From 272bf7dbc199de9e45beb04da7538266b31edc02 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 10 Sep 2024 12:35:36 -0400 Subject: [PATCH] terminate NTCP2 session from duplicated router properly --- libi2pd/NTCP2.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libi2pd/NTCP2.cpp b/libi2pd/NTCP2.cpp index f7d81671..a33d4fef 100644 --- a/libi2pd/NTCP2.cpp +++ b/libi2pd/NTCP2.cpp @@ -729,6 +729,7 @@ namespace transport if (!ri1) { LogPrint (eLogError, "NTCP2: Couldn't update RouterInfo from SessionConfirmed in netdb"); + Terminate (); return; } std::shared_ptr profile; // not null if older @@ -737,7 +738,10 @@ namespace transport // received RouterInfo is older than one in netdb profile = i2p::data::GetRouterProfile (ri1->GetIdentHash ()); // retrieve profile if (profile && profile->IsDuplicated ()) + { + SendTerminationAndTerminate (eNTCP2Banned); return; + } } auto addr = m_RemoteEndpoint.address ().is_v4 () ? ri1->GetNTCP2V4Address () : @@ -756,8 +760,8 @@ namespace transport if (profile) // older router? profile->Duplicated (); // mark router as duplicated in profile else - LogPrint (eLogError, "NTCP2: Host mismatch between published address ", addr->host, " and actual endpoint ", m_RemoteEndpoint.address ()); - Terminate (); + LogPrint (eLogInfo, "NTCP2: Host mismatch between published address ", addr->host, " and actual endpoint ", m_RemoteEndpoint.address ()); + SendTerminationAndTerminate (eNTCP2Banned); return; } // TODO: process options