From 6ebc61cef9ee483af2da4782c657a3468b0b8a58 Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Sun, 24 Jul 2016 17:22:04 -0700 Subject: [PATCH] reject nodes with our id after checking for an existing entry This allows us to evict nodes which start reporting our id as theirs. --- src/kademlia/routing_table.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index 2d148005e..eb0e41d28 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -648,9 +648,6 @@ routing_table::add_node_status_t routing_table::add_node_impl(node_entry e) if (m_router_nodes.find(e.ep()) != m_router_nodes.end()) return failed_to_add; - // don't add ourself - if (e.id == m_id) return failed_to_add; - // do we already have this IP in the table? if (m_ips.count(e.addr()) > 0) { @@ -732,6 +729,9 @@ routing_table::add_node_status_t routing_table::add_node_impl(node_entry e) } } + // don't add ourself + if (e.id == m_id) return failed_to_add; + table_t::iterator i = find_bucket(e.id); bucket_t& b = i->live_nodes; bucket_t& rb = i->replacements;