From bcb1f9d895284957cce1b18dc2b65d296fa182ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=B3=E5=BD=93=E5=BD=93?= Date: Mon, 10 Nov 2014 20:04:43 +0800 Subject: [PATCH 1/4] bugfix: process.on("exit",function(code){ --- package.json | 2 +- proxy.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6d0840a..07a541e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "2.8.3", + "version": "2.8.4", "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 1e7ae92..62f7b52 100644 --- a/proxy.js +++ b/proxy.js @@ -150,8 +150,14 @@ function proxyServer(option){ //TODO : uncaught exception //kill web server when father process exits - process.on("exit uncaughtException",function(){ + process.on("exit",function(code){ child_webServer.kill(); + console.log('AnyProxy is about to exit with code:', code); + process.exit(); + }); + process.on("uncaughtException",function(err){ + child_webServer.kill(); + console.log('Caught exception: ' + err); process.exit(); }); From 344326706ec2e950568dedec88c4ff759963ff75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=B3=E5=BD=93=E5=BD=93?= Date: Mon, 10 Nov 2014 20:07:33 +0800 Subject: [PATCH 2/4] bugfix:kill web server when father process exits --- proxy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/proxy.js b/proxy.js index 62f7b52..4a84878 100644 --- a/proxy.js +++ b/proxy.js @@ -155,6 +155,7 @@ function proxyServer(option){ console.log('AnyProxy is about to exit with code:', code); process.exit(); }); + process.on("uncaughtException",function(err){ child_webServer.kill(); console.log('Caught exception: ' + err); From f6ac9a3228c7287c0a76d856ddc0dd1f1ae00b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=B3=E5=BD=93=E5=BD=93?= Date: Wed, 12 Nov 2014 14:28:20 +0800 Subject: [PATCH 3/4] add tcp-ping --- lib/requestHandler.js | 1 + package.json | 5 +++-- proxy.js | 7 +++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/requestHandler.js b/lib/requestHandler.js index ff1e885..03e6640 100644 --- a/lib/requestHandler.js +++ b/lib/requestHandler.js @@ -274,6 +274,7 @@ function connectReqHandler(req, socket, head){ //find port function(callback){ + if(shouldIntercept){ //TODO : remote port other than 433 httpsServerMgrInstance.fetchPort(host,userRequestHandler,function(err,port){ diff --git a/package.json b/package.json index 07a541e..294eb12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "2.8.4", + "version": "2.8.5", "description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.", "main": "proxy.js", "bin": { @@ -33,7 +33,8 @@ "socks5-http-client": "^0.1.6", "socks5-https-client": "^0.2.2", "http-proxy-agent":"^0.2.6", - "https-proxy-agent":"^0.3.5" + "https-proxy-agent":"^0.3.5", + "tcp-ping":"^0.1.1" }, "repository": { "type":"git", diff --git a/proxy.js b/proxy.js index 4a84878..641a312 100644 --- a/proxy.js +++ b/proxy.js @@ -10,10 +10,9 @@ try{ GLOBAL.util['mysql'] = require('mysql'); GLOBAL.util['Socks5ClientHttpAgent'] = require('socks5-http-client/lib/Agent'); GLOBAL.util['Socks5ClientHttpsAgent'] = require('socks5-https-client/lib/Agent'); - GLOBAL.util['HttpProxyAgent'] = require("http-proxy-agent"); - GLOBAL.util['HttpsProxyAgent'] = require("https-proxy-agent"); - - + GLOBAL.util['HttpProxyAgent'] = require('http-proxy-agent'); + GLOBAL.util['HttpsProxyAgent'] = require('https-proxy-agent'); + GLOBAL.util['tcp-ping'] = require('tcp-ping'); }catch(e){} var http = require('http'), From 805d851ecf2f702416d77fdb727e18212767aac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=B3=E5=BD=93=E5=BD=93?= Date: Wed, 12 Nov 2014 21:22:14 +0800 Subject: [PATCH 4/4] Global.util.async --- package.json | 2 +- proxy.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 294eb12..2c57ca1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "2.8.5", + "version": "2.8.6", "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 641a312..413a570 100644 --- a/proxy.js +++ b/proxy.js @@ -13,6 +13,7 @@ try{ GLOBAL.util['HttpProxyAgent'] = require('http-proxy-agent'); GLOBAL.util['HttpsProxyAgent'] = require('https-proxy-agent'); GLOBAL.util['tcp-ping'] = require('tcp-ping'); + GLOBAL.util['async'] = require('async'); }catch(e){} var http = require('http'),