summaryrefslogtreecommitdiff
path: root/src/net/download.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-01 18:48:02 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-01 18:48:02 +0300
commit8b1922e8e7a227090cf01b05e65209076dec9df5 (patch)
treeba3c487dff6da52c6cca10e925b2b5a77f073742 /src/net/download.cpp
parenteb119ecb58cce24813b37108fce4c0f343bdc2ab (diff)
downloadmv-8b1922e8e7a227090cf01b05e65209076dec9df5.tar.gz
mv-8b1922e8e7a227090cf01b05e65209076dec9df5.tar.bz2
mv-8b1922e8e7a227090cf01b05e65209076dec9df5.tar.xz
mv-8b1922e8e7a227090cf01b05e65209076dec9df5.zip
Add support form different proxy types in download process.
Diffstat (limited to 'src/net/download.cpp')
-rw-r--r--src/net/download.cpp39
1 files changed, 39 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