summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network/SOCKS5ProxiedConnection.cpp')
-rw-r--r--Swiften/Network/SOCKS5ProxiedConnection.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/Swiften/Network/SOCKS5ProxiedConnection.cpp b/Swiften/Network/SOCKS5ProxiedConnection.cpp
index f8084ab..163e23a 100644
--- a/Swiften/Network/SOCKS5ProxiedConnection.cpp
+++ b/Swiften/Network/SOCKS5ProxiedConnection.cpp
@@ -80,27 +80,27 @@ void SOCKS5ProxiedConnection::handleConnectionConnectFinished(bool error) {
// buffer.push_back(0x02); // 0x02 == Username/Password
// rest see RFC 1928 (http://tools.ietf.org/html/rfc1928)
connection_->write(socksConnect);
}
else {
onConnectFinished(true);
}
}
-void SOCKS5ProxiedConnection::handleDataRead(const SafeByteArray& data) {
+void SOCKS5ProxiedConnection::handleDataRead(boost::shared_ptr<SafeByteArray> data) {
SafeByteArray socksConnect;
boost::asio::ip::address rawAddress = server_.getAddress().getRawAddress();
assert(rawAddress.is_v4() || rawAddress.is_v6());
if (!connected_) {
if (proxyState_ == ProxyAuthenticating) {
SWIFT_LOG(debug) << "ProxyAuthenticating response received, reply with the connect BYTEs" << std::endl;
- unsigned char choosenMethod = static_cast<unsigned char> (data[1]);
- if (data[0] == 0x05 && choosenMethod != 0xFF) {
+ unsigned char choosenMethod = static_cast<unsigned char> ((*data)[1]);
+ if ((*data)[0] == 0x05 && choosenMethod != 0xFF) {
switch(choosenMethod) { // use the correct Method
case 0x00:
try {
proxyState_ = ProxyConnecting;
socksConnect.push_back(0x05); // VER = SOCKS5 = 0x05
socksConnect.push_back(0x01); // Construct a TCP connection. (CMD)
socksConnect.push_back(0x00); // reserved.
socksConnect.push_back(rawAddress.is_v4() ? 0x01 : 0x04); // IPv4 == 0x01, Hostname == 0x02, IPv6 == 0x04. (ATYP)
size_t size = rawAddress.is_v4() ? rawAddress.to_v4().to_bytes().size() : rawAddress.to_v6().to_bytes().size();
@@ -128,41 +128,41 @@ void SOCKS5ProxiedConnection::handleDataRead(const SafeByteArray& data) {
default:
onConnectFinished(true);
break;
}
return;
}
}
else if (proxyState_ == ProxyConnecting) {
SWIFT_LOG(debug) << "Connect response received, check if successfully." << std::endl;
- SWIFT_LOG(debug) << "Errorbyte: 0x" << std::hex << static_cast<int> (data[1]) << std::dec << std::endl;
+ SWIFT_LOG(debug) << "Errorbyte: 0x" << std::hex << static_cast<int> ((*data)[1]) << std::dec << std::endl;
/*
data.at(1) can be one of the following:
0x00 succeeded
0x01 general SOCKS server failure
0x02 connection not allowed by ruleset
0x03 Network unreachable
0x04 Host unreachable
0x05 Connection refused
0x06 TTL expired
0x07 Command not supported (CMD)
0x08 Address type not supported (ATYP)
0x09 bis 0xFF unassigned
*/
- if (data[0] == 0x05 && data[1] == 0x0) {
+ if ((*data)[0] == 0x05 && (*data)[1] == 0x0) {
SWIFT_LOG(debug) << "Successfully connected the server via the proxy." << std::endl;
connected_ = true;
onConnectFinished(false);
return;
}
else {
- std::cerr << "SOCKS Proxy returned an error: " << std::hex << data[1] << std::endl;
+ std::cerr << "SOCKS Proxy returned an error: " << std::hex << (*data)[1] << std::endl;
}
return;
}
}
else {
onDataRead(data);
return;
}
disconnect();