From 88491fbb45958017155bfb233a8464734604624c Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 9 Oct 2026 10:55:50 -0400 Subject: [PATCH] don't include new nodes to routing table until until receive a message from them --- libi2pd_client/TorrentsDHT.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libi2pd_client/TorrentsDHT.cpp b/libi2pd_client/TorrentsDHT.cpp index 8482fe29..b61c03f4 100644 --- a/libi2pd_client/TorrentsDHT.cpp +++ b/libi2pd_client/TorrentsDHT.cpp @@ -800,12 +800,13 @@ namespace torrents if (m_RoutingTable) { const auto& [ident, port, query, info, time] = it->second; + if (query != eKRPCQueryAnnouncePeer) // port is rport there + UpdateNode (std::make_shared (nodeID, ident, port)); switch (query) { case eKRPCQueryPing: { LogPrint (eLogDebug, "TorrentsDHT: Ping response received"); - UpdateNode (std::make_shared (nodeID, ident, port)); break; } case eKRPCQueryGetPeers: @@ -846,9 +847,9 @@ namespace torrents while (nodes.size () >= nodeInfo.size ()) { memcpy (nodeInfo.data (), nodes.data (), nodeInfo.size ()); - auto node = UpdateNode (std::make_shared(nodeInfo)); - if (info) - info->AddNode (node); + auto node = std::make_shared(nodeInfo); + if (info && info->AddNode (node)) + SendPingQuery (node->peer, node->port); nodes = nodes.substr (nodeInfo.size ()); } if (info) @@ -880,9 +881,9 @@ namespace torrents while (nodes.size () >= nodeInfo.size ()) { memcpy (nodeInfo.data (), nodes.data (), nodeInfo.size ()); - auto node = UpdateNode (std::make_shared(nodeInfo)); - if (info && node) - info->AddNode (node); + auto node = std::make_shared(nodeInfo); + if (info && info->AddNode (node)) + SendPingQuery (node->peer, node->port); nodes = nodes.substr (nodeInfo.size ()); } if (info)