mirror of
https://github.com/NixOS/nix.git
synced 2025-12-01 06:31:00 +01:00
Move /src to /subprojects
This will facilitate breaking up Nix into multiple packages for each component with Meson.
This commit is contained in:
parent
4db9487823
commit
84e2963f8e
737 changed files with 504 additions and 505 deletions
50
subprojects/libcmd/network-proxy.cc
Normal file
50
subprojects/libcmd/network-proxy.cc
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#include "network-proxy.hh"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "environment-variables.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
static const StringSet lowercaseVariables{"http_proxy", "https_proxy", "ftp_proxy", "all_proxy", "no_proxy"};
|
||||
|
||||
static StringSet getAllVariables()
|
||||
{
|
||||
StringSet variables = lowercaseVariables;
|
||||
for (const auto & variable : lowercaseVariables) {
|
||||
std::string upperVariable;
|
||||
std::transform(
|
||||
variable.begin(), variable.end(), upperVariable.begin(), [](unsigned char c) { return std::toupper(c); });
|
||||
variables.insert(std::move(upperVariable));
|
||||
}
|
||||
return variables;
|
||||
}
|
||||
|
||||
const StringSet networkProxyVariables = getAllVariables();
|
||||
|
||||
static StringSet getExcludingNoProxyVariables()
|
||||
{
|
||||
static const StringSet excludeVariables{"no_proxy", "NO_PROXY"};
|
||||
StringSet variables;
|
||||
std::set_difference(
|
||||
networkProxyVariables.begin(),
|
||||
networkProxyVariables.end(),
|
||||
excludeVariables.begin(),
|
||||
excludeVariables.end(),
|
||||
std::inserter(variables, variables.begin()));
|
||||
return variables;
|
||||
}
|
||||
|
||||
static const StringSet excludingNoProxyVariables = getExcludingNoProxyVariables();
|
||||
|
||||
bool haveNetworkProxyConnection()
|
||||
{
|
||||
for (const auto & variable : excludingNoProxyVariables) {
|
||||
if (getEnv(variable).has_value()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue