summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-09-28 17:42:54 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-09-28 17:43:38 (GMT)
commitbab047c1bef2936124db1346863a902e1064af12 (patch)
treec59de84a76581bd07713eb0591121e6a4aa04e7b /Swiften/Network/SOCKS5ProxiedConnection.cpp
parent7b8860c794419b63f827c9b87fbc469a1bcd58ef (diff)
downloadswift-contrib-bab047c1bef2936124db1346863a902e1064af12.zip
swift-contrib-bab047c1bef2936124db1346863a902e1064af12.tar.bz2
Pass read data from connection via shared_ptr.
This should avoid unnecessary copying of the received data while being processed by the event loop.
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
@@ -86,15 +86,15 @@ void SOCKS5ProxiedConnection::handleConnectionConnectFinished(bool error) {
}
}
-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 {
@@ -134,7 +134,7 @@ void SOCKS5ProxiedConnection::handleDataRead(const SafeByteArray& data) {
}
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:
@@ -149,14 +149,14 @@ void SOCKS5ProxiedConnection::handleDataRead(const SafeByteArray& data) {
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;
}