Browse Source

resend SessionConfirmed immediately if another SessionCreated received

pull/1786/head
orignal 2 years ago
parent
commit
000e0358a7
  1. 25
      libi2pd/SSU2Session.cpp
  2. 3
      libi2pd/SSU2Session.h

25
libi2pd/SSU2Session.cpp

@ -336,13 +336,8 @@ namespace transport
if (m_SentHandshakePacket && ts >= m_SentHandshakePacket->nextResendTime) if (m_SentHandshakePacket && ts >= m_SentHandshakePacket->nextResendTime)
{ {
LogPrint (eLogDebug, "SSU2: Resending ", (int)m_State); LogPrint (eLogDebug, "SSU2: Resending ", (int)m_State);
m_Server.Send (m_SentHandshakePacket->header.buf, 16, m_SentHandshakePacket->headerX, 48, ResendHandshakePacket ();
m_SentHandshakePacket->payload, m_SentHandshakePacket->payloadSize, m_RemoteEndpoint);
m_SentHandshakePacket->nextResendTime = ts + SSU2_HANDSHAKE_RESEND_INTERVAL; m_SentHandshakePacket->nextResendTime = ts + SSU2_HANDSHAKE_RESEND_INTERVAL;
if (m_SessionConfirmedFragment && m_State == eSSU2SessionStateSessionConfirmedSent)
// resend second fragment of SessionConfirmed
m_Server.Send (m_SessionConfirmedFragment->header.buf, 16,
m_SessionConfirmedFragment->payload, m_SessionConfirmedFragment->payloadSize, m_RemoteEndpoint);
return; return;
} }
// resend data packets // resend data packets
@ -382,6 +377,19 @@ namespace transport
SendQueue (); SendQueue ();
} }
void SSU2Session::ResendHandshakePacket ()
{
if (m_SentHandshakePacket)
{
m_Server.Send (m_SentHandshakePacket->header.buf, 16, m_SentHandshakePacket->headerX, 48,
m_SentHandshakePacket->payload, m_SentHandshakePacket->payloadSize, m_RemoteEndpoint);
if (m_SessionConfirmedFragment && m_State == eSSU2SessionStateSessionConfirmedSent)
// resend second fragment of SessionConfirmed
m_Server.Send (m_SessionConfirmedFragment->header.buf, 16,
m_SessionConfirmedFragment->payload, m_SessionConfirmedFragment->payloadSize, m_RemoteEndpoint);
}
}
bool SSU2Session::ProcessFirstIncomingMessage (uint64_t connID, uint8_t * buf, size_t len) bool SSU2Session::ProcessFirstIncomingMessage (uint64_t connID, uint8_t * buf, size_t len)
{ {
// we are Bob // we are Bob
@ -1190,7 +1198,10 @@ namespace transport
if (header.h.type != eSSU2Data) if (header.h.type != eSSU2Data)
{ {
LogPrint (eLogWarning, "SSU2: Unexpected message type ", (int)header.h.type, " instead ", (int)eSSU2Data); LogPrint (eLogWarning, "SSU2: Unexpected message type ", (int)header.h.type, " instead ", (int)eSSU2Data);
SendQuickAck (); // in case it was SessionConfirmed if (IsEstablished ())
SendQuickAck (); // in case it was SessionConfirmed
else
ResendHandshakePacket (); // assume we receive
return; return;
} }
uint8_t payload[SSU2_MAX_PACKET_SIZE]; uint8_t payload[SSU2_MAX_PACKET_SIZE];

3
libi2pd/SSU2Session.h

@ -252,7 +252,8 @@ namespace transport
void PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs); void PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs);
bool SendQueue (); bool SendQueue ();
void SendFragmentedMessage (std::shared_ptr<I2NPMessage> msg); void SendFragmentedMessage (std::shared_ptr<I2NPMessage> msg);
void ResendHandshakePacket ();
void ProcessSessionRequest (Header& header, uint8_t * buf, size_t len); void ProcessSessionRequest (Header& header, uint8_t * buf, size_t len);
void ProcessTokenRequest (Header& header, uint8_t * buf, size_t len); void ProcessTokenRequest (Header& header, uint8_t * buf, size_t len);

Loading…
Cancel
Save