Merge pull request #15699 from yashykt/noproxyarg

Add channel arg to enable/disable http proxy
pull/15730/head
Yash Tibrewal 7 years ago committed by GitHub
commit 56e59ef6b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      include/grpc/impl/codegen/grpc_types.h
  2. 13
      src/core/ext/filters/client_channel/http_proxy.cc

@ -336,6 +336,8 @@ typedef struct {
/** If non-zero, client authority filter is disabled for the channel */ /** If non-zero, client authority filter is disabled for the channel */
#define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \ #define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \
"grpc.disable_client_authority_filter" "grpc.disable_client_authority_filter"
/** If set to zero, disables use of http proxies. Enabled by default. */
#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy"
/** \} */ /** \} */
/** Result of a grpc call. If the caller satisfies the prerequisites of a /** Result of a grpc call. If the caller satisfies the prerequisites of a

@ -83,11 +83,24 @@ done:
return proxy_name; return proxy_name;
} }
/**
* Checks the value of GRPC_ARG_ENABLE_HTTP_PROXY to determine if http_proxy
* should be used.
*/
bool http_proxy_enabled(const grpc_channel_args* args) {
const grpc_arg* arg =
grpc_channel_args_find(args, GRPC_ARG_ENABLE_HTTP_PROXY);
return grpc_channel_arg_get_bool(arg, true);
}
static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper, static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper,
const char* server_uri, const char* server_uri,
const grpc_channel_args* args, const grpc_channel_args* args,
char** name_to_resolve, char** name_to_resolve,
grpc_channel_args** new_args) { grpc_channel_args** new_args) {
if (!http_proxy_enabled(args)) {
return false;
}
char* user_cred = nullptr; char* user_cred = nullptr;
*name_to_resolve = get_http_proxy_server(&user_cred); *name_to_resolve = get_http_proxy_server(&user_cred);
if (*name_to_resolve == nullptr) return false; if (*name_to_resolve == nullptr) return false;

Loading…
Cancel
Save