diff options
-rw-r--r-- | src/main/cpp/blaze.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index 655406ae94..d023f6491a 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -1354,9 +1354,23 @@ static void ComputeBaseDirectories(const WorkspaceLayout *workspace_layout, static map<string, EnvVarValue> PrepareEnvironmentForJvm() { map<string, EnvVarValue> result; - if (!blaze::GetEnv("http_proxy").empty()) { - BAZEL_LOG(WARNING) << "ignoring http_proxy in environment."; - result["http_proxy"] = EnvVarValue(EnvVarAction::UNSET, ""); + // We need to disable HTTP proxies for local (gRPC-based) communication + // between the client and server. gRPC currently only checks http_proxy, but + // HTTP_PROXY could also be used to specify a proxy, so we check for both. + if (!blaze::GetEnv("http_proxy").empty() || + !blaze::GetEnv("HTTP_PROXY").empty()) { + BAZEL_LOG(WARNING) + << "detected http_proxy set in env, setting no_proxy for localhost."; + + // Disable HTTP proxies for localhost and any localhost-like address, + // in case we (or gRPC, etc.) ever use one of these addresses. + std::string localhost_addresses = "localhost,127.0.0.1,0:0:0:0:0:0:0:1,::1"; + result["no_proxy"] = EnvVarValue(EnvVarAction::SET, localhost_addresses); + result["NO_PROXY"] = EnvVarValue(EnvVarAction::SET, localhost_addresses); + + // Set no_proxy for the client, as well. + blaze::SetEnv("no_proxy", localhost_addresses); + blaze::SetEnv("NO_PROXY", localhost_addresses); } if (!blaze::GetEnv("LD_ASSUME_KERNEL").empty()) { |