Browse Source

more

pull/881/head
Jeff Becker 8 years ago
parent
commit
71c9b15ff1
  1. 16
      libi2pd/NTCPSession.cpp

16
libi2pd/NTCPSession.cpp

@ -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,12 +1126,19 @@ 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)
{
if( readbuff[1] == 0x5a)
{ {
timer->cancel(); timer->cancel();
conn->ClientLogin(); conn->ClientLogin();
} }
else
{
i2p::data::netdb.SetUnreachable (conn->GetRemoteIdentity ()->GetIdentHash (), true);
}
}
}); });
} }

Loading…
Cancel
Save