From c55d293a56855842884f1f526834bf1884f36043 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 18 Sep 2017 02:20:13 +0300 Subject: Add option for enable http tunneling for downloads from http proxy. --- src/defaults.cpp | 1 + src/gui/widgets/tabs/setup_misc.cpp | 4 ++++ src/net/download.cpp | 9 +++++++++ 3 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/defaults.cpp b/src/defaults.cpp index 5dad898dd..c485c12e5 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -296,6 +296,7 @@ void setConfigDefaults(Configuration &cfg) AddDEF("autohideChat", false); AddDEF("downloadProxy", ""); AddDEF("downloadProxyType", 0); + AddDEF("downloadProxyTunnel", false); AddDEF("blur", false); #if defined(WIN32) || defined(__APPLE__) AddDEF("centerwindow", true); diff --git a/src/gui/widgets/tabs/setup_misc.cpp b/src/gui/widgets/tabs/setup_misc.cpp index f4ce6cba0..07b4c5193 100644 --- a/src/gui/widgets/tabs/setup_misc.cpp +++ b/src/gui/widgets/tabs/setup_misc.cpp @@ -385,6 +385,10 @@ Setup_Misc::Setup_Misc(const Widget2 *const widget) : new SetupItemTextField(_("Proxy address:port"), "", "downloadProxy", this, "downloadProxyEvent"); + // TRANSLATORS: settings option + new SetupItemCheckBox(_("Tunnel through HTTP proxy"), "", + "downloadProxyTunnel", this, "downloadProxyTunnelEvent"); + // TRANSLATORS: settings group new SetupItemLabel(_("Logging"), "", this); diff --git a/src/net/download.cpp b/src/net/download.cpp index db001d1b5..8fd8bfd1e 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -511,6 +511,7 @@ void Download::addProxy(CURL *const curl) curl_easy_setopt(curl, CURLOPT_PROXY, config.getStringValue("downloadProxy").c_str()); } + switch (mode) { case 1: // direct connection @@ -518,11 +519,19 @@ void Download::addProxy(CURL *const curl) curl_easy_setopt(curl, CURLOPT_PROXY, ""); break; case 2: // HTTP +#if LIBCURL_VERSION_NUM >= 0x070300 + curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, + config.getIntValue("downloadProxyTunnel")); +#endif // LIBCURL_VERSION_NUM >= 0x070300 break; case 3: // HTTP 1.0 #if LIBCURL_VERSION_NUM >= 0x071304 curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP_1_0); #endif // LIBCURL_VERSION_NUM >= 0x071304 +#if LIBCURL_VERSION_NUM >= 0x070300 + curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, + config.getIntValue("downloadProxyTunnel")); +#endif // LIBCURL_VERSION_NUM >= 0x070300 break; case 4: // SOCKS4 #if LIBCURL_VERSION_NUM >= 0x070a00 -- cgit v1.2.3-70-g09d2