mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-06-07 09:48:21 +00:00
add -c
This commit is contained in:
parent
cf77e0ec1f
commit
5e87fd0707
22
index.js
22
index.js
@ -10,9 +10,10 @@ var http = require('http'),
|
|||||||
program = require('commander');
|
program = require('commander');
|
||||||
|
|
||||||
program
|
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('-t, --type [value]', 'http|https,http for default')
|
||||||
.option('-p, --port [value]', 'proxy port , 8001 for default')
|
.option('-p, --port [value]', 'proxy port, 8001 for default')
|
||||||
|
.option('-c, --clear', 'clear all the tmp certificates')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
var PROXY_PORT = program.port || 8001,
|
var PROXY_PORT = program.port || 8001,
|
||||||
@ -21,11 +22,16 @@ var PROXY_PORT = program.port || 8001,
|
|||||||
PROXY_TYPE = /https/i.test(program.type)? T_PROXY_HTTPS : T_PROXY_HTTP;
|
PROXY_TYPE = /https/i.test(program.type)? T_PROXY_HTTPS : T_PROXY_HTTP;
|
||||||
HOSTNAME = program.host || "localhost";
|
HOSTNAME = program.host || "localhost";
|
||||||
|
|
||||||
var serverMgrInstance = new serverMgr(),
|
if(program.clear){
|
||||||
|
exec("rm -rf ./cert/tmpCert",function(){
|
||||||
|
console.log("certificates cleared");
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
var serverMgrInstance = new serverMgr(),
|
||||||
httpProxyServer;
|
httpProxyServer;
|
||||||
|
|
||||||
|
async.series([
|
||||||
async.series([
|
|
||||||
//creat server
|
//creat server
|
||||||
function(callback){
|
function(callback){
|
||||||
if(PROXY_TYPE == T_PROXY_HTTP){
|
if(PROXY_TYPE == T_PROXY_HTTP){
|
||||||
@ -69,7 +75,11 @@ async.series([
|
|||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function dealProxyUserHttpReq(req,res){
|
function dealProxyUserHttpReq(req,res){
|
||||||
var urlPattern = url.parse(req.url);
|
var urlPattern = url.parse(req.url);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user