mirror of
https://github.com/NixOS/nix
synced 2025-07-03 14:31:46 +02:00
nix
: Fix haveInternet
to check for proxy
This commit is contained in:
parent
6a5210f48e
commit
d3bff699aa
1 changed files with 21 additions and 0 deletions
|
@ -23,6 +23,7 @@
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
@ -32,6 +33,24 @@ void chrootHelper(int argc, char * * argv);
|
||||||
|
|
||||||
namespace nix {
|
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. */
|
/* Check if we have a non-loopback/link-local network interface. */
|
||||||
static bool haveInternet()
|
static bool haveInternet()
|
||||||
{
|
{
|
||||||
|
@ -55,6 +74,8 @@ static bool haveInternet()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (haveProxyEnvironmentVariables()) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue