Browse Source

check send frame error code

pull/1221/head
orignal 6 years ago
parent
commit
6d46fc9f9f
  1. 38
      libi2pd/NTCP2.cpp

38
libi2pd/NTCP2.cpp

@ -465,8 +465,16 @@ namespace transport
// TODO: check tsB // TODO: check tsB
if (paddingLen > 0) if (paddingLen > 0)
{ {
boost::asio::async_read (m_Socket, boost::asio::buffer(m_Establisher->m_SessionCreatedBuffer + 64, paddingLen), boost::asio::transfer_all (), if (paddingLen <= 287 - 64) // session created is 287 bytes max
std::bind(&NTCP2Session::HandleSessionCreatedPaddingReceived, shared_from_this (), std::placeholders::_1, std::placeholders::_2)); {
boost::asio::async_read (m_Socket, boost::asio::buffer(m_Establisher->m_SessionCreatedBuffer + 64, paddingLen), boost::asio::transfer_all (),
std::bind(&NTCP2Session::HandleSessionCreatedPaddingReceived, shared_from_this (), std::placeholders::_1, std::placeholders::_2));
}
else
{
LogPrint (eLogWarning, "NTCP2: SessionCreated padding length ", (int)paddingLen, " is too long");
Terminate ();
}
} }
else else
SendSessionConfirmed (); SendSessionConfirmed ();
@ -677,7 +685,8 @@ namespace transport
{ {
if (ecode) if (ecode)
{ {
LogPrint (eLogWarning, "NTCP2: receive length read error: ", ecode.message ()); if (ecode != boost::asio::error::operation_aborted)
LogPrint (eLogWarning, "NTCP2: receive length read error: ", ecode.message ());
Terminate (); Terminate ();
} }
else else
@ -702,7 +711,8 @@ namespace transport
{ {
if (ecode) if (ecode)
{ {
LogPrint (eLogWarning, "NTCP2: receive read error: ", ecode.message ()); if (ecode != boost::asio::error::operation_aborted)
LogPrint (eLogWarning, "NTCP2: receive read error: ", ecode.message ());
Terminate (); Terminate ();
} }
else else
@ -805,13 +815,21 @@ namespace transport
void NTCP2Session::HandleNextFrameSent (const boost::system::error_code& ecode, std::size_t bytes_transferred) void NTCP2Session::HandleNextFrameSent (const boost::system::error_code& ecode, std::size_t bytes_transferred)
{ {
m_LastActivityTimestamp = i2p::util::GetSecondsSinceEpoch ();
m_NumSentBytes += bytes_transferred;
i2p::transport::transports.UpdateSentBytes (bytes_transferred);
delete[] m_NextSendBuffer; m_NextSendBuffer = nullptr;
LogPrint (eLogDebug, "NTCP2: Next frame sent");
m_IsSending = false; m_IsSending = false;
SendQueue (); delete[] m_NextSendBuffer; m_NextSendBuffer = nullptr;
if (ecode)
{
LogPrint (eLogWarning, "NTCP2: Couldn't send frame ", ecode.message ());
}
else
{
m_LastActivityTimestamp = i2p::util::GetSecondsSinceEpoch ();
m_NumSentBytes += bytes_transferred;
i2p::transport::transports.UpdateSentBytes (bytes_transferred);
LogPrint (eLogDebug, "NTCP2: Next frame sent");
SendQueue ();
}
} }
void NTCP2Session::SendQueue () void NTCP2Session::SendQueue ()

Loading…
Cancel
Save