Merge pull request #10067 from ramboman/fix-proxy-nix

`nix`: Fix `haveInternet` to check for proxy

(cherry picked from commit accae60e7710a18f6f2bd7d2f4cd836bcd76b684)
Change-Id: I996dafdcd266f4bc5806386c86b19040120842bf
This commit is contained in:
eldritch horrors 2024-03-04 09:11:33 +01:00
parent 82075c8ebd
commit 41b7876b32

View file

@ -27,6 +27,24 @@ void chrootHelper(int argc, char * * argv);
namespace nix {
static bool haveProxyEnvironmentVariables()
{
static const std::vector<std::string> proxyVariables = {
"http_proxy",
"https_proxy",
"ftp_proxy",
"HTTP_PROXY",
"HTTPS_PROXY",
"FTP_PROXY"
};
for (auto & proxyVariable: proxyVariables) {
if (getEnv(proxyVariable).has_value()) {
return true;
}
}
return false;
}
/* Check if we have a non-loopback/link-local network interface. */
static bool haveInternet()
{
@ -50,6 +68,8 @@ static bool haveInternet()
}
}
if (haveProxyEnvironmentVariables()) return true;
return false;
}