diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-04-01 18:48:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-04-01 18:48:02 +0300 |
commit | 8b1922e8e7a227090cf01b05e65209076dec9df5 (patch) | |
tree | ba3c487dff6da52c6cca10e925b2b5a77f073742 /src/net | |
parent | eb119ecb58cce24813b37108fce4c0f343bdc2ab (diff) | |
download | ManaVerse-8b1922e8e7a227090cf01b05e65209076dec9df5.tar.gz ManaVerse-8b1922e8e7a227090cf01b05e65209076dec9df5.tar.bz2 ManaVerse-8b1922e8e7a227090cf01b05e65209076dec9df5.tar.xz ManaVerse-8b1922e8e7a227090cf01b05e65209076dec9df5.zip |
Add support form different proxy types in download process.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/download.cpp | 39 | ||||
-rw-r--r-- | src/net/download.h | 2 |
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, |