From 95f19a5fb23e5a2e8c3c429c397b3ae6ae8f0039 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 26 Aug 2022 10:14:30 -0400 Subject: [PATCH] send Retry instead SessionCreated if clock skew --- libi2pd/SSU2Session.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libi2pd/SSU2Session.cpp b/libi2pd/SSU2Session.cpp index e9c79b9f..b66c44ef 100644 --- a/libi2pd/SSU2Session.cpp +++ b/libi2pd/SSU2Session.cpp @@ -616,8 +616,13 @@ namespace transport m_State = eSSU2SessionStateSessionRequestReceived; HandlePayload (decryptedPayload.data (), decryptedPayload.size ()); - m_Server.AddSession (shared_from_this ()); - SendSessionCreated (headerX + 16); + if (m_TerminationReason == eSSU2TerminationReasonNormalClose) + { + m_Server.AddSession (shared_from_this ()); + SendSessionCreated (headerX + 16); + } + else + SendRetry (); } void SSU2Session::SendSessionCreated (const uint8_t * X) @@ -666,8 +671,6 @@ namespace transport memcpy (payload + payloadSize + 7, &token.first, 8); // token payloadSize += 15; } - if (m_TerminationReason != eSSU2TerminationReasonNormalClose) - payloadSize += CreateTerminationBlock (payload + payloadSize, maxPayloadSize - payloadSize); payloadSize += CreatePaddingBlock (payload + payloadSize, maxPayloadSize - payloadSize); // KDF for SessionCreated m_NoiseState->MixHash ( { {header.buf, 16}, {headerX, 16} } ); // h = SHA256(h || header) @@ -687,9 +690,6 @@ namespace transport m_SentHandshakePacket->payloadSize = payloadSize; // send m_Server.Send (header.buf, 16, headerX, 48, payload, payloadSize, m_RemoteEndpoint); - // terminate if errors - if (m_TerminationReason != eSSU2TerminationReasonNormalClose) - Terminate (); } bool SSU2Session::ProcessSessionCreated (uint8_t * buf, size_t len)