You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by gr...@apache.org on 2020/03/24 13:43:13 UTC
[kudu] branch master updated: [util] set CURLOPT_NOPROXY for
EasyCurl
This is an automated email from the ASF dual-hosted git repository.
granthenke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new a33b095 [util] set CURLOPT_NOPROXY for EasyCurl
a33b095 is described below
commit a33b0951d91ecb0b84871bbf9d4b4b3550196af5
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Mon Mar 23 23:41:05 2020 -0700
[util] set CURLOPT_NOPROXY for EasyCurl
As it turned out, some environments set 'http_proxy' and 'https_proxy'
environment variables. This makes results unreliable for test scenarios
which fetch information from the embedded Kudu webserver.
This patch addresses that by programmatically setting CURLOPT_NOPROXY
to "*" wild-card by default, effectively disabling any proxying that
might otherwise occur if the mentioned environment variables were set.
Change-Id: If767bfb28516acb06f6243945300f5a362b869f8
Reviewed-on: http://gerrit.cloudera.org:8080/15542
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins
Reviewed-by: Grant Henke <gr...@apache.org>
---
src/kudu/util/curl_util.cc | 7 ++++++-
src/kudu/util/curl_util.h | 15 +++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/kudu/util/curl_util.cc b/src/kudu/util/curl_util.cc
index 82b0efc..e7992f7 100644
--- a/src/kudu/util/curl_util.cc
+++ b/src/kudu/util/curl_util.cc
@@ -71,7 +71,8 @@ size_t WriteCallback(void* buffer, size_t size, size_t nmemb, void* user_ptr) {
#define CURL_RETURN_NOT_OK(expr) \
RETURN_NOT_OK(TranslateError((expr), errbuf_))
-EasyCurl::EasyCurl() {
+EasyCurl::EasyCurl()
+ : noproxy_("*") {
// Use our own SSL initialization, and disable curl's.
// Both of these calls are idempotent.
security::InitializeOpenSSL();
@@ -167,6 +168,10 @@ Status EasyCurl::DoRequest(const string& url,
curl_, CURLOPT_CUSTOMREQUEST, custom_method_.c_str()));
}
+ if (!noproxy_.empty()) {
+ CURL_RETURN_NOT_OK(curl_easy_setopt(curl_, CURLOPT_NOPROXY, noproxy_.c_str()));
+ }
+
CURL_RETURN_NOT_OK(curl_easy_setopt(curl_, CURLOPT_HTTPAUTH, CURLAUTH_ANY));
if (timeout_.Initialized()) {
CURL_RETURN_NOT_OK(curl_easy_setopt(curl_, CURLOPT_NOSIGNAL, 1));
diff --git a/src/kudu/util/curl_util.h b/src/kudu/util/curl_util.h
index c1ddcc2..c05ce66 100644
--- a/src/kudu/util/curl_util.h
+++ b/src/kudu/util/curl_util.h
@@ -84,6 +84,19 @@ class EasyCurl {
custom_method_ = std::move(m);
}
+ // A comma-separated list of host names to avoid requests being proxied to,
+ // or "*" glob to disable proxying of any requests even if proxying is
+ // configured via CURLOPT_PROXY or '{http,https}_proxy' environment variables.
+ // An empty string "" clears the setting. By default, it's set to "*" since
+ // EasyCurl is primarily used in scenarios fetching data from embedded
+ // webservers of kudu-master/kudu-tserver running at the same host from where
+ // a request is issued, while 'http_proxy' and 'https_proxy' environment
+ // variables might be disruptive in that regard.
+ // See 'man CURLOPT_NOPROXY' for details.
+ void set_noproxy(std::string noproxy) {
+ noproxy_ = std::move(noproxy);
+ }
+
// Whether to return an error if server responds with HTTP code >= 400.
// By default, curl returns the returned content and the response code
// since it's handy in case of auth-related HTTP response codes such as
@@ -111,6 +124,8 @@ class EasyCurl {
std::string custom_method_;
+ std::string noproxy_;
+
// Whether to verify the server certificate.
bool verify_peer_ = true;