From 74d9bf0d5525426feae4ea21e2a81034ddcf4d7f Mon Sep 17 00:00:00 2001 From: Robin Cornelius Date: Mon, 28 Mar 2011 11:20:06 +0100 Subject: VWR-20801 Implement SOCKS 5 Proxy for the viewer --- indra/newview/llstartup.cpp | 123 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 8fccb35886..f054bd11b8 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -191,6 +191,8 @@ #include "llevents.h" #include "llstartuplistener.h" +#include "llsocks5.h" + #if LL_WINDOWS #include "lldxhardware.h" #endif @@ -393,7 +395,7 @@ bool idle_startup() gSavedSettings.setS32("LastGPUClass", LLFeatureManager::getInstance()->getGPUClass()); // load dynamic GPU/feature tables from website (S3) - LLFeatureManager::getInstance()->fetchHTTPTables(); + //LLFeatureManager::getInstance()->fetchHTTPTables(); std::string xml_file = LLUI::locateSkin("xui_version.xml"); LLXMLNodePtr root; @@ -595,6 +597,15 @@ bool idle_startup() LL_INFOS("AppInit") << "Message System Initialized." << LL_ENDL; + //------------------------------------------------- + // Init the socks 5 proxy and open the control TCP + // connection if the user is using SOCKS5 + // We need to do this early incase the user is using + // socks for http so we get the login screen via socks + //------------------------------------------------- + + LLStartUp::handleSocksProxy(false); + //------------------------------------------------- // Init audio, which may be needed for prefs dialog // or audio cues in connection UI. @@ -809,6 +820,27 @@ bool idle_startup() if (STATE_LOGIN_CLEANUP == LLStartUp::getStartupState()) { + // Post login screen, we should see if any settings have changed that may + // require us to either start/stop or change the socks proxy. As various communications + // past this point may require the proxy to be up. + if ( gSavedSettings.getBOOL("Socks5ProxyEnabled") ) + { + if (!LLStartUp::handleSocksProxy(true)) + { + // Proxy start up failed, we should now bail the state machine + // HandleSocksProxy() will have reported an error to the user + // already, so we just go back to the login screen. The user + // could then change the preferences to fix the issue. + LLStartUp::setStartupState(STATE_LOGIN_SHOW); + return FALSE; + } + } + else + { + LLSocks::getInstance()->stopProxy(); + } + + //reset the values that could have come in from a slurl // DEV-42215: Make sure they're not empty -- gUserCredential // might already have been set from gSavedSettings, and it's too bad @@ -2746,6 +2778,95 @@ void LLStartUp::setStartSLURL(const LLSLURL& slurl) } } +bool LLStartUp::handleSocksProxy(bool reportOK) +{ + std::string httpProxyType = gSavedSettings.getString("Socks5HttpProxyType"); + + // Determine the http proxy type (if any) + if ((httpProxyType.compare("Web") == 0) && gSavedSettings.getBOOL("BrowserProxyEnabled")) + { + LLHost httpHost; + httpHost.setHostByName(gSavedSettings.getString("BrowserProxyAddress")); + httpHost.setPort(gSavedSettings.getS32("BrowserProxyPort")); + LLSocks::getInstance()->EnableHttpProxy(httpHost,LLPROXY_HTTP); + } + else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) + { + LLHost httpHost; + httpHost.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); + httpHost.setPort(gSavedSettings.getU32("Socks5ProxyPort")); + LLSocks::getInstance()->EnableHttpProxy(httpHost,LLPROXY_SOCKS); + } + else + { + LLSocks::getInstance()->DisableHttpProxy(); + } + + bool use_socks_proxy = gSavedSettings.getBOOL("Socks5ProxyEnabled"); + if (use_socks_proxy) + { + + // Determine and update LLSocks with the saved authentication system + std::string auth_type = gSavedSettings.getString("Socks5AuthType"); + + if (auth_type.compare("None") == 0) + { + LLSocks::getInstance()->setAuthNone(); + } + + if (auth_type.compare("UserPass") == 0) + { + LLSocks::getInstance()->setAuthPassword(gSavedSettings.getString("Socks5Username"),gSavedSettings.getString("Socks5Password")); + } + + // Start the proxy and check for errors + int status = LLSocks::getInstance()->startProxy(gSavedSettings.getString("Socks5ProxyHost"), gSavedSettings.getU32("Socks5ProxyPort")); + LLSD subs; + LLSD payload; + subs["HOST"] = gSavedSettings.getString("Socks5ProxyHost"); + subs["PORT"] = (S32)gSavedSettings.getU32("Socks5ProxyPort"); + + switch(status) + { + case SOCKS_OK: + return true; + break; + + case SOCKS_CONNECT_ERROR: // TCP Fail + LLNotifications::instance().add("SOCKS_CONNECT_ERROR", subs,payload); + break; + + case SOCKS_NOT_PERMITTED: // Socks5 server rule set refused connection + LLNotifications::instance().add("SOCKS_NOT_PERMITTED", subs,payload); + break; + + case SOCKS_NOT_ACCEPTABLE: // Selected authentication is not acceptable to server + LLNotifications::instance().add("SOCKS_NOT_ACCEPTABLE", subs,payload); + break; + + case SOCKS_AUTH_FAIL: // Authentication failed + LLNotifications::instance().add("SOCKS_AUTH_FAIL", subs,payload); + break; + + case SOCKS_UDP_FWD_NOT_GRANTED: // UDP forward request failed + LLNotifications::instance().add("SOCKS_UDP_FWD_NOT_GRANTED", subs,payload); + break; + + case SOCKS_HOST_CONNECT_FAILED: // Failed to open a TCP channel to the socks server + LLNotifications::instance().add("SOCKS_HOST_CONNECT_FAILED", subs,payload); + break; + } + + return false; + } + else + { + LLSocks::getInstance()->stopProxy(); //ensure no UDP proxy is running and its all cleaned up + } + + return true; +} + bool login_alert_done(const LLSD& notification, const LLSD& response) { LLPanelLogin::giveFocus(); -- cgit v1.2.3 From 6ce2c20a06e32825f4e4260575059a9867510ecd Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Fri, 10 Jun 2011 17:34:00 -0400 Subject: STORM-1112 First pass at cleanup of SOCKS 5 proxy code based on Linden Coding Standard and comments in the code review. --- indra/newview/llstartup.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index d54c5b177a..6d94a5454e 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2770,18 +2770,18 @@ bool LLStartUp::handleSocksProxy(bool reportOK) LLHost httpHost; httpHost.setHostByName(gSavedSettings.getString("BrowserProxyAddress")); httpHost.setPort(gSavedSettings.getS32("BrowserProxyPort")); - LLSocks::getInstance()->EnableHttpProxy(httpHost,LLPROXY_HTTP); + LLSocks::getInstance()->enableHttpProxy(httpHost,LLPROXY_HTTP); } else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) { LLHost httpHost; httpHost.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); httpHost.setPort(gSavedSettings.getU32("Socks5ProxyPort")); - LLSocks::getInstance()->EnableHttpProxy(httpHost,LLPROXY_SOCKS); + LLSocks::getInstance()->enableHttpProxy(httpHost,LLPROXY_SOCKS); } else { - LLSocks::getInstance()->DisableHttpProxy(); + LLSocks::getInstance()->disableHttpProxy(); } bool use_socks_proxy = gSavedSettings.getBOOL("Socks5ProxyEnabled"); @@ -2843,7 +2843,7 @@ bool LLStartUp::handleSocksProxy(bool reportOK) } else { - LLSocks::getInstance()->stopProxy(); //ensure no UDP proxy is running and its all cleaned up + LLSocks::getInstance()->stopProxy(); // ensure no UDP proxy is running and it's all cleaned up } return true; -- cgit v1.2.3 From 20100ba38c6d3fa16ab11be2ed326ab0964c4c21 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Tue, 21 Jun 2011 17:09:12 -0400 Subject: Refactored SOCKS 5 handshake to use existing LLSocket class. --- indra/newview/llstartup.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 6d94a5454e..c2f0ca164b 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2770,18 +2770,18 @@ bool LLStartUp::handleSocksProxy(bool reportOK) LLHost httpHost; httpHost.setHostByName(gSavedSettings.getString("BrowserProxyAddress")); httpHost.setPort(gSavedSettings.getS32("BrowserProxyPort")); - LLSocks::getInstance()->enableHttpProxy(httpHost,LLPROXY_HTTP); + LLSocks::getInstance()->enableHTTPProxy(httpHost,LLPROXY_HTTP); } else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) { LLHost httpHost; httpHost.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); httpHost.setPort(gSavedSettings.getU32("Socks5ProxyPort")); - LLSocks::getInstance()->enableHttpProxy(httpHost,LLPROXY_SOCKS); + LLSocks::getInstance()->enableHTTPProxy(httpHost,LLPROXY_SOCKS); } else { - LLSocks::getInstance()->disableHttpProxy(); + LLSocks::getInstance()->disableHTTPProxy(); } bool use_socks_proxy = gSavedSettings.getBOOL("Socks5ProxyEnabled"); -- cgit v1.2.3 From 7717b6f647feb250c0b94d038f72a640a7888915 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Tue, 28 Jun 2011 19:54:53 -0400 Subject: STORM-1112 More cleanup of SOCKS 5 proxy code. Renamed llsocks5.cpp to llproxy.cpp. --- indra/newview/llstartup.cpp | 80 +++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 32 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index c2f0ca164b..7f14e403b0 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -125,6 +125,7 @@ #include "llpanelgroupnotices.h" #include "llpreview.h" #include "llpreviewscript.h" +#include "llproxy.h" #include "llproductinforequest.h" #include "llsecondlifeurls.h" #include "llselectmgr.h" @@ -191,8 +192,6 @@ #include "llevents.h" #include "llstartuplistener.h" -#include "llsocks5.h" - #if LL_WINDOWS #include "lldxhardware.h" #endif @@ -392,7 +391,7 @@ bool idle_startup() gSavedSettings.setS32("LastGPUClass", LLFeatureManager::getInstance()->getGPUClass()); // load dynamic GPU/feature tables from website (S3) - //LLFeatureManager::getInstance()->fetchHTTPTables(); + LLFeatureManager::getInstance()->fetchHTTPTables(); std::string xml_file = LLUI::locateSkin("xui_version.xml"); LLXMLNodePtr root; @@ -595,13 +594,13 @@ bool idle_startup() LL_INFOS("AppInit") << "Message System Initialized." << LL_ENDL; //------------------------------------------------- - // Init the socks 5 proxy and open the control TCP - // connection if the user is using SOCKS5 - // We need to do this early incase the user is using - // socks for http so we get the login screen via socks + // Init the SOCKS 5 proxy and open the control TCP + // connection if the user is using SOCKS 5 + // We need to do this early in case the user is using + // socks for HTTP so we get the login screen via SOCKS //------------------------------------------------- - LLStartUp::handleSocksProxy(false); + LLStartUp::handleSocksProxy(); //------------------------------------------------- // Init audio, which may be needed for prefs dialog @@ -823,7 +822,7 @@ bool idle_startup() // past this point may require the proxy to be up. if ( gSavedSettings.getBOOL("Socks5ProxyEnabled") ) { - if (!LLStartUp::handleSocksProxy(true)) + if (!LLStartUp::handleSocksProxy()) { // Proxy start up failed, we should now bail the state machine // HandleSocksProxy() will have reported an error to the user @@ -835,7 +834,7 @@ bool idle_startup() } else { - LLSocks::getInstance()->stopProxy(); + LLProxy::getInstance()->stopProxy(); } @@ -2760,54 +2759,70 @@ void LLStartUp::setStartSLURL(const LLSLURL& slurl) } } -bool LLStartUp::handleSocksProxy(bool reportOK) +bool LLStartUp::handleSocksProxy() { std::string httpProxyType = gSavedSettings.getString("Socks5HttpProxyType"); - // Determine the http proxy type (if any) + // Determine the HTTP proxy type (if any) if ((httpProxyType.compare("Web") == 0) && gSavedSettings.getBOOL("BrowserProxyEnabled")) { LLHost httpHost; httpHost.setHostByName(gSavedSettings.getString("BrowserProxyAddress")); httpHost.setPort(gSavedSettings.getS32("BrowserProxyPort")); - LLSocks::getInstance()->enableHTTPProxy(httpHost,LLPROXY_HTTP); + LLProxy::getInstance()->enableHTTPProxy(httpHost, LLPROXY_HTTP); } else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) { LLHost httpHost; httpHost.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); httpHost.setPort(gSavedSettings.getU32("Socks5ProxyPort")); - LLSocks::getInstance()->enableHTTPProxy(httpHost,LLPROXY_SOCKS); + LLProxy::getInstance()->enableHTTPProxy(httpHost, LLPROXY_SOCKS); } else { - LLSocks::getInstance()->disableHTTPProxy(); + LLProxy::getInstance()->disableHTTPProxy(); } bool use_socks_proxy = gSavedSettings.getBOOL("Socks5ProxyEnabled"); if (use_socks_proxy) { - // Determine and update LLSocks with the saved authentication system + // Determine and update LLProxy with the saved authentication system std::string auth_type = gSavedSettings.getString("Socks5AuthType"); - - if (auth_type.compare("None") == 0) - { - LLSocks::getInstance()->setAuthNone(); - } if (auth_type.compare("UserPass") == 0) { - LLSocks::getInstance()->setAuthPassword(gSavedSettings.getString("Socks5Username"),gSavedSettings.getString("Socks5Password")); + LLPointer socks_cred = gSecAPIHandler->loadCredential("SOCKS5"); + std::string socks_user = socks_cred->getIdentifier()["username"].asString(); + std::string socks_password = socks_cred->getAuthenticator()["creds"].asString(); + LLProxy::getInstance()->setAuthPassword(socks_user, socks_password); + } + else if (auth_type.compare("None") == 0) + { + LLProxy::getInstance()->setAuthNone(); + } + else + { + // Unknown or missing setting. + gSavedSettings.setString("Socks5AuthType", "None"); + + // Clear the SOCKS credentials. + LLPointer socks_cred = new LLCredential("SOCKS5"); + gSecAPIHandler->deleteCredential(socks_cred); + + LLProxy::getInstance()->setAuthNone(); } // Start the proxy and check for errors - int status = LLSocks::getInstance()->startProxy(gSavedSettings.getString("Socks5ProxyHost"), gSavedSettings.getU32("Socks5ProxyPort")); + // 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; LLSD payload; subs["HOST"] = gSavedSettings.getString("Socks5ProxyHost"); subs["PORT"] = (S32)gSavedSettings.getU32("Socks5ProxyPort"); + std::string error_string; + switch(status) { case SOCKS_OK: @@ -2815,35 +2830,36 @@ bool LLStartUp::handleSocksProxy(bool reportOK) break; case SOCKS_CONNECT_ERROR: // TCP Fail - LLNotifications::instance().add("SOCKS_CONNECT_ERROR", subs,payload); + error_string = "SOCKS_CONNECT_ERROR"; break; - case SOCKS_NOT_PERMITTED: // Socks5 server rule set refused connection - LLNotifications::instance().add("SOCKS_NOT_PERMITTED", subs,payload); + 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 - LLNotifications::instance().add("SOCKS_NOT_ACCEPTABLE", subs,payload); + error_string = "SOCKS_NOT_ACCEPTABLE"; break; case SOCKS_AUTH_FAIL: // Authentication failed - LLNotifications::instance().add("SOCKS_AUTH_FAIL", subs,payload); + error_string = "SOCKS_AUTH_FAIL"; break; case SOCKS_UDP_FWD_NOT_GRANTED: // UDP forward request failed - LLNotifications::instance().add("SOCKS_UDP_FWD_NOT_GRANTED", subs,payload); + error_string = "SOCKS_UDP_FWD_NOT_GRANTED"; break; case SOCKS_HOST_CONNECT_FAILED: // Failed to open a TCP channel to the socks server - LLNotifications::instance().add("SOCKS_HOST_CONNECT_FAILED", subs,payload); - break; + error_string = "SOCKS_HOST_CONNECT_FAILED"; + break; } + LLNotificationsUtil::add(error_string, subs); return false; } else { - LLSocks::getInstance()->stopProxy(); // ensure no UDP proxy is running and it's all cleaned up + LLProxy::getInstance()->stopProxy(); // ensure no UDP proxy is running and it's all cleaned up } return true; -- cgit v1.2.3 From 975975029d7f248cdf917da670ffd6c6b98d40c1 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Tue, 5 Jul 2011 16:55:43 -0400 Subject: STORM-1112 Fixed crash on quit. Other minor fixes: * Reordered HTTP proxy choices in settings dialog * Now using setBlocking and setNonBlocking LLSocket methods during TCP handshakes. * Made those LLSocket methods available outside the class. --- indra/newview/llstartup.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 7f14e403b0..8b333f265c 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2766,17 +2766,17 @@ bool LLStartUp::handleSocksProxy() // Determine the HTTP proxy type (if any) if ((httpProxyType.compare("Web") == 0) && gSavedSettings.getBOOL("BrowserProxyEnabled")) { - LLHost httpHost; - httpHost.setHostByName(gSavedSettings.getString("BrowserProxyAddress")); - httpHost.setPort(gSavedSettings.getS32("BrowserProxyPort")); - LLProxy::getInstance()->enableHTTPProxy(httpHost, LLPROXY_HTTP); + LLHost http_host; + http_host.setHostByName(gSavedSettings.getString("BrowserProxyAddress")); + http_host.setPort(gSavedSettings.getS32("BrowserProxyPort")); + LLProxy::getInstance()->enableHTTPProxy(http_host, LLPROXY_HTTP); } else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) { - LLHost httpHost; - httpHost.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); - httpHost.setPort(gSavedSettings.getU32("Socks5ProxyPort")); - LLProxy::getInstance()->enableHTTPProxy(httpHost, LLPROXY_SOCKS); + LLHost socks_host; + socks_host.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); + socks_host.setPort(gSavedSettings.getU32("Socks5ProxyPort")); + LLProxy::getInstance()->enableHTTPProxy(socks_host, LLPROXY_SOCKS); } else { -- cgit v1.2.3 From cb24dff9e36a963af280be1aead9424be8a678b6 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Wed, 13 Jul 2011 16:46:36 -0400 Subject: Code cleanup for the SOCKS 5 proxy viewer. --- indra/newview/llstartup.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 3661155e88..1fe241a8ce 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2827,7 +2827,6 @@ bool LLStartUp::handleSocksProxy() // 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; - LLSD payload; subs["HOST"] = gSavedSettings.getString("Socks5ProxyHost"); subs["PORT"] = (S32)gSavedSettings.getU32("Socks5ProxyPort"); -- cgit v1.2.3 From f15d28a636da7b6d2784d9301e7a030b5bd38a8c Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Thu, 28 Jul 2011 13:47:20 -0400 Subject: Proxy cleanup in llstartup.cpp and llproxy.cpp. --- indra/newview/llstartup.cpp | 79 +++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 35 deletions(-) (limited to 'indra/newview/llstartup.cpp') 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 { -- cgit v1.2.3 From d2c72cb7e92896cb414e357ef262d91b0498a6b7 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Fri, 29 Jul 2011 15:38:20 -0400 Subject: STORM-1112 Input sanitization of proxy options. --- indra/newview/llstartup.cpp | 54 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index eca3e5439e..c934ff9f1b 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -825,7 +825,7 @@ bool idle_startup() if (!LLStartUp::handleSocksProxy()) { // Proxy start up failed, we should now bail the state machine - // HandleSocksProxy() will have reported an error to the user + // handleSocksProxy() will have reported an error to the user // already, so we just go back to the login screen. The user // could then change the preferences to fix the issue. LLStartUp::setStartupState(STATE_LOGIN_SHOW); @@ -834,11 +834,11 @@ bool idle_startup() } else { - LLProxy::getInstance()->stopProxy(); + LLProxy::getInstance()->stopSOCKSProxy(); } - //reset the values that could have come in from a slurl + // reset the values that could have come in from a slurl // DEV-42215: Make sure they're not empty -- gUserCredential // might already have been set from gSavedSettings, and it's too bad // to overwrite valid values with empty strings. @@ -2779,20 +2779,40 @@ bool LLStartUp::handleSocksProxy() LLHost http_host; http_host.setHostByName(gSavedSettings.getString("BrowserProxyAddress")); http_host.setPort(gSavedSettings.getS32("BrowserProxyPort")); - LLProxy::getInstance()->enableHTTPProxy(http_host, LLPROXY_HTTP); + if (!LLProxy::getInstance()->enableHTTPProxy(http_host, LLPROXY_HTTP)) + { + LLSD subs; + subs["HOST"] = http_host.getIPString(); + subs["PORT"] = (S32)http_host.getPort(); + LLNotificationsUtil::add("PROXY_INVALID_HTTP_HOST", subs); + } } else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) { LLHost socks_host; socks_host.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); socks_host.setPort(gSavedSettings.getU32("Socks5ProxyPort")); - LLProxy::getInstance()->enableHTTPProxy(socks_host, LLPROXY_SOCKS); + if (!LLProxy::getInstance()->enableHTTPProxy(socks_host, LLPROXY_SOCKS)) + { + LLSD subs; + subs["HOST"] = socks_host.getIPString(); + subs["PORT"] = (S32)socks_host.getPort(); + LLNotificationsUtil::add("PROXY_INVALID_SOCKS_HOST", subs); + } + + + } + else if (httpProxyType.compare("None") == 0) + { + LLProxy::getInstance()->disableHTTPProxy(); } else { + LL_WARNS("Proxy") << "Invalid HTTP proxy configuration."<< LL_ENDL; + gSavedSettings.setString("Socks5HttpProxyType", "None"); LLProxy::getInstance()->disableHTTPProxy(); } - + // Set up SOCKS proxy (if needed) if (gSavedSettings.getBOOL("Socks5ProxyEnabled")) { @@ -2805,7 +2825,14 @@ bool LLStartUp::handleSocksProxy() LLPointer socks_cred = gSecAPIHandler->loadCredential("SOCKS5"); std::string socks_user = socks_cred->getIdentifier()["username"].asString(); std::string socks_password = socks_cred->getAuthenticator()["creds"].asString(); - LLProxy::getInstance()->setAuthPassword(socks_user, socks_password); + + bool ok; + ok = LLProxy::getInstance()->setAuthPassword(socks_user, socks_password); + if (!ok) + { + LLNotificationsUtil::add("SOCKS_BAD_CREDS"); + } + } else if (auth_type.compare("None") == 0) { @@ -2824,8 +2851,11 @@ 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")); + // If status != SOCKS_OK, stopSOCKSProxy() will already have been called when startSOCKSProxy() returns. + LLHost socks_host; + socks_host.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); + socks_host.setPort(gSavedSettings.getU32("Socks5ProxyPort")); + int status = LLProxy::getInstance()->startSOCKSProxy(socks_host); if (status == SOCKS_OK) { @@ -2865,6 +2895,10 @@ bool LLStartUp::handleSocksProxy() error_string = "SOCKS_HOST_CONNECT_FAILED"; break; + case SOCKS_INVALID_HOST: // Improperly formatted host address or port. + error_string = "SOCKS_INVALID_HOST"; + break; + default: error_string = "SOCKS_UNKNOWN_STATUS"; // Something strange happened, LL_WARNS("Proxy") << "Unknown return from LLProxy::startProxy(): " << status << LL_ENDL; @@ -2877,7 +2911,7 @@ bool LLStartUp::handleSocksProxy() } else { - LLProxy::getInstance()->stopProxy(); // ensure no UDP proxy is running and it's all cleaned up + LLProxy::getInstance()->stopSOCKSProxy(); // ensure no UDP proxy is running and it's all cleaned up } return true; -- cgit v1.2.3 From 97bedac2a1274f26a6a346afccea7596f1d13923 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Tue, 2 Aug 2011 11:08:07 -0400 Subject: Proxy: Improved mutex usage in LLProxy. Introduced an LLAtomic member to track the status of the http proxy that can be checked without locking a mutex. --- indra/newview/llstartup.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index c934ff9f1b..3ec5842e3c 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2785,6 +2785,7 @@ bool LLStartUp::handleSocksProxy() subs["HOST"] = http_host.getIPString(); subs["PORT"] = (S32)http_host.getPort(); LLNotificationsUtil::add("PROXY_INVALID_HTTP_HOST", subs); + return false; } } else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) @@ -2798,9 +2799,8 @@ bool LLStartUp::handleSocksProxy() subs["HOST"] = socks_host.getIPString(); subs["PORT"] = (S32)socks_host.getPort(); LLNotificationsUtil::add("PROXY_INVALID_SOCKS_HOST", subs); + return false; } - - } else if (httpProxyType.compare("None") == 0) { @@ -2816,7 +2816,6 @@ bool LLStartUp::handleSocksProxy() // Set up SOCKS proxy (if needed) if (gSavedSettings.getBOOL("Socks5ProxyEnabled")) { - // Determine and update LLProxy with the saved authentication system std::string auth_type = gSavedSettings.getString("Socks5AuthType"); @@ -2826,13 +2825,13 @@ bool LLStartUp::handleSocksProxy() std::string socks_user = socks_cred->getIdentifier()["username"].asString(); std::string socks_password = socks_cred->getAuthenticator()["creds"].asString(); - bool ok; - ok = LLProxy::getInstance()->setAuthPassword(socks_user, socks_password); + bool ok = LLProxy::getInstance()->setAuthPassword(socks_user, socks_password); + if (!ok) { LLNotificationsUtil::add("SOCKS_BAD_CREDS"); + return false; } - } else if (auth_type.compare("None") == 0) { -- cgit v1.2.3 From d3b4cc34a8d388ab66ef2ca717ee0d814d87ff3d Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Tue, 2 Aug 2011 17:18:54 -0400 Subject: LLProxy cleanup. * Removed early returns in LLStartup::handleSocksProxy * Corrected some cases that would result in handleSocksProxy not being called again during login if settings changed * Allowed for short replies in tcp_handshake in LLProxy.cpp * Renamed LLProxy::isEnabled() to LLProxy::isSocksProxyEnabled() to clarify its use. --- indra/newview/llstartup.cpp | 141 ++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 72 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 3ec5842e3c..25af63c0d3 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -598,6 +598,9 @@ bool idle_startup() // connection if the user is using SOCKS 5 // We need to do this early in case the user is using // socks for HTTP so we get the login screen via SOCKS + // We don't do anything if proxy setup was + // unsuccessful, since the user can configure their + // proxy settings before starting to log in. //------------------------------------------------- LLStartUp::handleSocksProxy(); @@ -820,23 +823,16 @@ bool idle_startup() // Post login screen, we should see if any settings have changed that may // require us to either start/stop or change the socks proxy. As various communications // past this point may require the proxy to be up. - if ( gSavedSettings.getBOOL("Socks5ProxyEnabled") ) + if (!LLStartUp::handleSocksProxy()) { - if (!LLStartUp::handleSocksProxy()) - { - // Proxy start up failed, we should now bail the state machine - // handleSocksProxy() will have reported an error to the user - // already, so we just go back to the login screen. The user - // could then change the preferences to fix the issue. - LLStartUp::setStartupState(STATE_LOGIN_SHOW); - return FALSE; - } - } - else - { - LLProxy::getInstance()->stopSOCKSProxy(); + // Proxy start up failed, we should now bail the state machine + // handleSocksProxy() will have reported an error to the user + // already, so we just go back to the login screen. The user + // could then change the preferences to fix the issue. + + LLStartUp::setStartupState(STATE_LOGIN_SHOW); + return FALSE; } - // reset the values that could have come in from a slurl // DEV-42215: Make sure they're not empty -- gUserCredential @@ -2771,6 +2767,7 @@ void LLStartUp::setStartSLURL(const LLSLURL& slurl) bool LLStartUp::handleSocksProxy() { + bool proxy_ok = true; std::string httpProxyType = gSavedSettings.getString("Socks5HttpProxyType"); // Determine the HTTP proxy type (if any) @@ -2785,7 +2782,7 @@ bool LLStartUp::handleSocksProxy() subs["HOST"] = http_host.getIPString(); subs["PORT"] = (S32)http_host.getPort(); LLNotificationsUtil::add("PROXY_INVALID_HTTP_HOST", subs); - return false; + proxy_ok = false; } } else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) @@ -2799,7 +2796,7 @@ bool LLStartUp::handleSocksProxy() subs["HOST"] = socks_host.getIPString(); subs["PORT"] = (S32)socks_host.getPort(); LLNotificationsUtil::add("PROXY_INVALID_SOCKS_HOST", subs); - return false; + proxy_ok = false; } } else if (httpProxyType.compare("None") == 0) @@ -2814,7 +2811,7 @@ bool LLStartUp::handleSocksProxy() } // Set up SOCKS proxy (if needed) - if (gSavedSettings.getBOOL("Socks5ProxyEnabled")) + if (gSavedSettings.getBOOL("Socks5ProxyEnabled") && proxy_ok) { // Determine and update LLProxy with the saved authentication system std::string auth_type = gSavedSettings.getString("Socks5AuthType"); @@ -2830,7 +2827,7 @@ bool LLStartUp::handleSocksProxy() if (!ok) { LLNotificationsUtil::add("SOCKS_BAD_CREDS"); - return false; + proxy_ok = false; } } else if (auth_type.compare("None") == 0) @@ -2849,63 +2846,63 @@ bool LLStartUp::handleSocksProxy() LLProxy::getInstance()->setAuthNone(); } - // Start the proxy and check for errors - // If status != SOCKS_OK, stopSOCKSProxy() will already have been called when startSOCKSProxy() returns. - LLHost socks_host; - socks_host.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); - socks_host.setPort(gSavedSettings.getU32("Socks5ProxyPort")); - int status = LLProxy::getInstance()->startSOCKSProxy(socks_host); - - if (status == SOCKS_OK) - { - return true; - } - else + if (proxy_ok) { - LLSD subs; - subs["HOST"] = gSavedSettings.getString("Socks5ProxyHost"); - subs["PORT"] = (S32)gSavedSettings.getU32("Socks5ProxyPort"); - std::string error_string; + // Start the proxy and check for errors + // If status != SOCKS_OK, stopSOCKSProxy() will already have been called when startSOCKSProxy() returns. + LLHost socks_host; + socks_host.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); + socks_host.setPort(gSavedSettings.getU32("Socks5ProxyPort")); + int status = LLProxy::getInstance()->startSOCKSProxy(socks_host); - switch(status) + if (status != SOCKS_OK) { - 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; - - case SOCKS_INVALID_HOST: // Improperly formatted host address or port. - error_string = "SOCKS_INVALID_HOST"; - break; - - default: - error_string = "SOCKS_UNKNOWN_STATUS"; // Something strange happened, - LL_WARNS("Proxy") << "Unknown return from LLProxy::startProxy(): " << status << LL_ENDL; - break; - } + LLSD subs; + subs["HOST"] = gSavedSettings.getString("Socks5ProxyHost"); + subs["PORT"] = (S32)gSavedSettings.getU32("Socks5ProxyPort"); + + std::string error_string; + + 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; - LLNotificationsUtil::add(error_string, subs); - return false; + case SOCKS_HOST_CONNECT_FAILED: // Failed to open a TCP channel to the socks server + error_string = "SOCKS_HOST_CONNECT_FAILED"; + break; + + case SOCKS_INVALID_HOST: // Improperly formatted host address or port. + error_string = "SOCKS_INVALID_HOST"; + break; + + default: + error_string = "SOCKS_UNKNOWN_STATUS"; // Something strange happened, + LL_WARNS("Proxy") << "Unknown return from LLProxy::startProxy(): " << status << LL_ENDL; + break; + } + + LLNotificationsUtil::add(error_string, subs); + proxy_ok = false; + } } } else @@ -2913,7 +2910,7 @@ bool LLStartUp::handleSocksProxy() LLProxy::getInstance()->stopSOCKSProxy(); // ensure no UDP proxy is running and it's all cleaned up } - return true; + return proxy_ok; } bool login_alert_done(const LLSD& notification, const LLSD& response) -- cgit v1.2.3 From 37f88470850cf572f30b0d1dae2f46a8e3b43977 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Thu, 4 Aug 2011 11:17:03 -0400 Subject: LLProxy: Added another attempt to download gpu and feature tables after successfully setting up a proxy. Other minor changes: Clarified why we are using SOCKS5 as the "grid" argument to store proxy credentials. Added class wide logging to the LLProxy class. --- indra/newview/llstartup.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 25af63c0d3..c5c143963b 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -592,10 +592,10 @@ bool idle_startup() } LL_INFOS("AppInit") << "Message System Initialized." << LL_ENDL; - + //------------------------------------------------- // Init the SOCKS 5 proxy and open the control TCP - // connection if the user is using SOCKS 5 + // connection if the user has configured a Proxy // We need to do this early in case the user is using // socks for HTTP so we get the login screen via SOCKS // We don't do anything if proxy setup was @@ -604,6 +604,11 @@ bool idle_startup() //------------------------------------------------- LLStartUp::handleSocksProxy(); + // If we started a proxy, try to grab the table files again. + if (LLProxy::getInstance()->isHTTPProxyEnabled()) + { + LLFeatureManager::getInstance()->fetchHTTPTables(); + } //------------------------------------------------- // Init audio, which may be needed for prefs dialog -- cgit v1.2.3 From 5915da89f06106d0e811c6655144df93d35144f8 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Mon, 8 Aug 2011 15:53:06 -0400 Subject: LLProxy cleanup. Made the socks proxy start first in llstartup.cpp Moved initialization of the proxy to before the HTTP table fetch Added Doxygen comments to LLProxy methods. Removed call to applyProxySettings in llxmlrpctransaction.cpp since the ctor of LLCurlEasyRequest will apply the proxy settings. --- indra/newview/llstartup.cpp | 129 +++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 61 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index c5c143963b..c34f84e2d9 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -387,6 +387,14 @@ bool idle_startup() LLNotificationsUtil::add(gViewerWindow->getInitAlert()); } + //------------------------------------------------- + // Init the SOCKS 5 proxy if the user has configured + // one. We need to do this early in case the user + // is using SOCKS for HTTP so we get the login + // screen and HTTP tables via SOCKS. + //------------------------------------------------- + LLStartUp::startLLProxy(); + gSavedSettings.setS32("LastFeatureVersion", LLFeatureManager::getInstance()->getVersion()); gSavedSettings.setS32("LastGPUClass", LLFeatureManager::getInstance()->getGPUClass()); @@ -593,23 +601,6 @@ bool idle_startup() LL_INFOS("AppInit") << "Message System Initialized." << LL_ENDL; - //------------------------------------------------- - // Init the SOCKS 5 proxy and open the control TCP - // connection if the user has configured a Proxy - // We need to do this early in case the user is using - // socks for HTTP so we get the login screen via SOCKS - // We don't do anything if proxy setup was - // unsuccessful, since the user can configure their - // proxy settings before starting to log in. - //------------------------------------------------- - - LLStartUp::handleSocksProxy(); - // If we started a proxy, try to grab the table files again. - if (LLProxy::getInstance()->isHTTPProxyEnabled()) - { - LLFeatureManager::getInstance()->fetchHTTPTables(); - } - //------------------------------------------------- // Init audio, which may be needed for prefs dialog // or audio cues in connection UI. @@ -828,10 +819,10 @@ bool idle_startup() // Post login screen, we should see if any settings have changed that may // require us to either start/stop or change the socks proxy. As various communications // past this point may require the proxy to be up. - if (!LLStartUp::handleSocksProxy()) + if (!LLStartUp::startLLProxy()) { // Proxy start up failed, we should now bail the state machine - // handleSocksProxy() will have reported an error to the user + // startLLProxy() will have reported an error to the user // already, so we just go back to the login screen. The user // could then change the preferences to fix the issue. @@ -2770,53 +2761,22 @@ void LLStartUp::setStartSLURL(const LLSLURL& slurl) } } -bool LLStartUp::handleSocksProxy() +/** + * Read all proxy configuration settings and set up both the HTTP proxy and + * SOCKS proxy as needed. + * + * Any errors that are encountered will result in showing the user a notification. + * When an error is encountered, + * + * @return Returns true if setup was successful, false if an error was encountered. + */ +bool LLStartUp::startLLProxy() { bool proxy_ok = true; std::string httpProxyType = gSavedSettings.getString("Socks5HttpProxyType"); - // Determine the HTTP proxy type (if any) - if ((httpProxyType.compare("Web") == 0) && gSavedSettings.getBOOL("BrowserProxyEnabled")) - { - LLHost http_host; - http_host.setHostByName(gSavedSettings.getString("BrowserProxyAddress")); - http_host.setPort(gSavedSettings.getS32("BrowserProxyPort")); - if (!LLProxy::getInstance()->enableHTTPProxy(http_host, LLPROXY_HTTP)) - { - LLSD subs; - subs["HOST"] = http_host.getIPString(); - subs["PORT"] = (S32)http_host.getPort(); - LLNotificationsUtil::add("PROXY_INVALID_HTTP_HOST", subs); - proxy_ok = false; - } - } - else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) - { - LLHost socks_host; - socks_host.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); - socks_host.setPort(gSavedSettings.getU32("Socks5ProxyPort")); - if (!LLProxy::getInstance()->enableHTTPProxy(socks_host, LLPROXY_SOCKS)) - { - LLSD subs; - subs["HOST"] = socks_host.getIPString(); - subs["PORT"] = (S32)socks_host.getPort(); - LLNotificationsUtil::add("PROXY_INVALID_SOCKS_HOST", subs); - proxy_ok = false; - } - } - else if (httpProxyType.compare("None") == 0) - { - LLProxy::getInstance()->disableHTTPProxy(); - } - else - { - LL_WARNS("Proxy") << "Invalid HTTP proxy configuration."<< LL_ENDL; - gSavedSettings.setString("Socks5HttpProxyType", "None"); - LLProxy::getInstance()->disableHTTPProxy(); - } - // Set up SOCKS proxy (if needed) - if (gSavedSettings.getBOOL("Socks5ProxyEnabled") && proxy_ok) + if (gSavedSettings.getBOOL("Socks5ProxyEnabled")) { // Determine and update LLProxy with the saved authentication system std::string auth_type = gSavedSettings.getString("Socks5AuthType"); @@ -2915,6 +2875,53 @@ bool LLStartUp::handleSocksProxy() LLProxy::getInstance()->stopSOCKSProxy(); // ensure no UDP proxy is running and it's all cleaned up } + if (proxy_ok) + { + // Determine the HTTP proxy type (if any) + if ((httpProxyType.compare("Web") == 0) && gSavedSettings.getBOOL("BrowserProxyEnabled")) + { + LLHost http_host; + http_host.setHostByName(gSavedSettings.getString("BrowserProxyAddress")); + http_host.setPort(gSavedSettings.getS32("BrowserProxyPort")); + if (!LLProxy::getInstance()->enableHTTPProxy(http_host, LLPROXY_HTTP)) + { + LLSD subs; + subs["HOST"] = http_host.getIPString(); + subs["PORT"] = (S32)http_host.getPort(); + LLNotificationsUtil::add("PROXY_INVALID_HTTP_HOST", subs); + proxy_ok = false; + } + } + else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) + { + LLHost socks_host; + socks_host.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); + socks_host.setPort(gSavedSettings.getU32("Socks5ProxyPort")); + if (!LLProxy::getInstance()->enableHTTPProxy(socks_host, LLPROXY_SOCKS)) + { + LLSD subs; + subs["HOST"] = socks_host.getIPString(); + subs["PORT"] = (S32)socks_host.getPort(); + LLNotificationsUtil::add("PROXY_INVALID_SOCKS_HOST", subs); + proxy_ok = false; + } + } + else if (httpProxyType.compare("None") == 0) + { + LLProxy::getInstance()->disableHTTPProxy(); + } + else + { + LL_WARNS("Proxy") << "Invalid HTTP proxy configuration."<< LL_ENDL; + + // Set the missing or wrong configuration back to something valid. + gSavedSettings.setString("Socks5HttpProxyType", "None"); + LLProxy::getInstance()->disableHTTPProxy(); + + // Leave proxy_ok alone, since this isn't necessarily fatal. + } + } + return proxy_ok; } -- cgit v1.2.3 From f9cf9179122d06782f0c968ba84adc1e44dd1e21 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 11 Aug 2011 18:16:21 -0600 Subject: fix for SH-2194: viewer UI is visible on the login progress screen --- indra/newview/llstartup.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index e4bf668275..9855326093 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2557,22 +2557,32 @@ void init_start_screen(S32 location_id) else if(!start_image_bmp->load(temp_str) ) { LL_WARNS("AppInit") << "Bitmap load failed" << LL_ENDL; - return; + gStartTexture = NULL; } + else + { + gStartImageWidth = start_image_bmp->getWidth(); + gStartImageHeight = start_image_bmp->getHeight(); - gStartImageWidth = start_image_bmp->getWidth(); - gStartImageHeight = start_image_bmp->getHeight(); + LLPointer raw = new LLImageRaw; + if (!start_image_bmp->decode(raw, 0.0f)) + { + LL_WARNS("AppInit") << "Bitmap decode failed" << LL_ENDL; + gStartTexture = NULL; + } + else + { + raw->expandToPowerOfTwo(); + gStartTexture = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE) ; + } + } - LLPointer raw = new LLImageRaw; - if (!start_image_bmp->decode(raw, 0.0f)) + if(gStartTexture.isNull()) { - LL_WARNS("AppInit") << "Bitmap decode failed" << LL_ENDL; - gStartTexture = NULL; - return; + gStartTexture = LLViewerTexture::sBlackImagep ; + gStartImageWidth = gStartTexture->getWidth() ; + gStartImageHeight = gStartTexture->getHeight() ; } - - raw->expandToPowerOfTwo(); - gStartTexture = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE) ; } -- cgit v1.2.3 From d79eedcfc3bbd0c72505bcf9bec98532a6fd5feb Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Thu, 18 Aug 2011 16:07:33 -0400 Subject: LLProxy: Renamed a setting to better describe what it controls. --- indra/newview/llstartup.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 3fa51c51f5..e053c4b07a 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2794,7 +2794,7 @@ void LLStartUp::setStartSLURL(const LLSLURL& slurl) bool LLStartUp::startLLProxy() { bool proxy_ok = true; - std::string httpProxyType = gSavedSettings.getString("Socks5HttpProxyType"); + std::string httpProxyType = gSavedSettings.getString("HttpProxyType"); // Set up SOCKS proxy (if needed) if (gSavedSettings.getBOOL("Socks5ProxyEnabled")) @@ -2822,6 +2822,8 @@ bool LLStartUp::startLLProxy() } else { + LL_WARNS("Proxy") << "Invalid SOCKS 5 authentication type."<< LL_ENDL; + // Unknown or missing setting. gSavedSettings.setString("Socks5AuthType", "None"); @@ -2834,7 +2836,6 @@ bool LLStartUp::startLLProxy() if (proxy_ok) { - // Start the proxy and check for errors // If status != SOCKS_OK, stopSOCKSProxy() will already have been called when startSOCKSProxy() returns. LLHost socks_host; @@ -2933,10 +2934,10 @@ bool LLStartUp::startLLProxy() } else { - LL_WARNS("Proxy") << "Invalid HTTP proxy configuration."<< LL_ENDL; + LL_WARNS("Proxy") << "Invalid other HTTP proxy configuration."<< LL_ENDL; // Set the missing or wrong configuration back to something valid. - gSavedSettings.setString("Socks5HttpProxyType", "None"); + gSavedSettings.setString("HttpProxyType", "None"); LLProxy::getInstance()->disableHTTPProxy(); // Leave proxy_ok alone, since this isn't necessarily fatal. -- cgit v1.2.3