aboutsummaryrefslogtreecommitdiff
path: root/src/nix/main.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 09:11:33 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 09:25:17 +0100
commit41b7876b32353f7649bccc5c7a11c02bf2e4c67a (patch)
treeb085c97a6a1e3f7cc6f8ee6c5b2f0b488c942a5d /src/nix/main.cc
parent82075c8ebdd0956844123e067f3c2fb7d29b0bbd (diff)
Merge pull request #10067 from ramboman/fix-proxy-nix
`nix`: Fix `haveInternet` to check for proxy (cherry picked from commit accae60e7710a18f6f2bd7d2f4cd836bcd76b684) Change-Id: I996dafdcd266f4bc5806386c86b19040120842bf
Diffstat (limited to 'src/nix/main.cc')
-rw-r--r--src/nix/main.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nix/main.cc b/src/nix/main.cc
index eb510eecc..f05c49523 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -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;
}