From 3e679f08347c9b4aae1cdb20f928aa4e7403aec7 Mon Sep 17 00:00:00 2001 From: OttoMao Date: Thu, 18 Jun 2015 20:23:42 +0800 Subject: [PATCH] print a hint when using SNI features in node <0.12 --- CHANGELOG | 5 +++++ lib/httpsServerMgr.js | 2 +- lib/log.js | 1 + package.json | 2 +- proxy.js | 6 ++++++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8325813..4c7b58f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +18 June: anyproxy 3.5.1: + + * print a hint when using SNI features in node <0.12 + * Ref : https://github.com/alibaba/anyproxy/issues/25 + 18 June: anyproxy 3.5.0: * it's a formal release of 3.4.0@beta. diff --git a/lib/httpsServerMgr.js b/lib/httpsServerMgr.js index a29d808..3e7bcca 100644 --- a/lib/httpsServerMgr.js +++ b/lib/httpsServerMgr.js @@ -48,7 +48,7 @@ function SNIPrepareCert(serverName,SNICallback){ SNICallback(null,ctx); }else{ logUtil.printLog("err occurred when prepare certs for SNI - " + err, logUtil.T_ERR); - logUtil.printLog("you may upgrade your Node.js to the lastest version", logUtil.T_ERR); + logUtil.printLog("you may upgrade your Node.js to >= v0.12", logUtil.T_ERR); } }); } diff --git a/lib/log.js b/lib/log.js index 4fc271d..2aae613 100644 --- a/lib/log.js +++ b/lib/log.js @@ -8,6 +8,7 @@ function printLog(content,type){ if(!ifPrint) return; var tip = content; + console.log(tip); } diff --git a/package.json b/package.json index 54bf107..69e194e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "3.5.0", + "version": "3.5.1", "description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.", "main": "proxy.js", "bin": { diff --git a/proxy.js b/proxy.js index 30cd9d8..484d292 100644 --- a/proxy.js +++ b/proxy.js @@ -93,6 +93,12 @@ function proxyServer(option){ if(!!option.interceptHttps){ default_rule.setInterceptFlag(true); + + //print a tip when using https features in Node < v0.12 + var nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]); + if(nodeVersion < 0.12){ + logUtil.printLog(color.red("node >= v0.12 is required when trying to intercept HTTPS requests :("), logUtil.T_ERR); + } } if(option.throttle){