mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-07-29 00:59:10 +00:00
update comments
This commit is contained in:
@@ -20,14 +20,39 @@ function execSync(cmd) {
|
||||
|
||||
|
||||
/**
|
||||
* proxy for Centos
|
||||
* ------------------------------------------------------------------------
|
||||
* linux like system proxy manager
|
||||
*
|
||||
* file: ~/.bash_profile
|
||||
*
|
||||
* http_proxy=http://proxy_server_address:port
|
||||
* export no_proxy=localhost,127.0.0.1,192.168.0.34
|
||||
* export http_proxy
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var unixLikeSysProxyManager = {};
|
||||
/**
|
||||
* proxy for Ubuntu
|
||||
* ------------------------------------------------------------------------
|
||||
*
|
||||
* file: /etc/environment
|
||||
* more info: http://askubuntu.com/questions/150210/how-do-i-set-systemwide-proxy-servers-in-xubuntu-lubuntu-or-ubuntu-studio
|
||||
*
|
||||
* http_proxy=http://proxy_server_address:port
|
||||
* export no_proxy=localhost,127.0.0.1,192.168.0.34
|
||||
* export http_proxy
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
unixLikeSysProxyManager.getNetworkType = function() {
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* mac proxy manager
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var macProxyManager = {};
|
||||
|
||||
macProxyManager.getNetworkType = function() {
|
||||
|
||||
for (var i = 0; i < networkTypes.length; i++) {
|
||||
|
||||
@@ -36,7 +61,7 @@ unixLikeSysProxyManager.getNetworkType = function() {
|
||||
result = execSync('networksetup -getwebproxy ' + type);
|
||||
|
||||
if (result.status === 0) {
|
||||
unixLikeSysProxyManager.networkType = type;
|
||||
macProxyManager.networkType = type;
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -44,14 +69,14 @@ unixLikeSysProxyManager.getNetworkType = function() {
|
||||
throw new Error('Unknown network type');
|
||||
};
|
||||
|
||||
unixLikeSysProxyManager.enableGlobalProxy = function(ip, port) {
|
||||
macProxyManager.enableGlobalProxy = function(ip, port) {
|
||||
|
||||
if (!ip && !port) {
|
||||
console.log('proxy server\'s ip and port is required');
|
||||
return;
|
||||
};
|
||||
|
||||
var networkType = unixLikeSysProxyManager.networkType || unixLikeSysProxyManager.getNetworkType();
|
||||
var networkType = macProxyManager.networkType || macProxyManager.getNetworkType();
|
||||
|
||||
var result = execSync(
|
||||
|
||||
@@ -70,8 +95,8 @@ unixLikeSysProxyManager.enableGlobalProxy = function(ip, port) {
|
||||
return result;
|
||||
};
|
||||
|
||||
unixLikeSysProxyManager.disableGlobalProxy = function() {
|
||||
var networkType = unixLikeSysProxyManager.networkType || unixLikeSysProxyManager.getNetworkType();
|
||||
macProxyManager.disableGlobalProxy = function() {
|
||||
var networkType = macProxyManager.networkType || macProxyManager.getNetworkType();
|
||||
|
||||
var result = execSync(
|
||||
|
||||
@@ -86,8 +111,8 @@ unixLikeSysProxyManager.disableGlobalProxy = function() {
|
||||
return result;
|
||||
};
|
||||
|
||||
unixLikeSysProxyManager.getProxyState = function() {
|
||||
var networkType = unixLikeSysProxyManager.networkType || unixLikeSysProxyManager.getNetworkType();
|
||||
macProxyManager.getProxyState = function() {
|
||||
var networkType = macProxyManager.networkType || macProxyManager.getNetworkType();
|
||||
var result = execSync('networksetup -getwebproxy ${networkType}'.replace('${networkType}', networkType));
|
||||
|
||||
return result;
|
||||
@@ -101,9 +126,9 @@ unixLikeSysProxyManager.getProxyState = function() {
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var winSysProxyManager = {};
|
||||
var winProxyManager = {};
|
||||
|
||||
winSysProxyManager.enableGlobalProxy = function(ip, port) {
|
||||
winProxyManager.enableGlobalProxy = function(ip, port) {
|
||||
|
||||
if (!ip && !port) {
|
||||
console.log('proxy server\'s ip and port is required');
|
||||
@@ -122,16 +147,16 @@ winSysProxyManager.enableGlobalProxy = function(ip, port) {
|
||||
|
||||
};
|
||||
|
||||
winSysProxyManager.disableGlobalProxy = function() {
|
||||
winProxyManager.disableGlobalProxy = function() {
|
||||
return execSync('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f');
|
||||
};
|
||||
|
||||
winSysProxyManager.getProxyState = function() {
|
||||
winProxyManager.getProxyState = function() {
|
||||
return '';
|
||||
};
|
||||
|
||||
winSysProxyManager.getNetworkType = function() {
|
||||
winProxyManager.getNetworkType = function() {
|
||||
return '';
|
||||
};
|
||||
|
||||
module.exports = /^win/.test(process.platform) ? winSysProxyManager : unixLikeSysProxyManager;
|
||||
module.exports = /^win/.test(process.platform) ? winProxyManager : macProxyManager;
|
||||
|
Reference in New Issue
Block a user