summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llmessage/llpacketring.cpp23
-rw-r--r--indra/llmessage/llsocks5.cpp295
-rw-r--r--indra/llmessage/llsocks5.h184
-rw-r--r--indra/llmessage/net.cpp61
-rw-r--r--indra/llmessage/net.h4
-rwxr-xr-xindra/newview/llfloaterpreference.cpp225
-rw-r--r--indra/newview/llstartup.cpp8
-rw-r--r--indra/newview/llxmlrpctransaction.cpp8
-rw-r--r--indra/newview/skins/default/xui/en/floater_preferences_proxy.xml2
9 files changed, 409 insertions, 401 deletions
diff --git a/indra/llmessage/llpacketring.cpp b/indra/llmessage/llpacketring.cpp
index 0c8c5f763c..62aaca0672 100644
--- a/indra/llmessage/llpacketring.cpp
+++ b/indra/llmessage/llpacketring.cpp
@@ -28,22 +28,26 @@
#include "llpacketring.h"
+#if LL_WINDOWS
+ #include <winsock2.h>
+#else
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+#endif
+
// linden library includes
#include "llerror.h"
+#include "message.h"
+#include "llsocks5.h"
#include "lltimer.h"
#include "timing.h"
#include "llrand.h"
#include "u64.h"
-#include "llsocks5.h"
-#include "message.h"
-#if LL_WINDOWS
- #include <winsock2.h>
-#else
- #include <sys/socket.h>
- #include <netinet/in.h>
-#endif
+
+
+
///////////////////////////////////////////////////////////
@@ -241,8 +245,7 @@ S32 LLPacketRing::receivePacket (S32 socket, char *datap)
packet_size=0;
}
- proxywrap_t * header;
- header = (proxywrap_t *)buffer;
+ proxywrap_t * header = (proxywrap_t *)buffer;
mLastSender.setAddress(header->addr);
mLastSender.setPort(ntohs(header->port));
}
diff --git a/indra/llmessage/llsocks5.cpp b/indra/llmessage/llsocks5.cpp
index 8a63287f22..7eac27d4bb 100644
--- a/indra/llmessage/llsocks5.cpp
+++ b/indra/llmessage/llsocks5.cpp
@@ -35,184 +35,185 @@
// Static class variable instances
// We want this to be static to avoid excessive indirection on every
-// incomming packet just to do a simple bool test. The getter for this
+// incoming packet just to do a simple bool test. The getter for this
// member is also static
bool LLSocks::sUdpProxyEnabled;
bool LLSocks::sHttpProxyEnabled;
LLSocks::LLSocks()
{
- sUdpProxyEnabled = false;
- sHttpProxyEnabled = false;
- hProxyControlChannel = 0;
- mProxyType = LLPROXY_SOCKS;
+ sUdpProxyEnabled = false;
+ sHttpProxyEnabled = false;
+ mProxyControlChannel = 0;
+ mProxyType = LLPROXY_SOCKS;
}
-// Perform a Socks5 authentication and UDP assioacation to the proxy
-// specified by proxy, and assiocate UDP port message_port
+// Perform a Socks5 authentication and UDP association to the proxy
+// specified by proxy, and associate UDP port message_port
int LLSocks::proxyHandshake(LLHost proxy, U32 message_port)
{
- int result;
-
- /* Socks 5 Auth request */
- socks_auth_request_t socks_auth_request;
- socks_auth_response_t socks_auth_response;
-
- socks_auth_request.version = SOCKS_VERSION; // Socks version 5
- socks_auth_request.num_methods = 1; // Sending 1 method
- socks_auth_request.methods = mAuthMethodSelected; // send only the selected metho
-
- result = tcp_handshake(hProxyControlChannel, (char*)&socks_auth_request, sizeof(socks_auth_request_t), (char*)&socks_auth_response, sizeof(socks_auth_response_t));
- if (result != 0)
- {
- llwarns << "Socks authentication request failed, error on TCP control channel : " << result << llendl;
- stopProxy();
- return SOCKS_CONNECT_ERROR;
- }
-
- if (socks_auth_response.method == AUTH_NOT_ACCEPTABLE)
- {
- llwarns << "Socks5 server refused all our authentication methods" << llendl;
- stopProxy();
- return SOCKS_NOT_ACCEPTABLE;
- }
-
- // SOCKS5 USERNAME/PASSWORD authentication
- if (socks_auth_response.method == METHOD_PASSWORD)
- {
- // The server has requested a username/password combination
- U32 request_size = mSocksUsername.size() + mSocksPassword.size() + 3;
- char * password_auth = (char *)malloc(request_size);
- password_auth[0] = 0x01;
- password_auth[1] = mSocksUsername.size();
- memcpy(&password_auth[2],mSocksUsername.c_str(), mSocksUsername.size());
- password_auth[mSocksUsername.size()+2] = mSocksPassword.size();
- memcpy(&password_auth[mSocksUsername.size()+3], mSocksPassword.c_str(), mSocksPassword.size());
-
- authmethod_password_reply_t password_reply;
-
- result = tcp_handshake(hProxyControlChannel, password_auth, request_size, (char*)&password_reply, sizeof(authmethod_password_reply_t));
- free (password_auth);
-
- if (result != 0)
- {
- llwarns << "Socks authentication failed, error on TCP control channel : " << result << llendl;
- stopProxy();
- return SOCKS_CONNECT_ERROR;
- }
-
- if (password_reply.status != AUTH_SUCCESS)
- {
- llwarns << "Socks authentication failed" << llendl;
- stopProxy();
- return SOCKS_AUTH_FAIL;
- }
- }
-
- /* SOCKS5 connect request */
-
- socks_command_request_t connect_request;
- socks_command_response_t connect_reply;
-
- connect_request.version = SOCKS_VERSION; //Socks V5
- connect_request.command = COMMAND_UDP_ASSOCIATE; // Associate UDP
- connect_request.flag = FIELD_RESERVED;
- connect_request.atype = ADDRESS_IPV4;
- connect_request.address = 0; // 0.0.0.0 We are not fussy about address
- // UDP is promiscious receive for our protocol
- connect_request.port = 0; // Port must be 0 if you ever want to connect via NAT and your router does port rewrite for you
-
- result = tcp_handshake(hProxyControlChannel, (char*)&connect_request, sizeof(socks_command_request_t), (char*)&connect_reply, sizeof(socks_command_response_t));
- if (result != 0)
- {
- llwarns << "Socks connect request failed, error on TCP control channel : " << result << llendl;
- stopProxy();
- return SOCKS_CONNECT_ERROR;
- }
-
- if (connect_reply.reply != REPLY_REQUEST_GRANTED)
- {
- //Something went wrong
- llwarns << "Connection to SOCKS5 server failed, UDP forward request not granted" << llendl;
- stopProxy();
- return SOCKS_UDP_FWD_NOT_GRANTED;
- }
-
- mUDPProxy.setPort(ntohs(connect_reply.port)); // reply port is in network byte order
- mUDPProxy.setAddress(proxy.getAddress());
- // All good now we have been given the UDP port to send requests that need forwarding.
- llinfos << "Socks 5 UDP proxy connected on " << mUDPProxy << llendl;
- return SOCKS_OK;
+ int result;
+
+ /* Socks 5 Auth request */
+ socks_auth_request_t socks_auth_request;
+ socks_auth_response_t socks_auth_response;
+
+ socks_auth_request.version = SOCKS_VERSION; // Socks version 5
+ socks_auth_request.num_methods = 1; // Sending 1 method
+ socks_auth_request.methods = mAuthMethodSelected; // send only the selected method
+
+ result = tcp_handshake(mProxyControlChannel, (char*)&socks_auth_request, sizeof(socks_auth_request_t), (char*)&socks_auth_response, sizeof(socks_auth_response_t));
+ if (result != 0)
+ {
+ llwarns << "Socks authentication request failed, error on TCP control channel : " << result << llendl;
+ stopProxy();
+ return SOCKS_CONNECT_ERROR;
+ }
+
+ if (socks_auth_response.method == AUTH_NOT_ACCEPTABLE)
+ {
+ llwarns << "Socks5 server refused all our authentication methods" << llendl;
+ stopProxy();
+ return SOCKS_NOT_ACCEPTABLE;
+ }
+
+ // SOCKS5 USERNAME/PASSWORD authentication
+ if (socks_auth_response.method == METHOD_PASSWORD)
+ {
+ // The server has requested a username/password combination
+ U32 request_size = mSocksUsername.size() + mSocksPassword.size() + 3;
+ // char * password_auth = (char *)malloc(request_size);
+ char * password_auth = new char[request_size];
+ password_auth[0] = 0x01;
+ password_auth[1] = mSocksUsername.size();
+ memcpy(&password_auth[2], mSocksUsername.c_str(), mSocksUsername.size());
+ password_auth[mSocksUsername.size()+2] = mSocksPassword.size();
+ memcpy(&password_auth[mSocksUsername.size()+3], mSocksPassword.c_str(), mSocksPassword.size());
+
+ authmethod_password_reply_t password_reply;
+
+ result = tcp_handshake(mProxyControlChannel, password_auth, request_size, (char*)&password_reply, sizeof(authmethod_password_reply_t));
+ delete[] password_auth;
+
+ if (result != 0)
+ {
+ llwarns << "Socks authentication failed, error on TCP control channel : " << result << llendl;
+ stopProxy();
+ return SOCKS_CONNECT_ERROR;
+ }
+
+ if (password_reply.status != AUTH_SUCCESS)
+ {
+ llwarns << "Socks authentication failed" << llendl;
+ stopProxy();
+ return SOCKS_AUTH_FAIL;
+ }
+ }
+
+ /* SOCKS5 connect request */
+
+ socks_command_request_t connect_request;
+ socks_command_response_t connect_reply;
+
+ connect_request.version = SOCKS_VERSION; //Socks V5
+ connect_request.command = COMMAND_UDP_ASSOCIATE; // Associate UDP
+ connect_request.flag = FIELD_RESERVED;
+ connect_request.atype = ADDRESS_IPV4;
+ connect_request.address = 0; // 0.0.0.0 We are not fussy about address
+ // UDP is promiscuous receive for our protocol
+ connect_request.port = 0; // Port must be 0 if you ever want to connect via NAT and your router does port rewrite for you
+
+ result = tcp_handshake(mProxyControlChannel, (char*)&connect_request, sizeof(socks_command_request_t), (char*)&connect_reply, sizeof(socks_command_response_t));
+ if (result != 0)
+ {
+ llwarns << "Socks connect request failed, error on TCP control channel : " << result << llendl;
+ stopProxy();
+ return SOCKS_CONNECT_ERROR;
+ }
+
+ if (connect_reply.reply != REPLY_REQUEST_GRANTED)
+ {
+ //Something went wrong
+ llwarns << "Connection to SOCKS5 server failed, UDP forward request not granted" << llendl;
+ stopProxy();
+ return SOCKS_UDP_FWD_NOT_GRANTED;
+ }
+
+ mUDPProxy.setPort(ntohs(connect_reply.port)); // reply port is in network byte order
+ mUDPProxy.setAddress(proxy.getAddress());
+ // All good now we have been given the UDP port to send requests that need forwarding.
+ llinfos << "Socks 5 UDP proxy connected on " << mUDPProxy << llendl;
+ return SOCKS_OK;
}
int LLSocks::startProxy(LLHost proxy, U32 message_port)
{
- int status;
-
- mTCPProxy = proxy;
-
- if (hProxyControlChannel)
- {
- tcp_close_channel(hProxyControlChannel);
- hProxyControlChannel=0;
- }
-
- hProxyControlChannel = tcp_open_channel(proxy);
- if (hProxyControlChannel == -1)
- {
- return SOCKS_HOST_CONNECT_FAILED;
- }
-
- status = proxyHandshake(proxy, message_port);
- if (status == SOCKS_OK)
- {
- sUdpProxyEnabled=true;
- }
- return status;
+ int status;
+
+ mTCPProxy = proxy;
+
+ if (mProxyControlChannel)
+ {
+ tcp_close_channel(mProxyControlChannel);
+ mProxyControlChannel = 0;
+ }
+
+ mProxyControlChannel = tcp_open_channel(proxy);
+ if (mProxyControlChannel == -1)
+ {
+ return SOCKS_HOST_CONNECT_FAILED;
+ }
+
+ status = proxyHandshake(proxy, message_port);
+ if (status == SOCKS_OK)
+ {
+ sUdpProxyEnabled = true;
+ }
+ return status;
}
int LLSocks::startProxy(std::string host, U32 port)
{
- mTCPProxy.setHostByName(host);
- mTCPProxy.setPort(port);
- return startProxy(mTCPProxy, (U32)gMessageSystem->mPort);
+ mTCPProxy.setHostByName(host);
+ mTCPProxy.setPort(port);
+ return startProxy(mTCPProxy, (U32)gMessageSystem->mPort);
}
void LLSocks::stopProxy()
{
- sUdpProxyEnabled = false;
-
- // If the Socks proxy is requested to stop and we are using that for http as well
- // then we must shut down any http proxy operations. But it is allowable if web
- // proxy is being used to continue proxying http.
-
- if(LLPROXY_SOCKS == mProxyType)
- {
- sHttpProxyEnabled = false;
- }
-
- if (hProxyControlChannel)
- {
- tcp_close_channel(hProxyControlChannel);
- hProxyControlChannel=0;
- }
+ sUdpProxyEnabled = false;
+
+ // If the Socks proxy is requested to stop and we are using that for http as well
+ // then we must shut down any http proxy operations. But it is allowable if web
+ // proxy is being used to continue proxying http.
+
+ if(LLPROXY_SOCKS == mProxyType)
+ {
+ sHttpProxyEnabled = false;
+ }
+
+ if (mProxyControlChannel)
+ {
+ tcp_close_channel(mProxyControlChannel);
+ mProxyControlChannel = 0;
+ }
}
void LLSocks::setAuthNone()
{
- mAuthMethodSelected = METHOD_NOAUTH;
+ mAuthMethodSelected = METHOD_NOAUTH;
}
void LLSocks::setAuthPassword(std::string username, std::string password)
{
- mAuthMethodSelected = METHOD_PASSWORD;
- mSocksUsername = username;
- mSocksPassword = password;
+ mAuthMethodSelected = METHOD_PASSWORD;
+ mSocksUsername = username;
+ mSocksPassword = password;
}
-void LLSocks::EnableHttpProxy(LLHost httpHost, LLHttpProxyType type)
+void LLSocks::enableHttpProxy(LLHost httpHost, LLHttpProxyType type)
{
- sHttpProxyEnabled = true;
- mHTTPProxy = httpHost;
- mProxyType = type;
+ sHttpProxyEnabled = true;
+ mHTTPProxy = httpHost;
+ mProxyType = type;
}
diff --git a/indra/llmessage/llsocks5.h b/indra/llmessage/llsocks5.h
index a78acb8b23..171a933d32 100644
--- a/indra/llmessage/llsocks5.h
+++ b/indra/llmessage/llsocks5.h
@@ -35,12 +35,12 @@
// Error codes returned from the StartProxy method
#define SOCKS_OK 0
-#define SOCKS_CONNECT_ERROR -1
-#define SOCKS_NOT_PERMITTED -2
-#define SOCKS_NOT_ACCEPTABLE -3
-#define SOCKS_AUTH_FAIL -4
-#define SOCKS_UDP_FWD_NOT_GRANTED -5
-#define SOCKS_HOST_CONNECT_FAILED -6
+#define SOCKS_CONNECT_ERROR (-1)
+#define SOCKS_NOT_PERMITTED (-2)
+#define SOCKS_NOT_ACCEPTABLE (-3)
+#define SOCKS_AUTH_FAIL (-4)
+#define SOCKS_UDP_FWD_NOT_GRANTED (-5)
+#define SOCKS_HOST_CONNECT_FAILED (-6)
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN (255 + 1) /* socks5: 255, +1 for len. */
@@ -56,8 +56,8 @@
// Lets just use our own ipv4 struct rather than dragging in system
// specific headers
union ipv4_address_t {
- unsigned char octects[4];
- U32 addr32;
+ unsigned char octets[4];
+ U32 addr32;
};
// Socks 5 control channel commands
@@ -86,53 +86,53 @@ union ipv4_address_t {
// Socks5 command packet
struct socks_command_request_t {
- unsigned char version;
- unsigned char command;
- unsigned char flag;
- unsigned char atype;
- U32 address;
- U16 port;
+ unsigned char version;
+ unsigned char command;
+ unsigned char flag;
+ unsigned char atype;
+ U32 address;
+ U16 port;
};
// Standard socks5 reply packet
struct socks_command_response_t {
- unsigned char version;
- unsigned char reply;
- unsigned char flag;
- unsigned char atype;
- unsigned char add_bytes[4];
- U16 port;
+ unsigned char version;
+ unsigned char reply;
+ unsigned char flag;
+ unsigned char atype;
+ unsigned char add_bytes[4];
+ U16 port;
};
-#define AUTH_NOT_ACCEPTABLE 0xFF // reply if prefered methods are not avaiable
-#define AUTH_SUCCESS 0x00 // reply if authentication successfull
+#define AUTH_NOT_ACCEPTABLE 0xFF // reply if preferred methods are not available
+#define AUTH_SUCCESS 0x00 // reply if authentication successful
// socks 5 authentication request, stating which methods the client supports
struct socks_auth_request_t {
- unsigned char version;
- unsigned char num_methods;
- unsigned char methods; // We are only using a single method currently
+ unsigned char version;
+ unsigned char num_methods;
+ unsigned char methods; // We are only using a single method currently
};
// socks 5 authentication response packet, stating server prefered method
struct socks_auth_response_t {
- unsigned char version;
- unsigned char method;
+ unsigned char version;
+ unsigned char method;
};
// socks 5 password reply packet
struct authmethod_password_reply_t {
- unsigned char version;
- unsigned char status;
+ unsigned char version;
+ unsigned char status;
};
// socks 5 UDP packet header
struct proxywrap_t {
- U16 rsv;
- U8 frag;
- U8 atype;
- U32 addr;
- U16 port;
+ U16 rsv;
+ U8 frag;
+ U8 atype;
+ U32 addr;
+ U16 port;
};
#pragma pack(pop) /* restore original alignment from stack */
@@ -141,97 +141,97 @@ struct proxywrap_t {
// Currently selected http proxy type
enum LLHttpProxyType
{
- LLPROXY_SOCKS = 0,
- LLPROXY_HTTP = 1
+ LLPROXY_SOCKS = 0,
+ LLPROXY_HTTP = 1
};
// Auth types
enum LLSocks5AuthType
{
- METHOD_NOAUTH = 0x00, // Client supports no auth
- METHOD_GSSAPI = 0x01, // Client supports GSSAPI (Not currently supported)
- METHOD_PASSWORD = 0x02 // Client supports username/password
+ METHOD_NOAUTH = 0x00, // Client supports no auth
+ METHOD_GSSAPI = 0x01, // Client supports GSSAPI (Not currently supported)
+ METHOD_PASSWORD = 0x02 // Client supports username/password
};
class LLSocks: public LLSingleton<LLSocks>
{
public:
- LLSocks();
+ LLSocks();
- // Start a connection to the socks 5 proxy
- int startProxy(std::string host,U32 port);
- int startProxy(LLHost proxy,U32 messagePort);
+ // Start a connection to the socks 5 proxy
+ int startProxy(std::string host,U32 port);
+ int startProxy(LLHost proxy,U32 messagePort);
- // Disconnect and clean up any connection to the socks 5 proxy
- void stopProxy();
+ // Disconnect and clean up any connection to the socks 5 proxy
+ void stopProxy();
- // Set up to use Password auth when connecting to the socks proxy
- void setAuthPassword(std::string username,std::string password);
+ // Set up to use Password auth when connecting to the socks proxy
+ void setAuthPassword(std::string username,std::string password);
- // Set up to use No Auth when connecting to the socks proxy;
- void setAuthNone();
+ // Set up to use No Auth when connecting to the socks proxy
+ void setAuthNone();
- // get the currently selected auth method
- LLSocks5AuthType getSelectedAuthMethod() { return mAuthMethodSelected; };
+ // get the currently selected auth method
+ LLSocks5AuthType getSelectedAuthMethod() const { return mAuthMethodSelected; }
- // static check for enabled status for UDP packets
- static bool isEnabled(){return sUdpProxyEnabled;};
+ // static check for enabled status for UDP packets
+ static bool isEnabled() { return sUdpProxyEnabled; }
- // static check for enabled status for http packets
- static bool isHttpProxyEnabled(){return sHttpProxyEnabled;};
+ // static check for enabled status for http packets
+ static bool isHttpProxyEnabled() { return sHttpProxyEnabled; }
- // Proxy http packets via httpHost, which can be a Socks5 or a http proxy
- // as specified in type
- void EnableHttpProxy(LLHost httpHost,LLHttpProxyType type);
+ // Proxy http packets via httpHost, which can be a Socks5 or a http proxy
+ // as specified in type
+ void enableHttpProxy(LLHost httpHost, LLHttpProxyType type);
- // Stop proxying http packets
- void DisableHttpProxy() {sHttpProxyEnabled = false;};
+ // Stop proxying http packets
+ void disableHttpProxy() { sHttpProxyEnabled = false; };
- // get the UDP proxy address and port
- LLHost getUDPProxy(){return mUDPProxy;};
+ // Get the UDP proxy address and port
+ LLHost getUDPProxy() const { return mUDPProxy; }
- // get the socks 5 TCP control channel address and port
- LLHost getTCPProxy(){return mTCPProxy;};
+ // Get the socks 5 TCP control channel address and port
+ LLHost getTCPProxy() const { return mTCPProxy; }
- //get the http proxy address and port
- LLHost getHTTPProxy(){return mHTTPProxy;};
+ // Get the http proxy address and port
+ LLHost getHTTPProxy() const { return mHTTPProxy; }
- // get the currently selected http proxy type
- LLHttpProxyType getHttpProxyType(){return mProxyType;};
+ // Get the currently selected http proxy type
+ LLHttpProxyType getHttpProxyType() const { return mProxyType; }
- //Get the username password in a curl compatible format
- std::string getProxyUserPwd(){ return (mSocksUsername + ":" + mSocksPassword);};
+ // Get the username password in a curl compatible format
+ std::string getProxyUserPwd() const { return (mSocksUsername + ":" + mSocksPassword); }
private:
- // Open a communication channel to the socks5 proxy proxy, at port messagePort
- int proxyHandshake(LLHost proxy,U32 messagePort);
+ // Open a communication channel to the socks5 proxy proxy, at port messagePort
+ int proxyHandshake(LLHost proxy,U32 messagePort);
- // socket handle to proxy tcp control channel
- S32 hProxyControlChannel;
+ // socket handle to proxy tcp control channel
+ S32 mProxyControlChannel;
- // is the UDP proxy enabled
- static bool sUdpProxyEnabled;
- // is the http proxy enabled
- static bool sHttpProxyEnabled;
+ // is the UDP proxy enabled?
+ static bool sUdpProxyEnabled;
+ // is the http proxy enabled?
+ static bool sHttpProxyEnabled;
- // currently selected http proxy type
- LLHttpProxyType mProxyType;
+ // currently selected http proxy type
+ LLHttpProxyType mProxyType;
- // UDP proxy address and port
- LLHost mUDPProxy;
- // TCP Proxy control channel address and port
- LLHost mTCPProxy;
- // HTTP proxy address and port
- LLHost mHTTPProxy;
+ // UDP proxy address and port
+ LLHost mUDPProxy;
+ // TCP Proxy control channel address and port
+ LLHost mTCPProxy;
+ // HTTP proxy address and port
+ LLHost mHTTPProxy;
- // socks 5 auth method selected
- LLSocks5AuthType mAuthMethodSelected;
+ // socks 5 auth method selected
+ LLSocks5AuthType mAuthMethodSelected;
- // socks 5 username
- std::string mSocksUsername;
- // socks 5 password
- std::string mSocksPassword;
+ // socks 5 username
+ std::string mSocksUsername;
+ // socks 5 password
+ std::string mSocksPassword;
};
#endif
diff --git a/indra/llmessage/net.cpp b/indra/llmessage/net.cpp
index ab5c1950c6..a51d80ff48 100644
--- a/indra/llmessage/net.cpp
+++ b/indra/llmessage/net.cpp
@@ -175,7 +175,7 @@ U32 ip_string_to_u32(const char* ip_string)
// use wildcard addresses. -Ambroff
U32 ip = inet_addr(ip_string);
if (ip == INADDR_NONE
- && strncmp(ip_string, BROADCAST_ADDRESS_STRING, MAXADDRSTR) != 0)
+ && strncmp(ip_string, BROADCAST_ADDRESS_STRING, MAXADDRSTR) != 0)
{
llwarns << "ip_string_to_u32() failed, Error: Invalid IP string '" << ip_string << "'" << llendl;
return INVALID_HOST_IP_ADDRESS;
@@ -220,9 +220,10 @@ S32 tcp_open_channel(LLHost host)
S32 handle;
handle = socket(AF_INET, SOCK_STREAM, 0);
- if (!handle)
+ if (INVALID_SOCKET == handle)
{
- llwarns << "Error opening TCP control socket, socket() returned " << handle << llendl;
+ llwarns << "Error opening TCP control socket, socket() returned "
+ << WSAGetLastError() << ", " << DecodeError(WSAGetLastError()) << llendl;
return -1;
}
@@ -232,15 +233,15 @@ S32 tcp_open_channel(LLHost host)
address.sin_addr.s_addr = host.getAddress();
// Non blocking
- WSAEVENT hEvent=WSACreateEvent();
+ WSAEVENT hEvent = WSACreateEvent();
WSAEventSelect(handle, hEvent, FD_CONNECT) ;
connect(handle, (struct sockaddr*)&address, sizeof(address)) ;
- // Wait fot 5 seconds, if we can't get a TCP channel open in this
+ // Wait for 5 seconds, if we can't get a TCP channel open in this
// time frame then there is something badly wrong.
- WaitForSingleObject(hEvent, 1000*5); // 5 seconds time out
+ WaitForSingleObject(hEvent, 1000 * 5); // 5 seconds time out
WSANETWORKEVENTS netevents;
- WSAEnumNetworkEvents(handle,hEvent,&netevents);
+ WSAEnumNetworkEvents(handle, hEvent, &netevents);
// Check the async event status to see if we connected
if ((netevents.lNetworkEvents & FD_CONNECT) == FD_CONNECT)
@@ -249,6 +250,7 @@ S32 tcp_open_channel(LLHost host)
{
llwarns << "Unable to open TCP channel, WSA returned an error code of " << netevents.iErrorCode[FD_CONNECT_BIT] << llendl;
WSACloseEvent(hEvent);
+ tcp_close_channel(handle);
return -1;
}
@@ -264,6 +266,7 @@ S32 tcp_open_channel(LLHost host)
}
llwarns << "Unable to open TCP channel, Timeout is the host up?" << netevents.iErrorCode[FD_CONNECT_BIT] << llendl;
+ tcp_close_channel(handle);
return -1;
}
@@ -277,7 +280,7 @@ void tcp_close_channel(S32 handle)
S32 start_net(S32& socket_out, int& nPort)
{
// Create socket, make non-blocking
- // Init WinSock
+ // Init WinSock
int nRet;
int hSocket;
@@ -286,7 +289,7 @@ S32 start_net(S32& socket_out, int& nPort)
int buff_size = 4;
// Initialize windows specific stuff
- if(WSAStartup(0x0202, &stWSAData))
+ if (WSAStartup(0x0202, &stWSAData))
{
S32 err = WSAGetLastError();
WSACleanup();
@@ -295,8 +298,8 @@ S32 start_net(S32& socket_out, int& nPort)
}
// Get a datagram socket
- hSocket = (int)socket(AF_INET, SOCK_DGRAM, 0);
- if (hSocket == INVALID_SOCKET)
+ hSocket = (int)socket(AF_INET, SOCK_DGRAM, 0);
+ if (hSocket == INVALID_SOCKET)
{
S32 err = WSAGetLastError();
WSACleanup();
@@ -389,7 +392,7 @@ S32 start_net(S32& socket_out, int& nPort)
// Setup a destination address
stDstAddr.sin_family = AF_INET;
stDstAddr.sin_addr.s_addr = INVALID_HOST_IP_ADDRESS;
- stDstAddr.sin_port = htons(nPort);
+ stDstAddr.sin_port = htons(nPort);
socket_out = hSocket;
return 0;
@@ -492,9 +495,9 @@ S32 tcp_open_channel(LLHost host)
{
S32 handle;
handle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (!handle)
+ if (-1 == handle)
{
- llwarns << "Error opening TCP control socket, socket() returned " << handle << llendl;
+ llwarns << "Error opening TCP control socket, socket() returned " << handle << "error code: " << errno << llendl;
return -1;
}
@@ -511,6 +514,7 @@ S32 tcp_open_channel(LLHost host)
if (error && (errno != EINPROGRESS))
{
llwarns << "Unable to open TCP channel, error code: " << errno << llendl;
+ tcp_close_channel(handle);
return -1;
}
@@ -521,12 +525,13 @@ S32 tcp_open_channel(LLHost host)
FD_ZERO(&fds);
FD_SET(handle, &fds);
- // See if we have connectde or time out after 5 seconds
- U32 rc = select(sizeof(fds)*8, NULL, &fds, NULL, &timeout);
+ // See if we have connected or time out after 5 seconds
+ S32 rc = select(sizeof(fds)*8, NULL, &fds, NULL, &timeout);
if (rc != 1) // we require exactly one descriptor to be set
{
llwarns << "Unable to open TCP channel" << llendl;
+ tcp_close_channel(handle);
return -1;
}
@@ -549,10 +554,10 @@ S32 start_net(S32& socket_out, int& nPort)
int rec_size = RECEIVE_BUFFER_SIZE;
socklen_t buff_size = 4;
-
+
// Create socket
- hSocket = socket(AF_INET, SOCK_DGRAM, 0);
- if (hSocket < 0)
+ hSocket = socket(AF_INET, SOCK_DGRAM, 0);
+ if (hSocket < 0)
{
llwarns << "socket() failed" << llendl;
return 1;
@@ -585,7 +590,7 @@ S32 start_net(S32& socket_out, int& nPort)
}
else
{
- // Name the socket (assign the local port number to receive on)
+ // Name the socket (assign the local port number to receive on)
stLclAddr.sin_family = AF_INET;
stLclAddr.sin_addr.s_addr = htonl(INADDR_ANY);
stLclAddr.sin_port = htons(nPort);
@@ -630,7 +635,7 @@ S32 start_net(S32& socket_out, int& nPort)
nPort = attempt_port;
}
// Set socket to be non-blocking
- fcntl(hSocket, F_SETFL, O_NONBLOCK);
+ fcntl(hSocket, F_SETFL, O_NONBLOCK);
// set a large receive buffer
nRet = setsockopt(hSocket, SOL_SOCKET, SO_RCVBUF, (char *)&rec_size, buff_size);
if (nRet)
@@ -666,8 +671,8 @@ S32 start_net(S32& socket_out, int& nPort)
// Setup a destination address
char achMCAddr[MAXADDRSTR] = "127.0.0.1"; /* Flawfinder: ignore */
stDstAddr.sin_family = AF_INET;
- stDstAddr.sin_addr.s_addr = ip_string_to_u32(achMCAddr);
- stDstAddr.sin_port = htons(nPort);
+ stDstAddr.sin_addr.s_addr = ip_string_to_u32(achMCAddr);
+ stDstAddr.sin_port = htons(nPort);
socket_out = hSocket;
return 0;
@@ -693,7 +698,7 @@ static int recvfrom_destip( int socket, void *buf, int len, struct sockaddr *fro
iov[0].iov_base = buf;
iov[0].iov_len = len;
- memset( &msg, 0, sizeof msg );
+ memset(&msg, 0, sizeof msg);
msg.msg_name = from;
msg.msg_namelen = *fromlen;
msg.msg_iov = iov;
@@ -701,14 +706,14 @@ static int recvfrom_destip( int socket, void *buf, int len, struct sockaddr *fro
msg.msg_control = &cmsg;
msg.msg_controllen = sizeof(cmsg);
- size = recvmsg( socket, &msg, 0 );
+ size = recvmsg(socket, &msg, 0);
- if( size == -1 )
+ if (size == -1)
{
return -1;
}
- for( cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; cmsgptr = CMSG_NXTHDR( &msg, cmsgptr ) )
+ for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; cmsgptr = CMSG_NXTHDR( &msg, cmsgptr))
{
if( cmsgptr->cmsg_level == SOL_IP && cmsgptr->cmsg_type == IP_PKTINFO )
{
@@ -806,7 +811,7 @@ BOOL send_packet(int hSocket, const char * sendBuffer, int size, U32 recipient,
}
}
}
- while ( resend && send_attempts < 3);
+ while (resend && send_attempts < 3);
if (send_attempts >= 3)
{
diff --git a/indra/llmessage/net.h b/indra/llmessage/net.h
index d93ed20c98..047e8ce646 100644
--- a/indra/llmessage/net.h
+++ b/indra/llmessage/net.h
@@ -46,10 +46,10 @@ S32 receive_packet(int hSocket, char * receiveBuffer);
BOOL send_packet(int hSocket, const char *sendBuffer, int size, U32 recipient, int nPort); // Returns TRUE on success.
//void get_sender(char * tmp);
-LLHost get_sender();
+LLHost get_sender();
U32 get_sender_port();
U32 get_sender_ip(void);
-LLHost get_receiving_interface();
+LLHost get_receiving_interface();
U32 get_receiving_interface_ip(void);
// Some helpful tcp functions added for the socks 5 proxy support
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index b49026de38..dfc3fe1fc7 100755
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -343,7 +343,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key)
mCommitCallbackRegistrar.add("Pref.getUIColor", boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2));
mCommitCallbackRegistrar.add("Pref.MaturitySettings", boost::bind(&LLFloaterPreference::onChangeMaturity, this));
mCommitCallbackRegistrar.add("Pref.BlockList", boost::bind(&LLFloaterPreference::onClickBlockList, this));
- mCommitCallbackRegistrar.add("Pref.Proxy", boost::bind(&LLFloaterPreference::onClickProxySettings, this));
+ mCommitCallbackRegistrar.add("Pref.Proxy", boost::bind(&LLFloaterPreference::onClickProxySettings, this));
sSkin = gSavedSettings.getString("SkinCurrent");
@@ -1545,7 +1545,7 @@ void LLFloaterPreference::updateDoubleClickSettings()
void LLFloaterPreference::onClickProxySettings()
{
- LLFloaterReg::showInstance("prefs_proxy");
+ LLFloaterReg::showInstance("prefs_proxy");
}
void LLFloaterPreference::updateDoubleClickControls()
@@ -1916,16 +1916,13 @@ void LLPanelPreferenceGraphics::setHardwareDefaults()
LLPanelPreference::setHardwareDefaults();
}
-
-/* ------------------------------------------------------------ */
-
LLFloaterPreferenceProxy::LLFloaterPreferenceProxy(const LLSD& key)
- : LLFloater(key),
- mSocksSettingsDirty(false)
+ : LLFloater(key),
+ mSocksSettingsDirty(false)
{
- mCommitCallbackRegistrar.add("Proxy.OK", boost::bind(&LLFloaterPreferenceProxy::onBtnOk, this));
- mCommitCallbackRegistrar.add("Proxy.Cancel", boost::bind(&LLFloaterPreferenceProxy::onBtnCancel, this));
- mCommitCallbackRegistrar.add("Proxy.Change", boost::bind(&LLFloaterPreferenceProxy::onChangeSocksSettings, this));
+ mCommitCallbackRegistrar.add("Proxy.OK", boost::bind(&LLFloaterPreferenceProxy::onBtnOk, this));
+ mCommitCallbackRegistrar.add("Proxy.Cancel", boost::bind(&LLFloaterPreferenceProxy::onBtnCancel, this));
+ mCommitCallbackRegistrar.add("Proxy.Change", boost::bind(&LLFloaterPreferenceProxy::onChangeSocksSettings, this));
}
LLFloaterPreferenceProxy::~LLFloaterPreferenceProxy()
@@ -1934,142 +1931,142 @@ LLFloaterPreferenceProxy::~LLFloaterPreferenceProxy()
BOOL LLFloaterPreferenceProxy::postBuild()
{
- LLLineEditor* edit = getChild<LLLineEditor>("socks_password_editor");
- if (edit) edit->setDrawAsterixes(TRUE);
+ LLLineEditor* edit = getChild<LLLineEditor>("socks_password_editor");
+ if (edit) edit->setDrawAsterixes(TRUE);
- LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
- if(socksAuth->getSelectedValue().asString() == "None")
- {
- getChild<LLLineEditor>("socks5_username")->setEnabled(false);
- getChild<LLLineEditor>("socks5_password")->setEnabled(false);
- }
+ LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
+ if(socksAuth->getSelectedValue().asString() == "None")
+ {
+ getChild<LLLineEditor>("socks5_username")->setEnabled(false);
+ getChild<LLLineEditor>("socks5_password")->setEnabled(false);
+ }
- center();
- return TRUE;
+ center();
+ return TRUE;
}
void LLFloaterPreferenceProxy::onOpen(const LLSD& key)
{
- saveSettings();
+ saveSettings();
}
void LLFloaterPreferenceProxy::onClose(bool app_quitting)
{
- if(mSocksSettingsDirty)
- {
+ if(mSocksSettingsDirty)
+ {
- // If the user plays with the Socks proxy settings after login, its only fair we let them know
- // it will not be updated untill next restart.
- if(LLStartUp::getStartupState()>STATE_LOGIN_WAIT)
- {
- if(this->mSocksSettingsDirty == true )
- {
- LLNotifications::instance().add("ChangeSocks5Settings",LLSD(),LLSD());
- mSocksSettingsDirty = false; // we have notified the user now be quiet again
- }
- }
- }
+ // If the user plays with the Socks proxy settings after login, it's only fair we let them know
+ // it will not be updated until next restart.
+ if(LLStartUp::getStartupState()>STATE_LOGIN_WAIT)
+ {
+ if(this->mSocksSettingsDirty == true )
+ {
+ LLNotifications::instance().add("ChangeSocks5Settings",LLSD(),LLSD());
+ mSocksSettingsDirty = false; // we have notified the user now be quiet again
+ }
+ }
+ }
}
void LLFloaterPreferenceProxy::saveSettings()
{
- // Save the value of all controls in the hierarchy
- mSavedValues.clear();
- std::list<LLView*> view_stack;
- view_stack.push_back(this);
- while(!view_stack.empty())
- {
- // Process view on top of the stack
- LLView* curview = view_stack.front();
- view_stack.pop_front();
-
- LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
- if (ctrl)
- {
- LLControlVariable* control = ctrl->getControlVariable();
- if (control)
- {
- mSavedValues[control] = control->getValue();
- }
- }
-
- // Push children onto the end of the work stack
- for (child_list_t::const_iterator iter = curview->getChildList()->begin();
- iter != curview->getChildList()->end(); ++iter)
- {
- view_stack.push_back(*iter);
- }
- }
+ // Save the value of all controls in the hierarchy
+ mSavedValues.clear();
+ std::list<LLView*> view_stack;
+ view_stack.push_back(this);
+ while(!view_stack.empty())
+ {
+ // Process view on top of the stack
+ LLView* curview = view_stack.front();
+ view_stack.pop_front();
+
+ LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+ if (ctrl)
+ {
+ LLControlVariable* control = ctrl->getControlVariable();
+ if (control)
+ {
+ mSavedValues[control] = control->getValue();
+ }
+ }
+
+ // Push children onto the end of the work stack
+ for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+ iter != curview->getChildList()->end(); ++iter)
+ {
+ view_stack.push_back(*iter);
+ }
+ }
}
void LLFloaterPreferenceProxy::onBtnOk()
{
- // commit any outstanding text entry
- if (hasFocus())
- {
- LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
- if (cur_focus && cur_focus->acceptsTextInput())
- {
- cur_focus->onCommit();
- }
- }
- closeFloater(false);
+ // commit any outstanding text entry
+ if (hasFocus())
+ {
+ LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
+ if (cur_focus && cur_focus->acceptsTextInput())
+ {
+ cur_focus->onCommit();
+ }
+ }
+ closeFloater(false);
}
void LLFloaterPreferenceProxy::onBtnCancel()
{
- if (hasFocus())
- {
- LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
- if (cur_focus && cur_focus->acceptsTextInput())
- {
- cur_focus->onCommit();
- }
- refresh();
- }
-
- cancel();
-
+ if (hasFocus())
+ {
+ LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
+ if (cur_focus && cur_focus->acceptsTextInput())
+ {
+ cur_focus->onCommit();
+ }
+ refresh();
+ }
+
+ cancel();
+
}
void LLFloaterPreferenceProxy::cancel()
{
- for (control_values_map_t::iterator iter = mSavedValues.begin();
- iter != mSavedValues.end(); ++iter)
- {
- LLControlVariable* control = iter->first;
- LLSD ctrl_value = iter->second;
- control->set(ctrl_value);
- }
-
- closeFloater();
+ for (control_values_map_t::iterator iter = mSavedValues.begin();
+ iter != mSavedValues.end(); ++iter)
+ {
+ LLControlVariable* control = iter->first;
+ LLSD ctrl_value = iter->second;
+ control->set(ctrl_value);
+ }
+
+ closeFloater();
}
void LLFloaterPreferenceProxy::onChangeSocksSettings()
{
- mSocksSettingsDirty = true;
+ mSocksSettingsDirty = true;
- LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
- if(socksAuth->getSelectedValue().asString() == "None")
- {
- getChild<LLLineEditor>("socks5_username")->setEnabled(false);
- getChild<LLLineEditor>("socks5_password")->setEnabled(false);
- }
- else
- {
- getChild<LLLineEditor>("socks5_username")->setEnabled(true);
- getChild<LLLineEditor>("socks5_password")->setEnabled(true);
- }
+ LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
+ if(socksAuth->getSelectedValue().asString() == "None")
+ {
+ getChild<LLLineEditor>("socks5_username")->setEnabled(false);
+ getChild<LLLineEditor>("socks5_password")->setEnabled(false);
+ }
+ else
+ {
+ getChild<LLLineEditor>("socks5_username")->setEnabled(true);
+ getChild<LLLineEditor>("socks5_password")->setEnabled(true);
+ }
- //Check for invalid states for the other http proxy radio
- LLRadioGroup* otherHttpProxy = getChild<LLRadioGroup>("other_http_proxy_selection");
- if( (otherHttpProxy->getSelectedValue().asString() == "Socks" &&
- getChild<LLCheckBoxCtrl>("socks_proxy_enabled")->get() == FALSE )||(
- otherHttpProxy->getSelectedValue().asString() == "Web" &&
- getChild<LLCheckBoxCtrl>("web_proxy_enabled")->get() == FALSE ) )
- {
- otherHttpProxy->selectFirstItem();
- }
+ //Check for invalid states for the other http proxy radio
+ LLRadioGroup* otherHttpProxy = getChild<LLRadioGroup>("other_http_proxy_selection");
+ if( (otherHttpProxy->getSelectedValue().asString() == "Socks" &&
+ getChild<LLCheckBoxCtrl>("socks_proxy_enabled")->get() == FALSE )||(
+ otherHttpProxy->getSelectedValue().asString() == "Web" &&
+ getChild<LLCheckBoxCtrl>("web_proxy_enabled")->get() == FALSE ) )
+ {
+ otherHttpProxy->selectFirstItem();
+ }
-}; \ No newline at end of file
+};
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;
diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp
index b3d899c61a..87d2f780be 100644
--- a/indra/newview/llxmlrpctransaction.cpp
+++ b/indra/newview/llxmlrpctransaction.cpp
@@ -319,15 +319,17 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip)
{
mCurlRequest->setopt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
if(LLSocks::getInstance()->getSelectedAuthMethod()==METHOD_PASSWORD)
+ {
mCurlRequest->setoptString(CURLOPT_PROXYUSERPWD,LLSocks::getInstance()->getProxyUserPwd());
+ }
}
else
{
- mCurlRequest->setopt(CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- }
+ mCurlRequest->setopt(CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+ }
}
-// mCurlRequest->setopt(CURLOPT_VERBOSE, 1); // usefull for debugging
+// mCurlRequest->setopt(CURLOPT_VERBOSE, 1); // useful for debugging
mCurlRequest->setopt(CURLOPT_NOSIGNAL, 1);
mCurlRequest->setWriteCallback(&curlDownloadCallback, (void*)this);
BOOL vefifySSLCert = !gSavedSettings.getBOOL("NoVerifySSLCert");
diff --git a/indra/newview/skins/default/xui/en/floater_preferences_proxy.xml b/indra/newview/skins/default/xui/en/floater_preferences_proxy.xml
index bb9ade067b..9baa9a0e02 100644
--- a/indra/newview/skins/default/xui/en/floater_preferences_proxy.xml
+++ b/indra/newview/skins/default/xui/en/floater_preferences_proxy.xml
@@ -60,7 +60,7 @@
layout="topleft"
value="None"
width="120"
- tool_tip="Non web Http trafic should NOT be sent to any proxy."/>
+ tool_tip="Non web Http traffic should NOT be sent to any proxy."/>
<radio_item
height="16"
label="Use Socks 5 Proxy"