diff options
author | McCabe Maxsted | 2011-04-12 17:41:10 -0700 |
---|---|---|
committer | McCabe Maxsted | 2011-04-12 17:41:10 -0700 |
commit | 809de77034c5956a95f35c90024e62b02b439164 (patch) | |
tree | 69beeac02b6c37b38c881d702ede4b7b83642a31 /linden/indra/newview/llstartup.cpp | |
parent | Partial revert of a47ebd78. This caused issues with selection and alt-camming... (diff) | |
download | meta-impy-809de77034c5956a95f35c90024e62b02b439164.zip meta-impy-809de77034c5956a95f35c90024e62b02b439164.tar.gz meta-impy-809de77034c5956a95f35c90024e62b02b439164.tar.bz2 meta-impy-809de77034c5956a95f35c90024e62b02b439164.tar.xz |
Ported SOCKS5 proxy support from Snowglobe 1.5
Diffstat (limited to 'linden/indra/newview/llstartup.cpp')
-rw-r--r-- | linden/indra/newview/llstartup.cpp | 125 |
1 files changed, 124 insertions, 1 deletions
diff --git a/linden/indra/newview/llstartup.cpp b/linden/indra/newview/llstartup.cpp index 8e11d8c..80ddfa4 100644 --- a/linden/indra/newview/llstartup.cpp +++ b/linden/indra/newview/llstartup.cpp | |||
@@ -189,6 +189,7 @@ | |||
189 | #include "llwlparammanager.h" | 189 | #include "llwlparammanager.h" |
190 | #include "llwaterparammanager.h" | 190 | #include "llwaterparammanager.h" |
191 | #include "llagentlanguage.h" | 191 | #include "llagentlanguage.h" |
192 | #include "llsocks5.h" | ||
192 | #include "viewerversion.h" | 193 | #include "viewerversion.h" |
193 | 194 | ||
194 | #include "lgghunspell_wrapper.h" | 195 | #include "lgghunspell_wrapper.h" |
@@ -635,6 +636,15 @@ bool idle_startup() | |||
635 | LL_INFOS("AppInit") << "Message System Initialized." << LL_ENDL; | 636 | LL_INFOS("AppInit") << "Message System Initialized." << LL_ENDL; |
636 | 637 | ||
637 | //------------------------------------------------- | 638 | //------------------------------------------------- |
639 | // Init the socks 5 proxy and open the control TCP | ||
640 | // connection if the user is using SOCKS5 | ||
641 | // We need to do this early incase the user is using | ||
642 | // socks for http so we get the login screen via socks | ||
643 | //------------------------------------------------- | ||
644 | |||
645 | LLStartUp::handleSocksProxy(false); | ||
646 | |||
647 | //------------------------------------------------- | ||
638 | // Init audio, which may be needed for prefs dialog | 648 | // Init audio, which may be needed for prefs dialog |
639 | // or audio cues in connection UI. | 649 | // or audio cues in connection UI. |
640 | //------------------------------------------------- | 650 | //------------------------------------------------- |
@@ -890,8 +900,31 @@ bool idle_startup() | |||
890 | 900 | ||
891 | if (STATE_LOGIN_CLEANUP == LLStartUp::getStartupState()) | 901 | if (STATE_LOGIN_CLEANUP == LLStartUp::getStartupState()) |
892 | { | 902 | { |
893 | |||
894 | LL_DEBUGS("AppInitStartupState") << "STATE_LOGIN_CLEANUP" << LL_ENDL; | 903 | LL_DEBUGS("AppInitStartupState") << "STATE_LOGIN_CLEANUP" << LL_ENDL; |
904 | |||
905 | // Post login screen, we should see if any settings have changed that may | ||
906 | // require us to either start/stop or change the socks proxy. As various communications | ||
907 | // past this point may require the proxy to be up. | ||
908 | bool socks_enable_required = gSavedSettings.getBOOL("Socks5ProxyEnabled"); | ||
909 | if ((LLSocks::getInstance()->isEnabled() != socks_enable_required) || LLSocks::getInstance()->needsUpdate()) | ||
910 | { | ||
911 | if (socks_enable_required) | ||
912 | { | ||
913 | if (!LLStartUp::handleSocksProxy(false)) | ||
914 | { | ||
915 | // Proxy start up failed, we should now bail the state machine | ||
916 | // HandleSocksProxy() will have reported an error to the user | ||
917 | // already, so we just go back to the login screen. The user | ||
918 | // could then change the perferences to fix the issue. | ||
919 | LLStartUp::setStartupState(STATE_LOGIN_SHOW); | ||
920 | return FALSE; | ||
921 | } | ||
922 | } | ||
923 | else | ||
924 | { | ||
925 | LLSocks::getInstance()->stopProxy(); | ||
926 | } | ||
927 | } | ||
895 | 928 | ||
896 | gDisconnected = TRUE; | 929 | gDisconnected = TRUE; |
897 | 930 | ||
@@ -4022,3 +4055,93 @@ void apply_udp_blacklist(const std::string& csv) | |||
4022 | 4055 | ||
4023 | } | 4056 | } |
4024 | 4057 | ||
4058 | bool LLStartUp::handleSocksProxy(bool reportOK) | ||
4059 | { | ||
4060 | std::string httpProxyType = gSavedSettings.getString("Socks5HttpProxyType"); | ||
4061 | |||
4062 | // Determine the http proxy type (if any) | ||
4063 | if ((httpProxyType.compare("Web") == 0) && gSavedSettings.getBOOL("BrowserProxyEnabled")) | ||
4064 | { | ||
4065 | LLHost httpHost; | ||
4066 | httpHost.setHostByName(gSavedSettings.getString("BrowserProxyAddress")); | ||
4067 | httpHost.setPort(gSavedSettings.getS32("BrowserProxyPort")); | ||
4068 | LLSocks::getInstance()->EnableHttpProxy(httpHost,LLPROXY_HTTP); | ||
4069 | } | ||
4070 | else if ((httpProxyType.compare("Socks") == 0) && gSavedSettings.getBOOL("Socks5ProxyEnabled")) | ||
4071 | { | ||
4072 | LLHost httpHost; | ||
4073 | httpHost.setHostByName(gSavedSettings.getString("Socks5ProxyHost")); | ||
4074 | httpHost.setPort(gSavedSettings.getU32("Socks5ProxyPort")); | ||
4075 | LLSocks::getInstance()->EnableHttpProxy(httpHost,LLPROXY_SOCKS); | ||
4076 | } | ||
4077 | else | ||
4078 | { | ||
4079 | LLSocks::getInstance()->DisableHttpProxy(); | ||
4080 | } | ||
4081 | |||
4082 | bool use_socks_proxy = gSavedSettings.getBOOL("Socks5ProxyEnabled"); | ||
4083 | if (use_socks_proxy) | ||
4084 | { | ||
4085 | |||
4086 | // Determine and update LLSocks with the saved authentication system | ||
4087 | std::string auth_type = gSavedSettings.getString("Socks5AuthType"); | ||
4088 | |||
4089 | if (auth_type.compare("None") == 0) | ||
4090 | { | ||
4091 | LLSocks::getInstance()->setAuthNone(); | ||
4092 | } | ||
4093 | |||
4094 | if (auth_type.compare("UserPass") == 0) | ||
4095 | { | ||
4096 | LLSocks::getInstance()->setAuthPassword(gSavedSettings.getString("Socks5Username"),gSavedSettings.getString("Socks5Password")); | ||
4097 | } | ||
4098 | |||
4099 | // Start the proxy and check for errors | ||
4100 | int status = LLSocks::getInstance()->startProxy(gSavedSettings.getString("Socks5ProxyHost"), gSavedSettings.getU32("Socks5ProxyPort")); | ||
4101 | LLSD subs; | ||
4102 | subs["PROXY"] = gSavedSettings.getString("Socks5ProxyHost"); | ||
4103 | |||
4104 | switch(status) | ||
4105 | { | ||
4106 | case SOCKS_OK: | ||
4107 | if (reportOK == true) | ||
4108 | { | ||
4109 | LLNotifications::instance().add("SOCKS_CONNECT_OK", subs); | ||
4110 | } | ||
4111 | return true; | ||
4112 | break; | ||
4113 | |||
4114 | case SOCKS_CONNECT_ERROR: // TCP Fail | ||
4115 | LLNotifications::instance().add("SOCKS_CONNECT_ERROR", subs); | ||
4116 | break; | ||
4117 | |||
4118 | case SOCKS_NOT_PERMITTED: // Socks5 server rule set refused connection | ||
4119 | LLNotifications::instance().add("SOCKS_NOT_PERMITTED", subs); | ||
4120 | break; | ||
4121 | |||
4122 | case SOCKS_NOT_ACCEPTABLE: // Selected authentication is not acceptable to server | ||
4123 | LLNotifications::instance().add("SOCKS_NOT_ACCEPTABLE", subs); | ||
4124 | break; | ||
4125 | |||
4126 | case SOCKS_AUTH_FAIL: // Authentication failed | ||
4127 | LLNotifications::instance().add("SOCKS_AUTH_FAIL", subs); | ||
4128 | break; | ||
4129 | |||
4130 | case SOCKS_UDP_FWD_NOT_GRANTED: // UDP forward request failed | ||
4131 | LLNotifications::instance().add("SOCKS_UDP_FWD_NOT_GRANTED", subs); | ||
4132 | break; | ||
4133 | |||
4134 | case SOCKS_HOST_CONNECT_FAILED: // Failed to open a TCP channel to the socks server | ||
4135 | LLNotifications::instance().add("SOCKS_HOST_CONNECT_FAILED", subs); | ||
4136 | break; | ||
4137 | } | ||
4138 | |||
4139 | return false; | ||
4140 | } | ||
4141 | else | ||
4142 | { | ||
4143 | LLSocks::getInstance()->stopProxy(); //ensure no UDP proxy is running and its all cleaned up | ||
4144 | } | ||
4145 | |||
4146 | return true; | ||
4147 | } | ||