aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp
diff options
context:
space:
mode:
authorGravatar ruperts <ruperts@google.com>2018-06-04 10:21:02 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-04 10:22:39 -0700
commit9cf0f655dc0e416f88c64bebe0eed6f1536b33fd (patch)
treebce86ef6c4861744f6e6041734fedf41216b4b9e /src/main/cpp
parent97a932f5d2679c8273957405d6255595f9647511 (diff)
Set no_proxy=localhost when an http_proxy is detected, instead of deleting the http_proxy value.
Also change the environment for the client and the server in this case, instead of only changing the server's environment. RELNOTES: None. PiperOrigin-RevId: 199152406
Diffstat (limited to 'src/main/cpp')
-rw-r--r--src/main/cpp/blaze.cc20
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()) {