1
0
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:
Bryan Roe
2019-07-17 14:08:46 -07:00
parent 134461448e
commit 02f3d8a76f

View File

@@ -419,6 +419,8 @@ int MeshAgent_GetSystemProxy(MeshAgentHostContainer *agent, char *buffer, size_t
})();"; })();";
#else #else
char getProxy[] = "(function getProxies(){\ char getProxy[] = "(function getProxies(){\
if(require('fs').existsSync('/etc/environment'))\
{\
var e = require('fs').readFileSync('/etc/environment').toString();\ var e = require('fs').readFileSync('/etc/environment').toString();\
var tokens = e.split('\\n');\ var tokens = e.split('\\n');\
for(var line in tokens)\ for(var line in tokens)\
@@ -429,6 +431,16 @@ int MeshAgent_GetSystemProxy(MeshAgentHostContainer *agent, char *buffer, size_t
return(val[1].split('//')[1]);\ 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