summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/download.cpp39
-rw-r--r--src/net/download.h2
2 files changed, 41 insertions, 0 deletions
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 355d30eca..4eec6b0b4 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -249,6 +249,7 @@ int Download::downloadThread(void *ptr)
curl_easy_setopt(d->mCurl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(d->mCurl, CURLOPT_CONNECTTIMEOUT, 30);
curl_easy_setopt(d->mCurl, CURLOPT_TIMEOUT, 1800);
+ addProxy(d->mCurl);
if ((res = curl_easy_perform(d->mCurl)) != 0
&& !d->mOptions.cancel)
@@ -360,4 +361,42 @@ int Download::downloadThread(void *ptr)
return 0;
}
+void Download::addProxy(CURL *curl)
+{
+ const int mode = config.getIntValue("downloadProxyType");
+ if (!mode)
+ return;
+
+ if (mode > 1)
+ {
+ curl_easy_setopt(curl, CURLOPT_PROXY,
+ config.getStringValue("downloadProxy").c_str());
+ }
+ switch (mode)
+ {
+ case 1: // direct connection
+ default:
+ curl_easy_setopt(curl, CURLOPT_PROXY, "");
+ break;
+ case 2: // HTTP
+ break;
+ case 3: // HTTP 1.0
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP_1_0);
+ break;
+ case 4: // SOCKS4
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+ break;
+ case 5: // SOCKS4A
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
+ break;
+ case 6: // SOCKS5
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ break;
+ case 7: // SOCKS5 hostname
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE,
+ CURLPROXY_SOCKS5_HOSTNAME);
+ break;
+ }
+}
+
} // namespace Net
diff --git a/src/net/download.h b/src/net/download.h
index b31350eff..90e9777ae 100644
--- a/src/net/download.h
+++ b/src/net/download.h
@@ -91,6 +91,8 @@ class Download
static unsigned long fadler32(FILE *file);
+ static void addProxy(CURL *curl);
+
private:
static int downloadThread(void *ptr);
static int downloadProgress(void *clientp, double dltotal,