From 6b3d7372aea660c92cc0cfa65489ce744d7c29ef Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 22 Jun 2022 13:58:22 -0400 Subject: [PATCH] token received session state --- libi2pd/SSU2Session.cpp | 5 ++--- libi2pd/SSU2Session.h | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libi2pd/SSU2Session.cpp b/libi2pd/SSU2Session.cpp index 943836a3..ada51b4e 100644 --- a/libi2pd/SSU2Session.cpp +++ b/libi2pd/SSU2Session.cpp @@ -403,7 +403,7 @@ namespace transport i2p::crypto::ChaCha20 (headerX, 48, m_Address->i, nonce, headerX); m_NoiseState->MixHash (payload, payloadSize); // h = SHA256(h || encrypted payload from Session Request) for SessionCreated // send - if (m_Server.AddPendingOutgoingSession (shared_from_this ())) + if (m_State == eSSU2SessionStateTokenReceived || m_Server.AddPendingOutgoingSession (shared_from_this ())) m_Server.Send (header.buf, 16, headerX, 48, payload, payloadSize, m_RemoteEndpoint); else { @@ -545,7 +545,6 @@ namespace transport HandlePayload (decryptedPayload.data (), decryptedPayload.size ()); m_Server.AddSession (shared_from_this ()); - m_Server.RemovePendingOutgoingSession (m_RemoteEndpoint); SendSessionConfirmed (headerX + 16); KDFDataPhase (m_KeyDataSend, m_KeyDataReceive); Established (); @@ -842,8 +841,8 @@ namespace transport } HandlePayload (payload, len - 48); + m_State = eSSU2SessionStateTokenReceived; InitNoiseXKState1 (*m_NoiseState, m_Address->s); // reset Noise TODO: check state - m_Server.RemovePendingOutgoingSession (m_RemoteEndpoint); SendSessionRequest (headerX[1]); return true; } diff --git a/libi2pd/SSU2Session.h b/libi2pd/SSU2Session.h index 2439033a..4015c0aa 100644 --- a/libi2pd/SSU2Session.h +++ b/libi2pd/SSU2Session.h @@ -79,6 +79,7 @@ namespace transport enum SSU2SessionState { eSSU2SessionStateUnknown, + eSSU2SessionStateTokenReceived, eSSU2SessionStateEstablished, eSSU2SessionStateTerminated, eSSU2SessionStateFailed,