mirror of https://github.com/SeanOMik/znc-push.git
Add explicit proxy support when using libcurl.
The appropriate *_proxy environment variables aren't always detected properly by libcurl. This allows manually setting the proxy when this happens, and disabling SSL certificate verification if the proxy requires it.
This commit is contained in:
parent
e0aacab2b6
commit
b9995692e8
|
@ -112,7 +112,7 @@ and looking in your profile or settings:
|
|||
/msg *push set username foo
|
||||
/msg *push set secret ...
|
||||
|
||||
If you're using Boxcar, you need to use the following command to send a subscription request
|
||||
If you're using Boxcar or Airgram, you need to use the following command to send a subscription request
|
||||
to your account, before ZNC Push can start working:
|
||||
|
||||
/msg *push subscribe
|
||||
|
|
21
push.cpp
21
push.cpp
|
@ -147,6 +147,10 @@ class CPushMod : public CModule
|
|||
defaults["nick_blacklist"] = "";
|
||||
defaults["replied"] = "yes";
|
||||
|
||||
// Proxy, for libcurl
|
||||
defaults["proxy"] = "";
|
||||
defaults["proxy_ssl_verify"] = "yes";
|
||||
|
||||
// Advanced
|
||||
defaults["channel_conditions"] = "all";
|
||||
defaults["query_conditions"] = "all";
|
||||
|
@ -570,13 +574,15 @@ class CPushMod : public CModule
|
|||
|
||||
#ifdef USE_CURL
|
||||
PutDebug("using libcurl");
|
||||
params["proxy"] = options["proxy"];
|
||||
params["proxy_ssl_verify"] = options["proxy_ssl_verify"];
|
||||
make_curl_request(service_host, service_url, service_auth, params, use_port, use_ssl, use_post, options["debug"] == "on");
|
||||
#else
|
||||
PutDebug("NOT using libcurl");
|
||||
// Create the socket connection, write to it, and add it to the queue
|
||||
CPushSocket *sock = new CPushSocket(this);
|
||||
sock->Connect(service_host, use_port, use_ssl);
|
||||
sock->Request(use_post, service_host, service_url, params, service_auth);
|
||||
sock->Request(use_post, service_host, service_url, params, service_auth, options["proxy"].c_str());
|
||||
AddSocket(sock);
|
||||
#endif
|
||||
}
|
||||
|
@ -1531,13 +1537,16 @@ class CPushMod : public CModule
|
|||
return;
|
||||
}
|
||||
|
||||
params["proxy"] = options["proxy"];
|
||||
params["proxy_ssl_verify"] = options["proxy_ssl_verify"];
|
||||
|
||||
#ifdef USE_CURL
|
||||
make_curl_request(service_host, service_url, service_auth, params, use_port, use_ssl, use_post, options["debug"] == "on");
|
||||
#else
|
||||
// Create the socket connection, write to it, and add it to the queue
|
||||
CPushSocket *sock = new CPushSocket(this);
|
||||
sock->Connect(service_host, use_port, use_ssl);
|
||||
sock->Request(use_post, service_host, service_url, params, service_auth);
|
||||
sock->Request(use_post, service_host, service_url, params, service_auth, options["proxy"].c_str());
|
||||
AddSocket(sock);
|
||||
#endif
|
||||
|
||||
|
@ -1657,6 +1666,14 @@ CURLcode make_curl_request(const CString& service_host, const CString& service_u
|
|||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, query.length());
|
||||
}
|
||||
|
||||
if (params["proxy"] != "") {
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, params["proxy"].c_str());
|
||||
|
||||
if (params["proxy_ssl_verify"] == "no") {
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
result = curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
|
|
Loading…
Reference in New Issue