1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 23:03:53 -04:00

nix: Fix haveInternet to check for proxy

This commit is contained in:
ramboman 2024-02-23 01:05:25 -05:00
parent 6a5210f48e
commit d3bff699aa

View file

@ -23,6 +23,7 @@
#include <netdb.h>
#include <netinet/in.h>
#include <regex>
#include <cstdlib>
#include <nlohmann/json.hpp>
@ -32,6 +33,24 @@ void chrootHelper(int argc, char * * argv);
namespace nix {
static bool haveProxyEnvironmentVariables()
{
static const char * const proxyVariables[] = {
"http_proxy",
"https_proxy",
"ftp_proxy",
"HTTP_PROXY",
"HTTPS_PROXY",
"FTP_PROXY"
};
for (auto & proxyVariable: proxyVariables) {
if (std::getenv(proxyVariable)) {
return true;
}
}
return false;
}
/* Check if we have a non-loopback/link-local network interface. */
static bool haveInternet()
{
@ -55,6 +74,8 @@ static bool haveInternet()
}
}
if (haveProxyEnvironmentVariables()) return true;
return false;
}