From 83bd3b6f0b549cf346f098c899438416a59f4a9a Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 29 Jun 2022 13:42:57 -0400 Subject: [PATCH] use token from RelayResponse block --- libi2pd/SSU2Session.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libi2pd/SSU2Session.cpp b/libi2pd/SSU2Session.cpp index 0ee95b08..ebb4ba31 100644 --- a/libi2pd/SSU2Session.cpp +++ b/libi2pd/SSU2Session.cpp @@ -960,11 +960,9 @@ namespace transport RAND_bytes ((uint8_t *)&m_DestConnID, 8); RAND_bytes ((uint8_t *)&m_SourceConnID, 8); m_Server.UpdateSessionConnID (oldConnID); - // new token - m_Server.UpdateOutgoingToken (m_RemoteEndpoint, headerX[1], i2p::util::GetSecondsSinceEpoch () + SSU2_TOKEN_EXPIRATION_TIMEOUT); // connect m_State = eSSU2SessionStateUnknown; - SendSessionRequest (headerX[1]); + Connect (); } return true; @@ -1451,6 +1449,13 @@ namespace transport // verify nonce if (~htobe64 (((uint64_t)nonce << 32) | nonce) != m_DestConnID) LogPrint (eLogWarning, "SSU2: Relay response nonce mismatch ", nonce, " connID=", m_DestConnID); + if (len >= 8) + { + // new token + uint64_t token; + memcpy (&token, buf + len - 8, 8); + m_Server.UpdateOutgoingToken (m_RemoteEndpoint, token, i2p::util::GetSecondsSinceEpoch () + SSU2_TOKEN_EXPIRATION_TIMEOUT); + } return; } auto it = m_RelaySessions.find (nonce);