mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-05-10 14:58:27 +00:00
allow user to close the web interface
This commit is contained in:
parent
93aa79b02a
commit
ccb6b817de
@ -242,6 +242,7 @@ var options = {
|
||||
socketPort : 8003, // optional, internal port for web socket, replace this when it is conflict with your own service
|
||||
webConfigPort : 8088, // optional, internal port for web config(beta), replace this when it is conflict with your own service
|
||||
throttle : 10, // optional, speed limit in kb/s
|
||||
disableWebInterface : false //option, set it when you don't want to use the web interface
|
||||
};
|
||||
new proxy.proxyServer(options);
|
||||
|
||||
|
3
bin.js
3
bin.js
@ -48,7 +48,8 @@ if(program.clear){
|
||||
hostname : program.hostname,
|
||||
dbFile : program.file,
|
||||
throttle : program.throttle,
|
||||
rule : ruleModule
|
||||
rule : ruleModule,
|
||||
disableWebInterface:false
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "anyproxy",
|
||||
"version": "2.7.3",
|
||||
"version": "2.7.4",
|
||||
"description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.",
|
||||
"main": "proxy.js",
|
||||
"bin": {
|
||||
|
12
proxy.js
12
proxy.js
@ -65,6 +65,7 @@ if(fs.existsSync(process.cwd() + '/rule.js')){
|
||||
//option.webConfigPort : 8088(default)
|
||||
//option.dbFile : null(default)
|
||||
//option.throttle : null(default)
|
||||
//option.disableWebInterface
|
||||
function proxyServer(option){
|
||||
option = option || {};
|
||||
|
||||
@ -75,7 +76,8 @@ function proxyServer(option){
|
||||
proxyRules = option.rule || default_rule,
|
||||
proxyWebPort = option.webPort || DEFAULT_WEB_PORT, //port for web interface
|
||||
socketPort = option.socketPort || DEFAULT_WEBSOCKET_PORT, //port for websocket
|
||||
proxyConfigPort = option.webConfigPort || DEFAULT_CONFIG_PORT; //port to ui config server
|
||||
proxyConfigPort = option.webConfigPort || DEFAULT_CONFIG_PORT, //port to ui config server
|
||||
disableWebInterface = !!option.disableWebInterface ;
|
||||
|
||||
if(option.dbFile){
|
||||
GLOBAL.recorder = new Recorder({filename: option.dbFile});
|
||||
@ -124,6 +126,10 @@ function proxyServer(option){
|
||||
|
||||
//start web interface
|
||||
function(callback){
|
||||
if(disableWebInterface){
|
||||
console.log('web interface is disabled');
|
||||
callback(null);
|
||||
}else{
|
||||
|
||||
//web interface
|
||||
var args = [proxyWebPort, socketPort, proxyConfigPort, requestHandler.getRuleSummary(), ip.address()];
|
||||
@ -138,6 +144,7 @@ function proxyServer(option){
|
||||
}
|
||||
});
|
||||
|
||||
//TODO : uncaught exception
|
||||
//kill web server when father process exits
|
||||
process.on("exit",function(){
|
||||
child_webServer.kill();
|
||||
@ -153,7 +160,7 @@ function proxyServer(option){
|
||||
var configServer = new UIConfigServer(proxyConfigPort);
|
||||
configServer.on("rule_changed",function() {
|
||||
// console.log(arguments);
|
||||
})
|
||||
});
|
||||
|
||||
var tipText,webUrl;
|
||||
webUrl = "http://" + ip.address() + ":" + proxyWebPort +"/";
|
||||
@ -164,6 +171,7 @@ function proxyServer(option){
|
||||
console.log(color.green(tipText));
|
||||
callback(null);
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
//final callback
|
||||
|
Loading…
x
Reference in New Issue
Block a user