mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 03:37:49 +02:00
support boost 1.87
This commit is contained in:
parent
3474538697
commit
ffd18baf30
28 changed files with 164 additions and 172 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
|
@ -129,7 +129,7 @@ namespace client
|
|||
|
||||
BOBI2POutboundTunnel::BOBI2POutboundTunnel (const std::string& outhost, uint16_t port,
|
||||
std::shared_ptr<ClientDestination> localDestination, bool quiet): BOBI2PTunnel (localDestination),
|
||||
m_Endpoint (boost::asio::ip::address::from_string (outhost), port), m_IsQuiet (quiet)
|
||||
m_Endpoint (boost::asio::ip::make_address (outhost), port), m_IsQuiet (quiet)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ namespace client
|
|||
if (!inhost.empty ())
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
auto addr = boost::asio::ip::address::from_string (inhost, ec);
|
||||
auto addr = boost::asio::ip::make_address (inhost, ec);
|
||||
if (!ec)
|
||||
ep.address (addr);
|
||||
else
|
||||
|
@ -425,7 +425,7 @@ namespace client
|
|||
{
|
||||
// TODO: FIXME: temporary validation, until hostname support is added
|
||||
boost::system::error_code ec;
|
||||
boost::asio::ip::address::from_string(m_InHost, ec);
|
||||
boost::asio::ip::make_address(m_InHost, ec);
|
||||
if (ec)
|
||||
{
|
||||
SendReplyError("inhost must be a valid IPv4 address.");
|
||||
|
@ -436,7 +436,7 @@ namespace client
|
|||
{
|
||||
// TODO: FIXME: temporary validation, until hostname support is added
|
||||
boost::system::error_code ec;
|
||||
boost::asio::ip::address::from_string(m_OutHost, ec);
|
||||
boost::asio::ip::make_address(m_OutHost, ec);
|
||||
if (ec)
|
||||
{
|
||||
SendReplyError("outhost must be a IPv4 address.");
|
||||
|
@ -828,7 +828,7 @@ namespace client
|
|||
|
||||
BOBCommandChannel::BOBCommandChannel (const std::string& address, uint16_t port):
|
||||
RunnableService ("BOB"),
|
||||
m_Acceptor (GetIOService (), boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(address), port))
|
||||
m_Acceptor (GetIOService (), boost::asio::ip::tcp::endpoint(boost::asio::ip::make_address(address), port))
|
||||
{
|
||||
// command -> handler
|
||||
m_CommandHandlers[BOB_COMMAND_ZAP] = &BOBCommandSession::ZapCommandHandler;
|
||||
|
|
|
@ -631,7 +631,7 @@ namespace client
|
|||
if (type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT) {
|
||||
// udp client
|
||||
// TODO: hostnames
|
||||
boost::asio::ip::udp::endpoint end (boost::asio::ip::address::from_string(address), port);
|
||||
boost::asio::ip::udp::endpoint end (boost::asio::ip::make_address(address), port);
|
||||
if (!localDestination)
|
||||
localDestination = m_SharedLocalDestination;
|
||||
|
||||
|
@ -787,7 +787,7 @@ namespace client
|
|||
{
|
||||
// udp server tunnel
|
||||
// TODO: hostnames
|
||||
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(host), port);
|
||||
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::make_address(host), port);
|
||||
if (address.empty ())
|
||||
{
|
||||
if (!endpoint.address ().is_unspecified () && endpoint.address ().is_v6 ())
|
||||
|
@ -795,7 +795,7 @@ namespace client
|
|||
else
|
||||
address = "127.0.0.1";
|
||||
}
|
||||
auto localAddress = boost::asio::ip::address::from_string(address);
|
||||
auto localAddress = boost::asio::ip::make_address(address);
|
||||
auto serverTunnel = std::make_shared<I2PUDPServerTunnel>(name, localDestination, localAddress, endpoint, inPort, gzip);
|
||||
if(!isUniqueLocal)
|
||||
{
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace proxy {
|
|||
|
||||
typedef std::function<void(boost::asio::ip::tcp::endpoint)> ProxyResolvedHandler;
|
||||
|
||||
void HandleUpstreamProxyResolved(const boost::system::error_code & ecode, boost::asio::ip::tcp::resolver::iterator itr, ProxyResolvedHandler handler);
|
||||
void HandleUpstreamProxyResolved(const boost::system::error_code & ecode, boost::asio::ip::tcp::resolver::results_type endpoints, ProxyResolvedHandler handler);
|
||||
|
||||
void SocksProxySuccess();
|
||||
void HandoverToUpstreamProxy();
|
||||
|
@ -584,20 +584,22 @@ namespace proxy {
|
|||
}
|
||||
else
|
||||
{
|
||||
boost::asio::ip::tcp::resolver::query q(m_ProxyURL.host, std::to_string(m_ProxyURL.port));
|
||||
m_proxy_resolver.async_resolve(q, std::bind(&HTTPReqHandler::HandleUpstreamProxyResolved, this, std::placeholders::_1, std::placeholders::_2, [&](boost::asio::ip::tcp::endpoint ep) {
|
||||
m_proxysock->async_connect(ep, std::bind(&HTTPReqHandler::HandleUpstreamHTTPProxyConnect, this, std::placeholders::_1));
|
||||
}));
|
||||
m_proxy_resolver.async_resolve(m_ProxyURL.host, std::to_string(m_ProxyURL.port), std::bind(&HTTPReqHandler::HandleUpstreamProxyResolved, this,
|
||||
std::placeholders::_1, std::placeholders::_2, [&](boost::asio::ip::tcp::endpoint ep)
|
||||
{
|
||||
m_proxysock->async_connect(ep, std::bind(&HTTPReqHandler::HandleUpstreamHTTPProxyConnect, this, std::placeholders::_1));
|
||||
}));
|
||||
}
|
||||
}
|
||||
else if (m_ProxyURL.schema == "socks")
|
||||
{
|
||||
/* handle upstream socks proxy */
|
||||
if (!m_ProxyURL.port) m_ProxyURL.port = 9050; // default to tor default if not specified
|
||||
boost::asio::ip::tcp::resolver::query q(m_ProxyURL.host, std::to_string(m_ProxyURL.port));
|
||||
m_proxy_resolver.async_resolve(q, std::bind(&HTTPReqHandler::HandleUpstreamProxyResolved, this, std::placeholders::_1, std::placeholders::_2, [&](boost::asio::ip::tcp::endpoint ep) {
|
||||
m_proxysock->async_connect(ep, std::bind(&HTTPReqHandler::HandleUpstreamSocksProxyConnect, this, std::placeholders::_1));
|
||||
}));
|
||||
m_proxy_resolver.async_resolve(m_ProxyURL.host, std::to_string(m_ProxyURL.port), std::bind(&HTTPReqHandler::HandleUpstreamProxyResolved, this,
|
||||
std::placeholders::_1, std::placeholders::_2, [&](boost::asio::ip::tcp::endpoint ep)
|
||||
{
|
||||
m_proxysock->async_connect(ep, std::bind(&HTTPReqHandler::HandleUpstreamSocksProxyConnect, this, std::placeholders::_1));
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -606,10 +608,10 @@ namespace proxy {
|
|||
}
|
||||
}
|
||||
|
||||
void HTTPReqHandler::HandleUpstreamProxyResolved(const boost::system::error_code & ec, boost::asio::ip::tcp::resolver::iterator it, ProxyResolvedHandler handler)
|
||||
void HTTPReqHandler::HandleUpstreamProxyResolved(const boost::system::error_code & ec, boost::asio::ip::tcp::resolver::results_type endpoints, ProxyResolvedHandler handler)
|
||||
{
|
||||
if(ec) GenericProxyError(tr("Cannot resolve upstream proxy"), ec.message());
|
||||
else handler(*it);
|
||||
else handler(*endpoints.begin ());
|
||||
}
|
||||
|
||||
void HTTPReqHandler::HandleUpstreamSocksProxyConnect(const boost::system::error_code & ec)
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace client
|
|||
|
||||
void I2CPDestination::CreateNewLeaseSet (const std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> >& tunnels)
|
||||
{
|
||||
GetService ().post (std::bind (&I2CPDestination::PostCreateNewLeaseSet, this, tunnels));
|
||||
boost::asio::post (GetService (), std::bind (&I2CPDestination::PostCreateNewLeaseSet, this, tunnels));
|
||||
}
|
||||
|
||||
void I2CPDestination::PostCreateNewLeaseSet (std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels)
|
||||
|
@ -170,7 +170,7 @@ namespace client
|
|||
{
|
||||
// send in destination's thread
|
||||
auto s = GetSharedFromThis ();
|
||||
GetService ().post (
|
||||
boost::asio::post (GetService (),
|
||||
[s, msg, remote, nonce]()
|
||||
{
|
||||
bool sent = s->SendMsg (msg, remote);
|
||||
|
@ -1079,7 +1079,7 @@ namespace client
|
|||
I2CPServer::I2CPServer (const std::string& interface, uint16_t port, bool isSingleThread):
|
||||
RunnableService ("I2CP"), m_IsSingleThread (isSingleThread),
|
||||
m_Acceptor (GetIOService (),
|
||||
boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(interface), port))
|
||||
boost::asio::ip::tcp::endpoint(boost::asio::ip::make_address(interface), port))
|
||||
{
|
||||
memset (m_MessagesHandlers, 0, sizeof (m_MessagesHandlers));
|
||||
m_MessagesHandlers[I2CP_GET_DATE_MESSAGE] = &I2CPSession::GetDateMessageHandler;
|
||||
|
|
|
@ -283,7 +283,7 @@ namespace client
|
|||
public:
|
||||
|
||||
TCPIPAcceptor (const std::string& address, uint16_t port, std::shared_ptr<ClientDestination> localDestination = nullptr) :
|
||||
ServiceAcceptor (boost::asio::ip::tcp::endpoint (boost::asio::ip::address::from_string(address), port), localDestination) {}
|
||||
ServiceAcceptor (boost::asio::ip::tcp::endpoint (boost::asio::ip::make_address(address), port), localDestination) {}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -717,7 +717,7 @@ namespace client
|
|||
{
|
||||
m_Endpoint.port (m_Port);
|
||||
boost::system::error_code ec;
|
||||
auto addr = boost::asio::ip::address::from_string (m_Address, ec);
|
||||
auto addr = boost::asio::ip::make_address (m_Address, ec);
|
||||
if (!ec)
|
||||
{
|
||||
m_Endpoint.address (addr);
|
||||
|
@ -726,7 +726,7 @@ namespace client
|
|||
else
|
||||
{
|
||||
auto resolver = std::make_shared<boost::asio::ip::tcp::resolver>(GetService ());
|
||||
resolver->async_resolve (boost::asio::ip::tcp::resolver::query (m_Address, ""),
|
||||
resolver->async_resolve (m_Address, "",
|
||||
std::bind (&I2PServerTunnel::HandleResolve, this,
|
||||
std::placeholders::_1, std::placeholders::_2, resolver));
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ namespace client
|
|||
ClearHandlers ();
|
||||
}
|
||||
|
||||
void I2PServerTunnel::HandleResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::iterator it,
|
||||
void I2PServerTunnel::HandleResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::results_type endpoints,
|
||||
std::shared_ptr<boost::asio::ip::tcp::resolver> resolver)
|
||||
{
|
||||
if (!ecode)
|
||||
|
@ -752,8 +752,7 @@ namespace client
|
|||
boost::asio::ip::tcp::endpoint ep;
|
||||
if (m_LocalAddress)
|
||||
{
|
||||
boost::asio::ip::tcp::resolver::iterator end;
|
||||
while (it != end)
|
||||
for (auto it = endpoints.begin (); it != endpoints.end ();)
|
||||
{
|
||||
ep = *it;
|
||||
if (!ep.address ().is_unspecified ())
|
||||
|
@ -780,7 +779,7 @@ namespace client
|
|||
else
|
||||
{
|
||||
found = true;
|
||||
ep = *it; // first available
|
||||
ep = *endpoints.begin (); // first available
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
|
@ -789,7 +788,7 @@ namespace client
|
|||
}
|
||||
|
||||
auto addr = ep.address ();
|
||||
LogPrint (eLogInfo, "I2PTunnel: Server tunnel ", (*it).host_name (), " has been resolved to ", addr);
|
||||
LogPrint (eLogInfo, "I2PTunnel: Server tunnel ", (*endpoints.begin ()).host_name (), " has been resolved to ", addr);
|
||||
m_Endpoint.address (addr);
|
||||
Accept ();
|
||||
}
|
||||
|
@ -806,7 +805,7 @@ namespace client
|
|||
void I2PServerTunnel::SetLocalAddress (const std::string& localAddress)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
auto addr = boost::asio::ip::address::from_string(localAddress, ec);
|
||||
auto addr = boost::asio::ip::make_address(localAddress, ec);
|
||||
if (!ec)
|
||||
m_LocalAddress.reset (new boost::asio::ip::address (addr));
|
||||
else
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
|
@ -208,7 +208,7 @@ namespace client
|
|||
|
||||
private:
|
||||
|
||||
void HandleResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::iterator it,
|
||||
void HandleResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::results_type endpoints,
|
||||
std::shared_ptr<boost::asio::ip::tcp::resolver> resolver);
|
||||
|
||||
void Accept ();
|
||||
|
|
|
@ -371,7 +371,7 @@ namespace client
|
|||
// udp forward selected
|
||||
boost::system::error_code e;
|
||||
// TODO: support hostnames in udp forward
|
||||
auto addr = boost::asio::ip::address::from_string(params[SAM_PARAM_HOST], e);
|
||||
auto addr = boost::asio::ip::make_address(params[SAM_PARAM_HOST], e);
|
||||
if (e)
|
||||
{
|
||||
// not an ip address
|
||||
|
@ -624,7 +624,7 @@ namespace client
|
|||
auto socket = session->acceptQueue.front ().first;
|
||||
session->acceptQueue.pop_front ();
|
||||
if (socket)
|
||||
m_Owner.GetService ().post (std::bind(&SAMSocket::TerminateClose, socket));
|
||||
boost::asio::post (m_Owner.GetService (), std::bind(&SAMSocket::TerminateClose, socket));
|
||||
}
|
||||
if (session->acceptQueue.size () < SAM_SESSION_MAX_ACCEPT_QUEUE_SIZE)
|
||||
{
|
||||
|
@ -1046,13 +1046,13 @@ namespace client
|
|||
else
|
||||
{
|
||||
auto s = shared_from_this ();
|
||||
m_Owner.GetService ().post ([s] { s->Terminate ("stream read error"); });
|
||||
boost::asio::post (m_Owner.GetService (), [s] { s->Terminate ("stream read error"); });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto s = shared_from_this ();
|
||||
m_Owner.GetService ().post ([s] { s->Terminate ("stream read error (op aborted)"); });
|
||||
boost::asio::post (m_Owner.GetService (), [s] { s->Terminate ("stream read error (op aborted)"); });
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1102,7 +1102,7 @@ namespace client
|
|||
auto socket = session->acceptQueue.front ().first;
|
||||
session->acceptQueue.pop_front ();
|
||||
if (socket)
|
||||
m_Owner.GetService ().post (std::bind(&SAMSocket::TerminateClose, socket));
|
||||
boost::asio::post (m_Owner.GetService (), std::bind(&SAMSocket::TerminateClose, socket));
|
||||
}
|
||||
if (!session->acceptQueue.empty ())
|
||||
{
|
||||
|
@ -1236,7 +1236,7 @@ namespace client
|
|||
|
||||
void SAMSocket::HandleStreamSend(const boost::system::error_code & ec)
|
||||
{
|
||||
m_Owner.GetService ().post (std::bind( !ec ? &SAMSocket::Receive : &SAMSocket::TerminateClose, shared_from_this()));
|
||||
boost::asio::post (m_Owner.GetService (), std::bind( !ec ? &SAMSocket::Receive : &SAMSocket::TerminateClose, shared_from_this()));
|
||||
}
|
||||
|
||||
SAMSession::SAMSession (SAMBridge & parent, const std::string & id, SAMSessionType type):
|
||||
|
@ -1310,8 +1310,8 @@ namespace client
|
|||
|
||||
SAMBridge::SAMBridge (const std::string& address, uint16_t portTCP, uint16_t portUDP, bool singleThread):
|
||||
RunnableService ("SAM"), m_IsSingleThread (singleThread),
|
||||
m_Acceptor (GetIOService (), boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(address), portTCP)),
|
||||
m_DatagramEndpoint (boost::asio::ip::address::from_string(address), (!portUDP) ? portTCP-1 : portUDP), m_DatagramSocket (GetIOService (), m_DatagramEndpoint),
|
||||
m_Acceptor (GetIOService (), boost::asio::ip::tcp::endpoint(boost::asio::ip::make_address(address), portTCP)),
|
||||
m_DatagramEndpoint (boost::asio::ip::make_address(address), (!portUDP) ? portTCP-1 : portUDP), m_DatagramSocket (GetIOService (), m_DatagramEndpoint),
|
||||
m_SignatureTypes
|
||||
{
|
||||
{"DSA_SHA1", i2p::data::SIGNING_KEY_TYPE_DSA_SHA1},
|
||||
|
|
|
@ -126,9 +126,8 @@ namespace proxy
|
|||
void HandleSockRecv(const boost::system::error_code & ecode, std::size_t bytes_transfered);
|
||||
void Terminate();
|
||||
void AsyncSockRead();
|
||||
boost::asio::const_buffers_1 GenerateSOCKS5SelectAuth(authMethods method);
|
||||
boost::asio::const_buffers_1 GenerateSOCKS4Response(errTypes error, uint32_t ip, uint16_t port);
|
||||
boost::asio::const_buffers_1 GenerateSOCKS5Response(errTypes error, addrTypes type, const address &addr, uint16_t port);
|
||||
boost::asio::const_buffer GenerateSOCKS4Response(errTypes error, uint32_t ip, uint16_t port);
|
||||
boost::asio::const_buffer GenerateSOCKS5Response(errTypes error, addrTypes type, const address &addr, uint16_t port);
|
||||
bool Socks5ChooseAuth();
|
||||
void Socks5UserPasswdResponse ();
|
||||
void SocksRequestFailed(errTypes error);
|
||||
|
@ -145,9 +144,9 @@ namespace proxy
|
|||
template<typename Socket>
|
||||
void SendUpstreamRequest(std::shared_ptr<Socket>& upstreamSock);
|
||||
void HandleUpstreamConnected(const boost::system::error_code & ecode,
|
||||
boost::asio::ip::tcp::resolver::iterator itr);
|
||||
const boost::asio::ip::tcp::endpoint& ep);
|
||||
void HandleUpstreamResolved(const boost::system::error_code & ecode,
|
||||
boost::asio::ip::tcp::resolver::iterator itr);
|
||||
boost::asio::ip::tcp::resolver::results_type endpoints);
|
||||
|
||||
boost::asio::ip::tcp::resolver m_proxy_resolver;
|
||||
uint8_t m_sock_buff[socks_buffer_size];
|
||||
|
@ -233,17 +232,17 @@ namespace proxy
|
|||
Done(shared_from_this());
|
||||
}
|
||||
|
||||
boost::asio::const_buffers_1 SOCKSHandler::GenerateSOCKS4Response(SOCKSHandler::errTypes error, uint32_t ip, uint16_t port)
|
||||
boost::asio::const_buffer SOCKSHandler::GenerateSOCKS4Response(SOCKSHandler::errTypes error, uint32_t ip, uint16_t port)
|
||||
{
|
||||
assert(error >= SOCKS4_OK);
|
||||
m_response[0] = '\x00'; // version
|
||||
m_response[1] = error; // response code
|
||||
htobe16buf(m_response + 2, port); // port
|
||||
htobe32buf(m_response + 4, ip); // IP
|
||||
return boost::asio::const_buffers_1(m_response,8);
|
||||
return boost::asio::const_buffer (m_response,8);
|
||||
}
|
||||
|
||||
boost::asio::const_buffers_1 SOCKSHandler::GenerateSOCKS5Response(SOCKSHandler::errTypes error, SOCKSHandler::addrTypes type, const SOCKSHandler::address &addr, uint16_t port)
|
||||
boost::asio::const_buffer SOCKSHandler::GenerateSOCKS5Response(SOCKSHandler::errTypes error, SOCKSHandler::addrTypes type, const SOCKSHandler::address &addr, uint16_t port)
|
||||
{
|
||||
size_t size = 6; // header + port
|
||||
assert(error <= SOCKS5_ADDR_UNSUP);
|
||||
|
@ -280,14 +279,14 @@ namespace proxy
|
|||
}
|
||||
break;
|
||||
}
|
||||
return boost::asio::const_buffers_1(m_response, size);
|
||||
return boost::asio::const_buffer (m_response, size);
|
||||
}
|
||||
|
||||
bool SOCKSHandler::Socks5ChooseAuth()
|
||||
{
|
||||
m_response[0] = '\x05'; // Version
|
||||
m_response[1] = m_authchosen; // Response code
|
||||
boost::asio::const_buffers_1 response(m_response, 2);
|
||||
boost::asio::const_buffer response(m_response, 2);
|
||||
if (m_authchosen == AUTH_UNACCEPTABLE)
|
||||
{
|
||||
LogPrint(eLogWarning, "SOCKS: v5 authentication negotiation failed");
|
||||
|
@ -307,14 +306,14 @@ namespace proxy
|
|||
m_response[0] = 1; // Version of the subnegotiation
|
||||
m_response[1] = 0; // Response code
|
||||
LogPrint(eLogDebug, "SOCKS: v5 user/password response");
|
||||
boost::asio::async_write(*m_sock, boost::asio::const_buffers_1(m_response, 2),
|
||||
boost::asio::async_write(*m_sock, boost::asio::const_buffer(m_response, 2),
|
||||
std::bind(&SOCKSHandler::SentSocksResponse, shared_from_this(), std::placeholders::_1));
|
||||
}
|
||||
|
||||
/* All hope is lost beyond this point */
|
||||
void SOCKSHandler::SocksRequestFailed(SOCKSHandler::errTypes error)
|
||||
{
|
||||
boost::asio::const_buffers_1 response(nullptr,0);
|
||||
boost::asio::const_buffer response(nullptr,0);
|
||||
assert(error != SOCKS4_OK && error != SOCKS5_OK);
|
||||
switch (m_socksv)
|
||||
{
|
||||
|
@ -334,7 +333,7 @@ namespace proxy
|
|||
|
||||
void SOCKSHandler::SocksRequestSuccess()
|
||||
{
|
||||
boost::asio::const_buffers_1 response(nullptr,0);
|
||||
boost::asio::const_buffer response(nullptr,0);
|
||||
// TODO: this should depend on things like the command type and callbacks may change
|
||||
switch (m_socksv)
|
||||
{
|
||||
|
@ -691,9 +690,8 @@ namespace proxy
|
|||
if (m_UpstreamProxyPort) // TCP
|
||||
{
|
||||
EnterState(UPSTREAM_RESOLVE);
|
||||
boost::asio::ip::tcp::resolver::query q(m_UpstreamProxyAddress, std::to_string(m_UpstreamProxyPort));
|
||||
m_proxy_resolver.async_resolve(q, std::bind(&SOCKSHandler::HandleUpstreamResolved, shared_from_this(),
|
||||
std::placeholders::_1, std::placeholders::_2));
|
||||
m_proxy_resolver.async_resolve(m_UpstreamProxyAddress, std::to_string(m_UpstreamProxyPort),
|
||||
std::bind(&SOCKSHandler::HandleUpstreamResolved, shared_from_this(), std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
else if (!m_UpstreamProxyAddress.empty ())// local
|
||||
{
|
||||
|
@ -729,7 +727,7 @@ namespace proxy
|
|||
void SOCKSHandler::SocksUpstreamSuccess(std::shared_ptr<Socket>& upstreamSock)
|
||||
{
|
||||
LogPrint(eLogInfo, "SOCKS: Upstream success");
|
||||
boost::asio::const_buffers_1 response(nullptr, 0);
|
||||
boost::asio::const_buffer response(nullptr, 0);
|
||||
switch (m_socksv)
|
||||
{
|
||||
case SOCKS4:
|
||||
|
@ -775,7 +773,8 @@ namespace proxy
|
|||
LogPrint(eLogError, "SOCKS: No upstream socket to send handshake to");
|
||||
}
|
||||
|
||||
void SOCKSHandler::HandleUpstreamConnected(const boost::system::error_code & ecode, boost::asio::ip::tcp::resolver::iterator itr)
|
||||
void SOCKSHandler::HandleUpstreamConnected(const boost::system::error_code & ecode,
|
||||
const boost::asio::ip::tcp::endpoint& ep)
|
||||
{
|
||||
if (ecode) {
|
||||
LogPrint(eLogWarning, "SOCKS: Could not connect to upstream proxy: ", ecode.message());
|
||||
|
@ -786,7 +785,8 @@ namespace proxy
|
|||
SendUpstreamRequest(m_upstreamSock);
|
||||
}
|
||||
|
||||
void SOCKSHandler::HandleUpstreamResolved(const boost::system::error_code & ecode, boost::asio::ip::tcp::resolver::iterator itr)
|
||||
void SOCKSHandler::HandleUpstreamResolved(const boost::system::error_code & ecode,
|
||||
boost::asio::ip::tcp::resolver::results_type endpoints)
|
||||
{
|
||||
if (ecode) {
|
||||
// error resolving
|
||||
|
@ -798,7 +798,7 @@ namespace proxy
|
|||
EnterState(UPSTREAM_CONNECT);
|
||||
auto & service = GetOwner()->GetService();
|
||||
m_upstreamSock = std::make_shared<boost::asio::ip::tcp::socket>(service);
|
||||
boost::asio::async_connect(*m_upstreamSock, itr,
|
||||
boost::asio::async_connect(*m_upstreamSock, endpoints,
|
||||
std::bind(&SOCKSHandler::HandleUpstreamConnected,
|
||||
shared_from_this(), std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue