Skip to content
Snippets Groups Projects
Commit f15d28a6 authored by Logan Dethrow's avatar Logan Dethrow
Browse files

Proxy cleanup in llstartup.cpp and llproxy.cpp.

parent 814a2d24
No related branches found
No related tags found
No related merge requests found
...@@ -355,6 +355,8 @@ class LLCurlEasyRequest ...@@ -355,6 +355,8 @@ class LLCurlEasyRequest
bool getResult(CURLcode* result, LLCurl::TransferInfo* info = NULL); bool getResult(CURLcode* result, LLCurl::TransferInfo* info = NULL);
std::string getErrorString(); std::string getErrorString();
LLCurl::Easy* getEasy() const { return mEasy; }
private: private:
CURLMsg* info_read(S32* queue, LLCurl::TransferInfo* info); CURLMsg* info_read(S32* queue, LLCurl::TransferInfo* info);
......
...@@ -278,50 +278,15 @@ void LLProxy::cleanupClass() ...@@ -278,50 +278,15 @@ void LLProxy::cleanupClass()
} }
// Apply proxy settings to CuRL request if either type of HTTP proxy is enabled. // 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) applyProxySettings(handle->getEasy());
{
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);
}
}
} }
void LLProxy::applyProxySettings(LLCurlEasyRequest* handle)
void LLProxy::applyProxySettings(LLCurl::Easy* handle)
{ {
if (sHTTPProxyEnabled) applyProxySettings(handle->getCurlHandle());
{
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);
}
}
} }
void LLProxy::applyProxySettings(CURL* handle) void LLProxy::applyProxySettings(CURL* handle)
......
...@@ -2793,8 +2793,8 @@ bool LLStartUp::handleSocksProxy() ...@@ -2793,8 +2793,8 @@ bool LLStartUp::handleSocksProxy()
LLProxy::getInstance()->disableHTTPProxy(); LLProxy::getInstance()->disableHTTPProxy();
} }
bool use_socks_proxy = gSavedSettings.getBOOL("Socks5ProxyEnabled"); // Set up SOCKS proxy (if needed)
if (use_socks_proxy) if (gSavedSettings.getBOOL("Socks5ProxyEnabled"))
{ {
// Determine and update LLProxy with the saved authentication system // Determine and update LLProxy with the saved authentication system
...@@ -2826,45 +2826,54 @@ bool LLStartUp::handleSocksProxy() ...@@ -2826,45 +2826,54 @@ bool LLStartUp::handleSocksProxy()
// Start the proxy and check for errors // Start the proxy and check for errors
// If status != SOCKS_OK, stopProxy() will already have been called when startProxy() returns. // If status != SOCKS_OK, stopProxy() will already have been called when startProxy() returns.
int status = LLProxy::getInstance()->startProxy(gSavedSettings.getString("Socks5ProxyHost"), gSavedSettings.getU32("Socks5ProxyPort")); 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; if (status == SOCKS_OK)
switch(status)
{ {
case SOCKS_OK: return true;
return true; }
break; else
{
case SOCKS_CONNECT_ERROR: // TCP Fail LLSD subs;
error_string = "SOCKS_CONNECT_ERROR"; subs["HOST"] = gSavedSettings.getString("Socks5ProxyHost");
break; subs["PORT"] = (S32)gSavedSettings.getU32("Socks5ProxyPort");
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 std::string error_string;
error_string = "SOCKS_AUTH_FAIL";
break;
case SOCKS_UDP_FWD_NOT_GRANTED: // UDP forward request failed switch(status)
error_string = "SOCKS_UDP_FWD_NOT_GRANTED"; {
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;
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 LLNotificationsUtil::add(error_string, subs);
error_string = "SOCKS_HOST_CONNECT_FAILED"; return false;
break;
} }
LLNotificationsUtil::add(error_string, subs);
return false;
} }
else else
{ {
......
...@@ -7207,6 +7207,17 @@ Click and drag anywhere on the world to rotate your view ...@@ -7207,6 +7207,17 @@ Click and drag anywhere on the world to rotate your view
name="okbutton" name="okbutton"
yestext="OK"/> yestext="OK"/>
</notification> </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 <notification
icon="alertmodal.tga" icon="alertmodal.tga"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment