Browse Source

don't send message to not established session

pull/1229/head
orignal 6 years ago
parent
commit
022f4d2c11
  1. 2
      libi2pd/NTCP2.cpp

2
libi2pd/NTCP2.cpp

@ -959,6 +959,7 @@ namespace transport
void NTCP2Session::SendRouterInfo () void NTCP2Session::SendRouterInfo ()
{ {
if (!IsEstablished ()) return;
auto riLen = i2p::context.GetRouterInfo ().GetBufferLen (); auto riLen = i2p::context.GetRouterInfo ().GetBufferLen ();
int paddingSize = (riLen*NTCP2_MAX_PADDING_RATIO)/100; int paddingSize = (riLen*NTCP2_MAX_PADDING_RATIO)/100;
size_t payloadLen = riLen + paddingSize + 7; // 7 = 2*3 bytes header + 1 byte RI flag size_t payloadLen = riLen + paddingSize + 7; // 7 = 2*3 bytes header + 1 byte RI flag
@ -976,6 +977,7 @@ namespace transport
void NTCP2Session::SendTermination (NTCP2TerminationReason reason) void NTCP2Session::SendTermination (NTCP2TerminationReason reason)
{ {
if (!IsEstablished ()) return;
uint8_t payload[12] = { eNTCP2BlkTermination, 0, 9 }; uint8_t payload[12] = { eNTCP2BlkTermination, 0, 9 };
htobe64buf (payload + 3, m_ReceiveSequenceNumber); htobe64buf (payload + 3, m_ReceiveSequenceNumber);
payload[11] = (uint8_t)reason; payload[11] = (uint8_t)reason;

Loading…
Cancel
Save