mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-23 16:01:26 +00:00
disable global proxy when user exit anyproxy by pressing ctrl/cmd + c
This commit is contained in:
parent
5b52859900
commit
a467f23ab0
@ -76,11 +76,11 @@ unixLikeSysProxyManager.disableGlobalProxy = function() {
|
|||||||
var result = execSync(
|
var result = execSync(
|
||||||
|
|
||||||
// disable http proxy
|
// disable http proxy
|
||||||
'networksetup -setwebproxystate ${networkType} off; '
|
'sudo networksetup -setwebproxystate ${networkType} off; '
|
||||||
.replace(/\$\{networkType\}/g, networkType) +
|
.replace(/\$\{networkType\}/g, networkType) +
|
||||||
|
|
||||||
// disable https proxy
|
// disable https proxy
|
||||||
'networksetup -setsecurewebproxystate ${networkType} off'
|
'sudo networksetup -setsecurewebproxystate ${networkType} off'
|
||||||
.replace(/\$\{networkType\}/g, networkType));
|
.replace(/\$\{networkType\}/g, networkType));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
13
proxy.js
13
proxy.js
@ -165,10 +165,16 @@ function proxyServer(option){
|
|||||||
var result = require('./lib/proxyManager').enableGlobalProxy(ip.address(), proxyPort);
|
var result = require('./lib/proxyManager').enableGlobalProxy(ip.address(), proxyPort);
|
||||||
|
|
||||||
if (result.status) {
|
if (result.status) {
|
||||||
console.log(color.red(result.stdout));
|
callback(result.stdout);
|
||||||
|
} else {
|
||||||
|
callback(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
callback(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//server status manager
|
//server status manager
|
||||||
@ -185,6 +191,11 @@ function proxyServer(option){
|
|||||||
process.exit();
|
process.exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//exit cause ctrl+c
|
||||||
|
process.on("SIGINT", function() {
|
||||||
|
process.exit();
|
||||||
|
});
|
||||||
|
|
||||||
process.on("uncaughtException",function(err){
|
process.on("uncaughtException",function(err){
|
||||||
logUtil.printLog('Caught exception: ' + (err.stack || err), logUtil.T_ERR);
|
logUtil.printLog('Caught exception: ' + (err.stack || err), logUtil.T_ERR);
|
||||||
process.exit();
|
process.exit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user