STORM-1112 Fixed network buffers that need to have space for the SOCKS proxy header.
parent
b750a5afb7
commit
cfce3686de
|
|
@ -533,7 +533,7 @@ void LLCurl::Easy::prepRequest(const std::string& url,
|
|||
|
||||
if (post) setoptString(CURLOPT_ENCODING, "");
|
||||
|
||||
//setopt(CURLOPT_VERBOSE, 1); // usefull for debugging
|
||||
//setopt(CURLOPT_VERBOSE, 1); // useful for debugging
|
||||
setopt(CURLOPT_NOSIGNAL, 1);
|
||||
|
||||
// Set the CURL options for either Socks or HTTP proxy
|
||||
|
|
@ -546,7 +546,7 @@ void LLCurl::Easy::prepRequest(const std::string& url,
|
|||
if (LLProxy::getInstance()->getHTTPProxyType() == LLPROXY_SOCKS)
|
||||
{
|
||||
setopt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
||||
if(LLProxy::getInstance()->getSelectedAuthMethod()==METHOD_PASSWORD)
|
||||
if(LLProxy::getInstance()->getSelectedAuthMethod() == METHOD_PASSWORD)
|
||||
{
|
||||
setoptString(CURLOPT_PROXYUSERPWD, LLProxy::getInstance()->getProxyUserPwdCURL());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,13 +227,13 @@ S32 LLPacketRing::receivePacket (S32 socket, char *datap)
|
|||
// no delay, pull straight from net
|
||||
if (LLProxy::isEnabled())
|
||||
{
|
||||
U8 buffer[NET_BUFFER_SIZE];
|
||||
U8 buffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE];
|
||||
packet_size = receive_packet(socket, reinterpret_cast<char *>(buffer));
|
||||
|
||||
if (packet_size > 10)
|
||||
if (packet_size > SOCKS_HEADER_SIZE)
|
||||
{
|
||||
// *FIX We are assuming ATYP is 0x01 (IPv4), not 0x03 (hostname) or 0x04 (IPv6)
|
||||
memcpy(datap, buffer + 10, packet_size - 10);
|
||||
memcpy(datap, buffer + SOCKS_HEADER_SIZE, packet_size - SOCKS_HEADER_SIZE);
|
||||
proxywrap_t * header = reinterpret_cast<proxywrap_t *>(buffer);
|
||||
mLastSender.setAddress(header->addr);
|
||||
mLastSender.setPort(ntohs(header->port));
|
||||
|
|
@ -274,7 +274,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
|
|||
BOOL status = TRUE;
|
||||
if (!mUseOutThrottle)
|
||||
{
|
||||
return doSendPacket(h_socket, send_buffer, buf_size, host );
|
||||
return sendPacketImpl(h_socket, send_buffer, buf_size, host );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -295,7 +295,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
|
|||
mOutBufferLength -= packetp->getSize();
|
||||
packet_size = packetp->getSize();
|
||||
|
||||
status = doSendPacket(h_socket, packetp->getData(), packet_size, packetp->getHost());
|
||||
status = sendPacketImpl(h_socket, packetp->getData(), packet_size, packetp->getHost());
|
||||
|
||||
delete packetp;
|
||||
// Update the throttle
|
||||
|
|
@ -304,7 +304,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
|
|||
else
|
||||
{
|
||||
// If the queue's empty, we can just send this packet right away.
|
||||
status = doSendPacket(h_socket, send_buffer, buf_size, host );
|
||||
status = sendPacketImpl(h_socket, send_buffer, buf_size, host );
|
||||
packet_size = buf_size;
|
||||
|
||||
// Update the throttle
|
||||
|
|
@ -343,7 +343,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
|
|||
return status;
|
||||
}
|
||||
|
||||
BOOL LLPacketRing::doSendPacket(int h_socket, const char * send_buffer, S32 buf_size, LLHost host)
|
||||
BOOL LLPacketRing::sendPacketImpl(int h_socket, const char * send_buffer, S32 buf_size, LLHost host)
|
||||
{
|
||||
|
||||
if (!LLProxy::isEnabled())
|
||||
|
|
@ -351,14 +351,14 @@ BOOL LLPacketRing::doSendPacket(int h_socket, const char * send_buffer, S32 buf_
|
|||
return send_packet(h_socket, send_buffer, buf_size, host.getAddress(), host.getPort());
|
||||
}
|
||||
|
||||
proxywrap_t *socks_header = (proxywrap_t *)&mProxyWrappedSendBuffer;
|
||||
proxywrap_t *socks_header = reinterpret_cast<proxywrap_t *>(&mProxyWrappedSendBuffer);
|
||||
socks_header->rsv = 0;
|
||||
socks_header->addr = host.getAddress();
|
||||
socks_header->port = htons(host.getPort());
|
||||
socks_header->atype = ADDRESS_IPV4;
|
||||
socks_header->frag = 0;
|
||||
|
||||
memcpy(mProxyWrappedSendBuffer + 10, send_buffer, buf_size);
|
||||
memcpy(mProxyWrappedSendBuffer + SOCKS_HEADER_SIZE, send_buffer, buf_size);
|
||||
|
||||
return send_packet(h_socket,(const char*) mProxyWrappedSendBuffer, buf_size + 10, LLProxy::getInstance()->getUDPProxy().getAddress(), LLProxy::getInstance()->getUDPProxy().getPort());
|
||||
return send_packet(h_socket, (const char*) mProxyWrappedSendBuffer, buf_size + 10, LLProxy::getInstance()->getUDPProxy().getAddress(), LLProxy::getInstance()->getUDPProxy().getPort());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@
|
|||
|
||||
#include <queue>
|
||||
|
||||
#include "llpacketbuffer.h"
|
||||
#include "llhost.h"
|
||||
#include "net.h"
|
||||
#include "llpacketbuffer.h"
|
||||
#include "llproxy.h"
|
||||
#include "llthrottle.h"
|
||||
|
||||
#include "net.h"
|
||||
|
||||
class LLPacketRing
|
||||
{
|
||||
|
|
@ -83,8 +83,11 @@ protected:
|
|||
LLHost mLastSender;
|
||||
LLHost mLastReceivingIF;
|
||||
|
||||
BOOL doSendPacket(int h_socket, const char * send_buffer, S32 buf_size, LLHost host);
|
||||
U8 mProxyWrappedSendBuffer[NET_BUFFER_SIZE];
|
||||
|
||||
U8 mProxyWrappedSendBuffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE];
|
||||
|
||||
private:
|
||||
BOOL sendPacketImpl(int h_socket, const char * send_buffer, S32 buf_size, LLHost host);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@
|
|||
|
||||
#define SOCKS_VERSION 0x05 // we are using SOCKS 5
|
||||
|
||||
#define SOCKS_HEADER_SIZE 10
|
||||
|
||||
// SOCKS 5 address/hostname types
|
||||
#define ADDRESS_IPV4 0x01
|
||||
#define ADDRESS_HOSTNAME 0x03
|
||||
|
|
@ -139,7 +141,7 @@ struct proxywrap_t {
|
|||
#pragma pack(pop) /* restore original alignment from stack */
|
||||
|
||||
|
||||
// Currently selected http proxy type
|
||||
// Currently selected HTTP proxy type
|
||||
enum LLHttpProxyType
|
||||
{
|
||||
LLPROXY_SOCKS = 0,
|
||||
|
|
|
|||
Loading…
Reference in New Issue