summaryrefslogtreecommitdiff
path: root/indra/llmessage/llcurl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/llcurl.cpp')
-rw-r--r--indra/llmessage/llcurl.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index a485fa0160..020c0d6a4a 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -50,6 +50,8 @@
#include "llsdserialize.h"
#include "llthread.h"
+#include "llsocks5.h"
+
//////////////////////////////////////////////////////////////////////////////
/*
The trick to getting curl to do keep-alives is to reuse the
@@ -273,6 +275,28 @@ LLCurl::Easy* LLCurl::Easy::getEasy()
// set no DMS caching as default for all easy handles. This prevents them adopting a
// multi handles cache if they are added to one.
curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_DNS_CACHE_TIMEOUT, 0);
+
+ //Set the CURL options for either Socks or HTTP proxy
+ if (LLSocks::getInstance()->isHttpProxyEnabled())
+ {
+ std::string address = LLSocks::getInstance()->getHTTPProxy().getIPString();
+ U16 port = LLSocks::getInstance()->getHTTPProxy().getPort();
+ curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_PROXY,address.c_str());
+ curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_PROXYPORT,port);
+ if (LLSocks::getInstance()->getHttpProxyType() == LLPROXY_SOCKS)
+ {
+ curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ if(LLSocks::getInstance()->getSelectedAuthMethod()==METHOD_PASSWORD)
+ {
+ curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_PROXYUSERPWD,LLSocks::getInstance()->getProxyUserPwd().c_str());
+ }
+ }
+ else
+ {
+ curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+ }
+ }
+
++gCurlEasyCount;
return easy;
}
@@ -446,6 +470,26 @@ void LLCurl::Easy::prepRequest(const std::string& url,
// setopt(CURLOPT_VERBOSE, 1); // usefull for debugging
setopt(CURLOPT_NOSIGNAL, 1);
+ if (LLSocks::getInstance()->isHttpProxyEnabled())
+ {
+ std::string address = LLSocks::getInstance()->getHTTPProxy().getIPString();
+ U16 port = LLSocks::getInstance()->getHTTPProxy().getPort();
+ setoptString(CURLOPT_PROXY, address.c_str());
+ setopt(CURLOPT_PROXYPORT, port);
+ if (LLSocks::getInstance()->getHttpProxyType() == LLPROXY_SOCKS)
+ {
+ setopt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ if(LLSocks::getInstance()->getSelectedAuthMethod()==METHOD_PASSWORD)
+ {
+ setoptString(CURLOPT_PROXYUSERPWD,LLSocks::getInstance()->getProxyUserPwd());
+ }
+ }
+ else
+ {
+ setopt(CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+ }
+ }
+
mOutput.reset(new LLBufferArray);
setopt(CURLOPT_WRITEFUNCTION, (void*)&curlWriteCallback);
setopt(CURLOPT_WRITEDATA, (void*)this);