Skip to content

Commit

Permalink
terminate NTCP2 session from duplicated router properly
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Sep 10, 2024
1 parent 261acbb commit 272bf7d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libi2pd/NTCP2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ namespace transport
if (!ri1)
{
LogPrint (eLogError, "NTCP2: Couldn't update RouterInfo from SessionConfirmed in netdb");
Terminate ();
return;
}
std::shared_ptr<i2p::data::RouterProfile> profile; // not null if older
Expand All @@ -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 () :
Expand All @@ -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
Expand Down

0 comments on commit 272bf7d

Please sign in to comment.