From f9ca0b2b2136fe40da077b1c50f744b649564e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=B3=E5=BD=93=E5=BD=93?= Date: Thu, 13 Nov 2014 11:32:59 +0800 Subject: [PATCH 1/3] add request --- package.json | 5 +++-- proxy.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2c57ca1..3b5896d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "2.8.6", + "version": "2.8.7", "description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.", "main": "proxy.js", "bin": { @@ -34,7 +34,8 @@ "socks5-https-client": "^0.2.2", "http-proxy-agent":"^0.2.6", "https-proxy-agent":"^0.3.5", - "tcp-ping":"^0.1.1" + "tcp-ping":"^0.1.1", + "request":"^2.48.0" }, "repository": { "type":"git", diff --git a/proxy.js b/proxy.js index 413a570..73a6f95 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['request'] = require('request'); GLOBAL.util['async'] = require('async'); }catch(e){} From 08680a7fa74b3e3f89fb7d850f0bc8aaf416cd5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=B3=E5=BD=93=E5=BD=93?= Date: Thu, 13 Nov 2014 13:12:13 +0800 Subject: [PATCH 2/3] userRule initialize --- lib/requestHandler.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/requestHandler.js b/lib/requestHandler.js index 03e6640..81bcae8 100644 --- a/lib/requestHandler.js +++ b/lib/requestHandler.js @@ -345,7 +345,27 @@ function setRules(newRule){ } userRule = util.merge(defaultRule,newRule); - 'function' == typeof(userRule.summary) && console.log(userRule.summary()); + + var functions = []; + if('function' == typeof(userRule.init)){ + functions.push(function(cb){ + userRule.init(cb); + }); + } + if('function' == typeof(userRule.summary)){ + functions.push(function(cb){ + userRule.summary(); + cb(null); + }); + } + async.series(functions,function(errors,result){ + if(!errors){ + console.log(color.green('Anyproxy initialize finished, have a fun!')); + } + }); + + //'function' == typeof(userRule.init) && console.log(userRule.init()); + //'function' == typeof(userRule.summary) && console.log(userRule.summary()); } } From bdc510326a4d7acc58c7d2921fc9a05a6d7a0966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=B3=E5=BD=93=E5=BD=93?= Date: Thu, 13 Nov 2014 13:14:08 +0800 Subject: [PATCH 3/3] update version --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c817c5..c93c36d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "2.8.9", + "version": "2.8.10", "description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.", "main": "proxy.js", "bin": { @@ -24,6 +24,7 @@ "test": "nodeunit test.js" }, "optionalDependencies":{ + "underscore":"^1.7.0", "cookie":"^0.1.2", "mysql":"^2.5.2", "iconv-lite": "^0.4.4",