Browse Source

check send frame error code

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

22
libi2pd/NTCP2.cpp

@ -464,10 +464,18 @@ namespace transport @@ -464,10 +464,18 @@ namespace transport
LogPrint (eLogDebug, "NTCP2: padding length ", paddingLen);
// TODO: check tsB
if (paddingLen > 0)
{
if (paddingLen <= 287 - 64) // session created is 287 bytes max
{
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
SendSessionConfirmed ();
}
@ -677,6 +685,7 @@ namespace transport @@ -677,6 +685,7 @@ namespace transport
{
if (ecode)
{
if (ecode != boost::asio::error::operation_aborted)
LogPrint (eLogWarning, "NTCP2: receive length read error: ", ecode.message ());
Terminate ();
}
@ -702,6 +711,7 @@ namespace transport @@ -702,6 +711,7 @@ namespace transport
{
if (ecode)
{
if (ecode != boost::asio::error::operation_aborted)
LogPrint (eLogWarning, "NTCP2: receive read error: ", ecode.message ());
Terminate ();
}
@ -804,15 +814,23 @@ namespace transport @@ -804,15 +814,23 @@ namespace transport
}
void NTCP2Session::HandleNextFrameSent (const boost::system::error_code& ecode, std::size_t bytes_transferred)
{
m_IsSending = false;
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);
delete[] m_NextSendBuffer; m_NextSendBuffer = nullptr;
LogPrint (eLogDebug, "NTCP2: Next frame sent");
m_IsSending = false;
SendQueue ();
}
}
void NTCP2Session::SendQueue ()
{

Loading…
Cancel
Save