mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-18 09:13:14 +00:00
Updated proxy check, to look at /etc/profile.d/proxy_setup if it exists
This commit is contained in:
@@ -419,16 +419,28 @@ int MeshAgent_GetSystemProxy(MeshAgentHostContainer *agent, char *buffer, size_t
|
|||||||
})();";
|
})();";
|
||||||
#else
|
#else
|
||||||
char getProxy[] = "(function getProxies(){\
|
char getProxy[] = "(function getProxies(){\
|
||||||
var e = require('fs').readFileSync('/etc/environment').toString();\
|
if(require('fs').existsSync('/etc/environment'))\
|
||||||
var tokens = e.split('\\n');\
|
|
||||||
for(var line in tokens)\
|
|
||||||
{\
|
{\
|
||||||
var val = tokens[line].split('=');\
|
var e = require('fs').readFileSync('/etc/environment').toString();\
|
||||||
if(val.length == 2 && (val[0].trim() == 'http_proxy' || val[0].trim() == 'https_proxy'))\
|
var tokens = e.split('\\n');\
|
||||||
|
for(var line in tokens)\
|
||||||
{\
|
{\
|
||||||
return(val[1].split('//')[1]);\
|
var val = tokens[line].split('=');\
|
||||||
|
if(val.length == 2 && (val[0].trim() == 'http_proxy' || val[0].trim() == 'https_proxy'))\
|
||||||
|
{\
|
||||||
|
return(val[1].split('//')[1]);\
|
||||||
|
}\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
|
if(require('fs').existsSync('/etc/profile.d/proxy_setup'))\
|
||||||
|
{\
|
||||||
|
var child = require('child_process').execFile('/bin/sh', ['sh']);\
|
||||||
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });\
|
||||||
|
child.stdin.write('cat /etc/profile.d/proxy_setup | awk \\'{ split($2, tok, \"=\"); if(tok[1]==\"http_proxy\") { print tok[2]; }}\\'\\nexit\\n');\
|
||||||
|
child.waitExit();\
|
||||||
|
child.ret = child.stdout.str.trim().split('\\n')[0].split('//')[1];\
|
||||||
|
if(child.ret != '') { return(child.ret); }\
|
||||||
|
}\
|
||||||
throw('No Proxy set');\
|
throw('No Proxy set');\
|
||||||
})();";
|
})();";
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user