|
|
@ -1424,19 +1424,20 @@ namespace transport |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogError, "NTCP2: Connected from error ", ec.message ()); |
|
|
|
LogPrint (eLogError, "NTCP2: Connected from error ", ec.message ()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (error == boost::asio::error::no_descriptors) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
i2p::context.SetError (eRouterErrorNoDescriptors); |
|
|
|
|
|
|
|
if (m_NoFileExhaustTimestamp < i2p::util::GetSecondsSinceEpoch () - NTCP2_DESCRIPTORS_EXHAUST_TIMEOUT) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_NoFileExhaustTimestamp = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
|
|
|
|
LogPrint (eLogWarning, "NTCP2: WARNING! i2pd met file descriptors exhaustion! Please check your nofile limits!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogError, "NTCP2: Accept error ", error.message ()); |
|
|
|
LogPrint (eLogError, "NTCP2: Accept error ", error.message ()); |
|
|
|
if (error == boost::asio::error::no_descriptors) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
i2p::context.SetError (eRouterErrorNoDescriptors); |
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (error != boost::asio::error::operation_aborted) |
|
|
|
if (error != boost::asio::error::operation_aborted) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!conn) // connection is used, create new one
|
|
|
|
if (!conn) // connection is used, create new one
|
|
|
|
conn = std::make_shared<NTCP2Session> (*this); |
|
|
|
conn = std::make_shared<NTCP2Session> (*this); |
|
|
|
else // reuse failed
|
|
|
|
else // reuse failed
|
|
|
@ -1463,22 +1464,26 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogError, "NTCP2: Connected from error ", ec.message ()); |
|
|
|
LogPrint (eLogError, "NTCP2: Connected from ipv6 error: ", ec.message ()); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else if (error == boost::asio::error::no_descriptors) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogError, "NTCP2: Accept ipv6 error ", error.message ()); |
|
|
|
i2p::context.SetErrorV6 (eRouterErrorNoDescriptors); |
|
|
|
if (error == boost::asio::error::no_descriptors) |
|
|
|
if (m_NoFileExhaustTimestamp < i2p::util::GetSecondsSinceEpoch () - NTCP2_DESCRIPTORS_EXHAUST_TIMEOUT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
i2p::context.SetErrorV6 (eRouterErrorNoDescriptors); |
|
|
|
m_NoFileExhaustTimestamp = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
// TODO
|
|
|
|
LogPrint (eLogWarning, "NTCP2: WARNING! i2pd met file descriptors exhaustion! Please check your nofile limits!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
LogPrint (eLogError, "NTCP2: Accept ipv6 error: ", error.message ()); |
|
|
|
|
|
|
|
|
|
|
|
if (error != boost::asio::error::operation_aborted) |
|
|
|
if (error != boost::asio::error::operation_aborted) |
|
|
|
{ |
|
|
|
{ |
|
|
|
conn = std::make_shared<NTCP2Session> (*this); |
|
|
|
if (!conn) // connection is used, create new one
|
|
|
|
|
|
|
|
conn = std::make_shared<NTCP2Session> (*this); |
|
|
|
|
|
|
|
else // reuse failed
|
|
|
|
|
|
|
|
conn->Close (); |
|
|
|
m_NTCP2V6Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCP2Server::HandleAcceptV6, this, |
|
|
|
m_NTCP2V6Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCP2Server::HandleAcceptV6, this, |
|
|
|
conn, std::placeholders::_1)); |
|
|
|
conn, std::placeholders::_1)); |
|
|
|
} |
|
|
|
} |
|
|
@ -1728,7 +1733,7 @@ namespace transport |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
boost::asio::async_read(conn->GetSocket(), boost::asio::buffer(readbuff->data (), SOCKS5_UDP_IPV4_REQUEST_HEADER_SIZE), // read min reply size
|
|
|
|
boost::asio::async_read(conn->GetSocket(), boost::asio::buffer(readbuff->data (), SOCKS5_UDP_IPV4_REQUEST_HEADER_SIZE), // read min reply size
|
|
|
|
boost::asio::transfer_all(), |
|
|
|
boost::asio::transfer_all(), |
|
|
|
[timer, conn, sz, readbuff](const boost::system::error_code & e, std::size_t transferred) |
|
|
|
[timer, conn, sz, readbuff](const boost::system::error_code & e, std::size_t transferred) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (e) |
|
|
|
if (e) |
|
|
@ -1736,7 +1741,7 @@ namespace transport |
|
|
|
else if (!(*readbuff)[1]) // succeeded
|
|
|
|
else if (!(*readbuff)[1]) // succeeded
|
|
|
|
{ |
|
|
|
{ |
|
|
|
boost::system::error_code ec; |
|
|
|
boost::system::error_code ec; |
|
|
|
size_t moreBytes = conn->GetSocket ().available(ec); |
|
|
|
size_t moreBytes = conn->GetSocket ().available(ec); |
|
|
|
if (moreBytes) // read remaining portion of reply if ipv6 received
|
|
|
|
if (moreBytes) // read remaining portion of reply if ipv6 received
|
|
|
|
boost::asio::read (conn->GetSocket (), boost::asio::buffer(readbuff->data (), moreBytes), boost::asio::transfer_all (), ec); |
|
|
|
boost::asio::read (conn->GetSocket (), boost::asio::buffer(readbuff->data (), moreBytes), boost::asio::transfer_all (), ec); |
|
|
|
timer->cancel(); |
|
|
|
timer->cancel(); |
|
|
|