mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
safe guard around no proxy strings
This commit is contained in:
parent
48de600770
commit
f026cc43cd
@ -37,16 +37,9 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
std::string getNoProxyHostsString()
|
||||
const char * getNoProxyHosts()
|
||||
{
|
||||
const char * no_proxy = std::getenv(NO_PROXY_ENVIRONMENT_VARIABLE); // NOLINT(concurrency-mt-unsafe)
|
||||
|
||||
if (!no_proxy)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return no_proxy;
|
||||
return std::getenv(NO_PROXY_ENVIRONMENT_VARIABLE); // NOLINT(concurrency-mt-unsafe)
|
||||
}
|
||||
|
||||
ProxyConfiguration buildProxyConfiguration(
|
||||
@ -86,7 +79,8 @@ ProxyConfiguration EnvironmentProxyConfigurationResolver::resolve()
|
||||
{
|
||||
static const auto * http_proxy_host = getProxyHost(Protocol::HTTP);
|
||||
static const auto * https_proxy_host = getProxyHost(Protocol::HTTPS);
|
||||
static const auto no_proxy_hosts_string = buildPocoNonProxyHosts(getNoProxyHostsString());
|
||||
static const auto * no_proxy = getNoProxyHosts();
|
||||
static const auto poco_no_proxy_hosts = no_proxy ? buildPocoNonProxyHosts(no_proxy) : "";
|
||||
|
||||
static const Poco::URI http_proxy_uri(http_proxy_host ? http_proxy_host : "");
|
||||
static const Poco::URI https_proxy_uri(https_proxy_host ? https_proxy_host : "");
|
||||
@ -94,9 +88,8 @@ ProxyConfiguration EnvironmentProxyConfigurationResolver::resolve()
|
||||
return buildProxyConfiguration(
|
||||
request_protocol,
|
||||
request_protocol == Protocol::HTTP ? http_proxy_uri : https_proxy_uri,
|
||||
no_proxy_hosts_string,
|
||||
poco_no_proxy_hosts,
|
||||
disable_tunneling_for_https_requests_over_http_proxy);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,6 +53,11 @@ std::string buildPocoRegexpEntryWithoutLeadingDot(const std::string & host)
|
||||
* */
|
||||
std::string buildPocoNonProxyHosts(const std::string & no_proxy_hosts_string)
|
||||
{
|
||||
if (no_proxy_hosts_string.empty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
static constexpr auto OR_SEPARATOR = "|";
|
||||
static constexpr auto MATCH_ANYTHING = R"(.*)";
|
||||
static constexpr auto MATCH_SUBDOMAINS_REGEX = R"((?:.*\.)?)";
|
||||
|
Loading…
Reference in New Issue
Block a user