mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 20:16:03 +01:00
Merge pull request #10067 from ramboman/fix-proxy-nix
`nix`: Fix `haveInternet` to check for proxy
This commit is contained in:
commit
accae60e77
1 changed files with 20 additions and 0 deletions
|
|
@ -32,6 +32,24 @@ void chrootHelper(int argc, char * * argv);
|
||||||
|
|
||||||
namespace nix {
|
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. */
|
/* Check if we have a non-loopback/link-local network interface. */
|
||||||
static bool haveInternet()
|
static bool haveInternet()
|
||||||
{
|
{
|
||||||
|
|
@ -55,6 +73,8 @@ static bool haveInternet()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (haveProxyEnvironmentVariables()) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue