From 5f98b46d58e37dfe409578d48e15966acf7c4560 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 4 Dec 2019 12:51:45 +0000 Subject: p2p: remove obsolete local time from TIMED_SYNC --- src/p2p/net_node.inl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/p2p/net_node.inl') diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 263cecfa2..7a2feddc8 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -1041,7 +1041,7 @@ namespace nodetool return; } - if(!handle_remote_peerlist(rsp.local_peerlist_new, rsp.node_data.local_time, context)) + if(!handle_remote_peerlist(rsp.local_peerlist_new, context)) { LOG_WARNING_CC(context, "COMMAND_HANDSHAKE: failed to handle_remote_peerlist(...), closing connection."); add_host_fail(context.m_remote_address); @@ -1119,7 +1119,7 @@ namespace nodetool return; } - if(!handle_remote_peerlist(rsp.local_peerlist_new, rsp.local_time, context)) + if(!handle_remote_peerlist(rsp.local_peerlist_new, context)) { LOG_WARNING_CC(context, "COMMAND_TIMED_SYNC: failed to handle_remote_peerlist(...), closing connection."); m_network_zones.at(context.m_remote_address.get_zone()).m_net_server.get_config_object().close(context.m_connection_id ); @@ -1894,7 +1894,7 @@ namespace nodetool } //----------------------------------------------------------------------------------- template - bool node_server::handle_remote_peerlist(const std::vector& peerlist, time_t local_time, const epee::net_utils::connection_context_base& context) + bool node_server::handle_remote_peerlist(const std::vector& peerlist, const epee::net_utils::connection_context_base& context) { std::vector peerlist_ = peerlist; if(!sanitize_peerlist(peerlist_)) @@ -2291,8 +2291,6 @@ namespace nodetool } //fill response - rsp.local_time = time(NULL); - const epee::net_utils::zone zone_type = context.m_remote_address.get_zone(); network_zone& zone = m_network_zones.at(zone_type); -- cgit v1.2.3 From 2fbbc4a2d3ebfd6fca1d9d7687cef261491c0e1f Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 4 Dec 2019 21:22:55 +0000 Subject: p2p: avoid sending the same peer list over and over Nodes remember which connections have been sent which peer addresses and won't send it again. This causes more addresses to be sent as the connection lifetime grows, since there is no duplication anymore, which increases the diffusion speed of peer addresses. The whole white list is now considered for sending, not just the most recent seen peers. This further hardens against topology discovery, though it will more readily send peers that have been last seen earlier than it otherwise would. While this does save a fair amount of net bandwidth, it makes heavy use of std::set lookups, which does bring network_address::less up the profile, though not too aggressively. --- src/p2p/net_node.inl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/p2p/net_node.inl') diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 7a2feddc8..13da53b1d 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -2294,7 +2294,17 @@ namespace nodetool const epee::net_utils::zone zone_type = context.m_remote_address.get_zone(); network_zone& zone = m_network_zones.at(zone_type); - zone.m_peerlist.get_peerlist_head(rsp.local_peerlist_new, true); + std::vector local_peerlist_new; + zone.m_peerlist.get_peerlist_head(local_peerlist_new, true, P2P_DEFAULT_PEERS_IN_HANDSHAKE); + + //only include out peers we did not already send + rsp.local_peerlist_new.reserve(local_peerlist_new.size()); + for (auto &pe: local_peerlist_new) + { + if (!context.sent_addresses.insert(pe.adr).second) + continue; + rsp.local_peerlist_new.push_back(std::move(pe)); + } m_payload_handler.get_payload_sync_data(rsp.payload_data); /* Tor/I2P nodes receiving connections via forwarding (from tor/i2p daemon) @@ -2416,6 +2426,8 @@ namespace nodetool //fill response zone.m_peerlist.get_peerlist_head(rsp.local_peerlist_new, true); + for (const auto &e: rsp.local_peerlist_new) + context.sent_addresses.insert(e.adr); get_local_node_data(rsp.node_data, zone); m_payload_handler.get_payload_sync_data(rsp.payload_data); LOG_DEBUG_CC(context, "COMMAND_HANDSHAKE"); -- cgit v1.2.3 From 4771a7aec198421fd6c7875b88f496b6c689ade8 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 5 Dec 2019 12:27:57 +0000 Subject: p2p: remove obsolete local time in handshake Also removes a potential fingerprinting vector --- src/p2p/net_node.inl | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/p2p/net_node.inl') diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 13da53b1d..998406c91 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -1918,9 +1918,6 @@ namespace nodetool template bool node_server::get_local_node_data(basic_node_data& node_data, const network_zone& zone) { - time_t local_time; - time(&local_time); - node_data.local_time = local_time; // \TODO This can be an identifying value across zones (public internet to tor/i2p) ... node_data.peer_id = zone.m_config.m_peer_id; if(!m_hide_my_port && zone.m_can_pingback) node_data.my_port = m_external_port ? m_external_port : m_listening_port; -- cgit v1.2.3