summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLogan Dethrow <log@lindenlab.com>2011-07-28 13:47:20 -0400
committerLogan Dethrow <log@lindenlab.com>2011-07-28 13:47:20 -0400
commitf15d28a636da7b6d2784d9301e7a030b5bd38a8c (patch)
treeabd388bbf9dd24e067987ae6d46c7ff7794db2e1
parent814a2d24dca5181a31316a6f5e00e1a1cf55f23e (diff)
Proxy cleanup in llstartup.cpp and llproxy.cpp.
-rw-r--r--indra/llmessage/llcurl.h2
-rw-r--r--indra/llmessage/llproxy.cpp45
-rw-r--r--indra/newview/llstartup.cpp79
-rw-r--r--indra/newview/skins/default/xui/en/notifications.xml11
4 files changed, 62 insertions, 75 deletions
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
index 79f5eeb927..d60d3b6f40 100644
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -355,6 +355,8 @@ public:
bool getResult(CURLcode* result, LLCurl::TransferInfo* info = NULL);
std::string getErrorString();
+ LLCurl::Easy* getEasy() const { return mEasy; }
+
private:
CURLMsg* info_read(S32* queue, LLCurl::TransferInfo* info);
diff --git a/indra/llmessage/llproxy.cpp b/indra/llmessage/llproxy.cpp
index d34ad1a811..e1970f1368 100644
--- a/indra/llmessage/llproxy.cpp
+++ b/indra/llmessage/llproxy.cpp
@@ -278,50 +278,15 @@ void LLProxy::cleanupClass()
}
// Apply proxy settings to CuRL request if either type of HTTP proxy is enabled.
-void LLProxy::applyProxySettings(LLCurl::Easy* handle)
+void LLProxy::applyProxySettings(LLCurlEasyRequest* handle)
{
- if (sHTTPProxyEnabled)
- {
- std::string address = mHTTPProxy.getIPString();
- U16 port = mHTTPProxy.getPort();
- handle->setoptString(CURLOPT_PROXY, address.c_str());
- handle->setopt(CURLOPT_PROXYPORT, port);
- if (mProxyType == LLPROXY_SOCKS)
- {
- handle->setopt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- if (mAuthMethodSelected == METHOD_PASSWORD)
- {
- handle->setoptString(CURLOPT_PROXYUSERPWD, getProxyUserPwdCURL());
- }
- }
- else
- {
- handle->setopt(CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- }
- }
+ applyProxySettings(handle->getEasy());
}
-void LLProxy::applyProxySettings(LLCurlEasyRequest* handle)
+
+void LLProxy::applyProxySettings(LLCurl::Easy* handle)
{
- if (sHTTPProxyEnabled)
- {
- std::string address = mHTTPProxy.getIPString();
- U16 port = mHTTPProxy.getPort();
- handle->setoptString(CURLOPT_PROXY, address.c_str());
- handle->setopt(CURLOPT_PROXYPORT, port);
- if (mProxyType == LLPROXY_SOCKS)
- {
- handle->setopt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- if (mAuthMethodSelected == METHOD_PASSWORD)
- {
- handle->setoptString(CURLOPT_PROXYUSERPWD, getProxyUserPwdCURL());
- }
- }
- else
- {
- handle->setopt(CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- }
- }
+ applyProxySettings(handle->getCurlHandle());
}
void LLProxy::applyProxySettings(CURL* handle)
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 1fe241a8ce..eca3e5439e 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2793,8 +2793,8 @@ bool LLStartUp::handleSocksProxy()
LLProxy::getInstance()->disableHTTPProxy();
}
- bool use_socks_proxy = gSavedSettings.getBOOL("Socks5ProxyEnabled");
- if (use_socks_proxy)
+ // Set up SOCKS proxy (if needed)
+ if (gSavedSettings.getBOOL("Socks5ProxyEnabled"))
{
// Determine and update LLProxy with the saved authentication system
@@ -2826,45 +2826,54 @@ bool LLStartUp::handleSocksProxy()
// Start the proxy and check for errors
// If status != SOCKS_OK, stopProxy() will already have been called when startProxy() returns.
int status = LLProxy::getInstance()->startProxy(gSavedSettings.getString("Socks5ProxyHost"), gSavedSettings.getU32("Socks5ProxyPort"));
- LLSD subs;
- subs["HOST"] = gSavedSettings.getString("Socks5ProxyHost");
- subs["PORT"] = (S32)gSavedSettings.getU32("Socks5ProxyPort");
- std::string error_string;
-
- switch(status)
+ if (status == SOCKS_OK)
{
- case SOCKS_OK:
- return true;
- break;
-
- case SOCKS_CONNECT_ERROR: // TCP Fail
- error_string = "SOCKS_CONNECT_ERROR";
- break;
-
- case SOCKS_NOT_PERMITTED: // SOCKS 5 server rule set refused connection
- error_string = "SOCKS_NOT_PERMITTED";
- break;
-
- case SOCKS_NOT_ACCEPTABLE: // Selected authentication is not acceptable to server
- error_string = "SOCKS_NOT_ACCEPTABLE";
- break;
+ return true;
+ }
+ else
+ {
+ LLSD subs;
+ subs["HOST"] = gSavedSettings.getString("Socks5ProxyHost");
+ subs["PORT"] = (S32)gSavedSettings.getU32("Socks5ProxyPort");
- case SOCKS_AUTH_FAIL: // Authentication failed
- error_string = "SOCKS_AUTH_FAIL";
- break;
+ std::string error_string;
- case SOCKS_UDP_FWD_NOT_GRANTED: // UDP forward request failed
- error_string = "SOCKS_UDP_FWD_NOT_GRANTED";
- break;
+ switch(status)
+ {
+ case SOCKS_CONNECT_ERROR: // TCP Fail
+ error_string = "SOCKS_CONNECT_ERROR";
+ break;
+
+ case SOCKS_NOT_PERMITTED: // SOCKS 5 server rule set refused connection
+ error_string = "SOCKS_NOT_PERMITTED";
+ break;
+
+ case SOCKS_NOT_ACCEPTABLE: // Selected authentication is not acceptable to server
+ error_string = "SOCKS_NOT_ACCEPTABLE";
+ break;
+
+ case SOCKS_AUTH_FAIL: // Authentication failed
+ error_string = "SOCKS_AUTH_FAIL";
+ break;
+
+ case SOCKS_UDP_FWD_NOT_GRANTED: // UDP forward request failed
+ error_string = "SOCKS_UDP_FWD_NOT_GRANTED";
+ break;
+
+ case SOCKS_HOST_CONNECT_FAILED: // Failed to open a TCP channel to the socks server
+ error_string = "SOCKS_HOST_CONNECT_FAILED";
+ break;
+
+ default:
+ error_string = "SOCKS_UNKNOWN_STATUS"; // Something strange happened,
+ LL_WARNS("Proxy") << "Unknown return from LLProxy::startProxy(): " << status << LL_ENDL;
+ break;
+ }
- case SOCKS_HOST_CONNECT_FAILED: // Failed to open a TCP channel to the socks server
- error_string = "SOCKS_HOST_CONNECT_FAILED";
- break;
+ LLNotificationsUtil::add(error_string, subs);
+ return false;
}
-
- LLNotificationsUtil::add(error_string, subs);
- return false;
}
else
{
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 78685dbd79..8b7e6d8c4e 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -7207,6 +7207,17 @@ Click and drag anywhere on the world to rotate your view
name="okbutton"
yestext="OK"/>
</notification>
+
+ <notification
+ icon="alertmodal.tga"
+ name="SOCKS_UNKNOWN_STATUS"
+ type="alertmodal">
+ Unknown SOCKS error with server "[HOST]:[PORT]"
+ <tag>fail</tag>
+ <usetemplate
+ name="okbutton"
+ yestext="OK"/>
+ </notification>
<notification
icon="alertmodal.tga"