mirror of
https://github.com/NixOS/nix
synced 2024-09-19 10:50:24 -04:00
nix
: Fix haveInternet
to check for proxy
This commit is contained in:
parent
6a5210f48e
commit
d3bff699aa
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue