1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-02-07 03:34:15 +00:00
This commit is contained in:
Jeff Becker 2017-05-29 02:12:16 -04:00
parent 2940f0d67c
commit 71c9b15ff1

View File

@ -1043,7 +1043,8 @@ namespace transport
{ {
auto timer = std::make_shared<boost::asio::deadline_timer>(m_Service); auto timer = std::make_shared<boost::asio::deadline_timer>(m_Service);
auto timeout = NTCP_CONNECT_TIMEOUT * 2; auto timeout = NTCP_CONNECT_TIMEOUT * 5;
conn->SetTerminationTimeout(timeout);
timer->expires_from_now (boost::posix_time::seconds(timeout)); timer->expires_from_now (boost::posix_time::seconds(timeout));
timer->async_wait ([conn, timeout](const boost::system::error_code& ecode) { timer->async_wait ([conn, timeout](const boost::system::error_code& ecode) {
if (ecode != boost::asio::error::operation_aborted) if (ecode != boost::asio::error::operation_aborted)
@ -1117,7 +1118,7 @@ namespace transport
memcpy(buff+12, host.c_str(), addrsz); memcpy(buff+12, host.c_str(), addrsz);
buff[12+addrsz] = 0; buff[12+addrsz] = 0;
boost::asio::async_write(conn->GetSocket(), boost::asio::buffer(buff, sz), boost::asio::transfer_all(), [&](const boost::system::error_code & ec, std::size_t written) { boost::asio::async_write(conn->GetSocket(), boost::asio::buffer(buff, sz), boost::asio::transfer_all(), [=](const boost::system::error_code & ec, std::size_t written) {
if(ec) if(ec)
{ {
LogPrint(eLogError, "NTCP: failed to write handshake to socks proxy ", ec.message()); LogPrint(eLogError, "NTCP: failed to write handshake to socks proxy ", ec.message());
@ -1125,11 +1126,18 @@ namespace transport
} }
}); });
boost::asio::async_read(conn->GetSocket(), boost::asio::buffer(readbuff, 8), [&](const boost::system::error_code & e, std::size_t transferred) { boost::asio::async_read(conn->GetSocket(), boost::asio::buffer(readbuff, 8), [=](const boost::system::error_code & e, std::size_t transferred) {
if(transferred == 8 && readbuff[1] == 0x5a) if(transferred == 8)
{ {
timer->cancel(); if( readbuff[1] == 0x5a)
conn->ClientLogin(); {
timer->cancel();
conn->ClientLogin();
}
else
{
i2p::data::netdb.SetUnreachable (conn->GetRemoteIdentity ()->GetIdentHash (), true);
}
} }
}); });
} }