From 1c766d5c6d2ddec146f3140eeefff7557ecd8228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Sojma?= Date: Tue, 6 Nov 2018 15:03:15 +0100 Subject: [PATCH 1/3] ability to set "no_proxy" with use of "no_grpc_proxy" environment variable --- src/core/ext/filters/client_channel/http_proxy.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 8951a2920c4..3f05b23ffaf 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -122,7 +122,10 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, server_uri); goto no_use_proxy; } - no_proxy_str = gpr_getenv("no_proxy"); + no_proxy_str = gpr_getenv("no_grpc_proxy"); + if (no_proxy_str == nullptr) { + no_proxy_str = gpr_getenv("no_proxy"); + } if (no_proxy_str != nullptr) { static const char* NO_PROXY_SEPARATOR = ","; bool use_proxy = true; From c2ddef218fb066fd217432ac3703720d4671cdf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Sojma?= Date: Tue, 6 Nov 2018 15:16:56 +0100 Subject: [PATCH 2/3] ability to set proxy with use of "grpc_proxy" environment variable --- src/core/ext/filters/client_channel/http_proxy.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 3f05b23ffaf..94ef2c55ec8 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -47,10 +47,12 @@ static char* get_http_proxy_server(char** user_cred) { char* proxy_name = nullptr; char** authority_strs = nullptr; size_t authority_nstrs; - /* Prefer using 'https_proxy'. Fallback on 'http_proxy' if it is not set. The + /* Prefer using 'grpc_proxy'. Fallback on 'http_proxy' if it is not set. + * Also prefer using 'https_proxy' with fallback on 'http_proxy'. The * fallback behavior can be removed if there's a demand for it. */ - char* uri_str = gpr_getenv("https_proxy"); + char* uri_str = gpr_getenv("grpc_proxy"); + if (uri_str == nullptr) uri_str = gpr_getenv("https_proxy"); if (uri_str == nullptr) uri_str = gpr_getenv("http_proxy"); if (uri_str == nullptr) return nullptr; grpc_uri* uri = grpc_uri_parse(uri_str, false /* suppress_errors */); @@ -122,6 +124,7 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, server_uri); goto no_use_proxy; } + /* Prefer using 'no_grpc_proxy'. Fallback on 'no_proxy' if it is not set. */ no_proxy_str = gpr_getenv("no_grpc_proxy"); if (no_proxy_str == nullptr) { no_proxy_str = gpr_getenv("no_proxy"); From 43279fc50ba83296fb43234aeab67910e68e7fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Sojma?= Date: Tue, 6 Nov 2018 15:24:40 +0100 Subject: [PATCH 3/3] coding style update --- src/core/ext/filters/client_channel/http_proxy.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 94ef2c55ec8..26c8b439e75 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -126,9 +126,7 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, } /* Prefer using 'no_grpc_proxy'. Fallback on 'no_proxy' if it is not set. */ no_proxy_str = gpr_getenv("no_grpc_proxy"); - if (no_proxy_str == nullptr) { - no_proxy_str = gpr_getenv("no_proxy"); - } + if (no_proxy_str == nullptr) no_proxy_str = gpr_getenv("no_proxy"); if (no_proxy_str != nullptr) { static const char* NO_PROXY_SEPARATOR = ","; bool use_proxy = true;