[monitoring-plugins] check_curl: handle proxied https requests

Sven Nierlein git at monitoring-plugins.org
Sun May 28 10:20:11 CEST 2017


 Module: monitoring-plugins
 Branch: feature_check_curl
 Commit: 7c7640833d4fae6260bdc312e70be79243958a55
 Author: Sven Nierlein <sven at nierlein.de>
   Date: Sun May 28 10:11:15 2017 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=7c76408

check_curl: handle proxied https requests

---

 plugins/check_curl.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 6856e78..0f06573 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -371,8 +371,19 @@ check_http (void)
   }
 #endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 21, 3) */
 
-  /* set port */
-  handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_PORT, server_port), "CURLOPT_PORT");
+  /* extract proxy information for legacy proxy https requests */
+  if (!strcmp(http_method, "CONNECT")) {
+    handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_PROXY, server_address), "CURLOPT_PROXY");
+    handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_PROXYPORT, (long)server_port), "CURLOPT_PROXYPORT");
+    if (verbose>=2)
+      printf ("* curl CURLOPT_PROXY: %s:%d\n", server_address, server_port);
+    http_method = "GET";
+    handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_URL, server_url), "CURLOPT_URL");
+    //server_port = use_ssl ? HTTPS_PORT : HTTP_PORT;
+  } else {
+    /* set port */
+    handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_PORT, server_port), "CURLOPT_PORT");
+  }
 
   /* set HTTP method */
   if (http_method) {



More information about the Commits mailing list