From 1bfb9b02f5103aa86cd9a47aedf1bb0f192015d5 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 24 Apr 2019 11:40:58 -0400 Subject: [PATCH] make sure remote endpoint matches stored with --- libi2pd/SSU.cpp | 10 ++++++++++ libi2pd/SSUSession.h | 1 + 2 files changed, 11 insertions(+) diff --git a/libi2pd/SSU.cpp b/libi2pd/SSU.cpp index 2197552c..4fe45e01 100644 --- a/libi2pd/SSU.cpp +++ b/libi2pd/SSU.cpp @@ -750,6 +750,11 @@ namespace transport if (it.second->IsTerminationTimeoutExpired (ts)) { auto session = it.second; + if (it.first != session->GetRemoteEndpoint ()) + { + LogPrint (eLogWarning, "SSU: remote endpoint ", session->GetRemoteEndpoint (), " doesn't match key ", it.first, " adjusted"); + session->SetRemoteEndpoint (it.first); // TODO: investigate why it happens + } m_Service.post ([session] { LogPrint (eLogWarning, "SSU: no activity with ", session->GetRemoteEndpoint (), " for ", session->GetTerminationTimeout (), " seconds"); @@ -776,6 +781,11 @@ namespace transport if (it.second->IsTerminationTimeoutExpired (ts)) { auto session = it.second; + if (it.first != session->GetRemoteEndpoint ()) + { + LogPrint (eLogWarning, "SSU: remote endpoint ", session->GetRemoteEndpoint (), " doesn't match key ", it.first, " adjusted"); + session->SetRemoteEndpoint (it.first); // TODO: investigate why it happens + } m_ServiceV6.post ([session] { LogPrint (eLogWarning, "SSU: no activity with ", session->GetRemoteEndpoint (), " for ", session->GetTerminationTimeout (), " seconds"); diff --git a/libi2pd/SSUSession.h b/libi2pd/SSUSession.h index 7f053d37..8df3933a 100644 --- a/libi2pd/SSUSession.h +++ b/libi2pd/SSUSession.h @@ -81,6 +81,7 @@ namespace transport void Done (); void Failed (); boost::asio::ip::udp::endpoint& GetRemoteEndpoint () { return m_RemoteEndpoint; }; + void SetRemoteEndpoint (const boost::asio::ip::udp::endpoint& ep) { m_RemoteEndpoint = ep; }; // TODO: not to use bool IsV6 () const { return m_RemoteEndpoint.address ().is_v6 (); }; void SendI2NPMessages (const std::vector >& msgs); void SendPeerTest (); // Alice