1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-05 18:13:38 +00:00

Updated, so on linux, if env variable for proxy isn't set, it'll check /etc/environment to see if proxy is set.

This commit is contained in:
Bryan Roe
2019-02-19 13:52:32 -08:00
parent e370491f98
commit 9ba3fbf4a1

View File

@@ -396,6 +396,31 @@ int MeshAgent_GetSystemProxy(MeshAgentHostContainer *agent, char *buffer, size_t
}
}
}
if (retVal == 0)
{
// Check /etc/environment just in case it wasn't exported
char getProxy[] = "(function getProxies(){\
var e = require('fs').readFileSync('/etc/environment').toString();\
var tokens = e.split('\\n');\
for(var line in tokens)\
{\
var val = tokens[line].split('=');\
if(val.length == 2 && (val[0].trim() == 'http_proxy' || val[0].trim() == 'https_proxy'))\
{\
return(val[1].split('//')[1]);\
}\
}\
throw('No Proxy set');\
})();";
if (duk_peval_string(agent->meshCoreCtx, getProxy) == 0)
{
duk_size_t proxyLen;
char *proxy = (char*)duk_get_lstring(agent->meshCoreCtx, -1, &proxyLen);
strcpy_s(buffer, bufferSize, proxy);
retVal = (int)proxyLen;
}
duk_pop(agent->meshCoreCtx);
}
return(retVal);
#else
char getProxyies[] = "(function getProxies(){\