This commit is contained in:
加里 2014-08-09 16:33:51 +08:00
parent cf77e0ec1f
commit 5e87fd0707

View File

@ -10,9 +10,10 @@ var http = require('http'),
program = require('commander');
program
.option('-h, --host [value]', 'hostname,use for https proxy. localhost for default')
.option('-h, --host [value]', 'hostname for https proxy, localhost for default')
.option('-t, --type [value]', 'http|https,http for default')
.option('-p, --port [value]', 'proxy port, 8001 for default')
.option('-c, --clear', 'clear all the tmp certificates')
.parse(process.argv);
var PROXY_PORT = program.port || 8001,
@ -21,10 +22,15 @@ var PROXY_PORT = program.port || 8001,
PROXY_TYPE = /https/i.test(program.type)? T_PROXY_HTTPS : T_PROXY_HTTP;
HOSTNAME = program.host || "localhost";
if(program.clear){
exec("rm -rf ./cert/tmpCert",function(){
console.log("certificates cleared");
process.exit(0);
});
}else{
var serverMgrInstance = new serverMgr(),
httpProxyServer;
async.series([
//creat server
function(callback){
@ -70,6 +76,10 @@ async.series([
}
}
);
}
function dealProxyUserHttpReq(req,res){
var urlPattern = url.parse(req.url);