From 077bac4b66b7cb3858cfb694e6dddf01c5686159 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 19 Oct 2021 13:56:09 +0200 Subject: [PATCH] Don't print "Discovered new external" line for private IPs (#10055) --- client/network/src/discovery.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 1ed08cd671d4e..2a4b25a621e04 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -599,14 +599,16 @@ impl NetworkBehaviour for DiscoveryBehaviour { fn inject_new_external_addr(&mut self, addr: &Multiaddr) { let new_addr = addr.clone().with(Protocol::P2p(self.local_peer_id.into())); - // NOTE: we might re-discover the same address multiple times - // in which case we just want to refrain from logging. - if self.known_external_addresses.insert(new_addr.clone()) { - info!( - target: "sub-libp2p", - "🔍 Discovered new external address for our node: {}", - new_addr, - ); + if self.can_add_to_dht(addr) { + // NOTE: we might re-discover the same address multiple times + // in which case we just want to refrain from logging. + if self.known_external_addresses.insert(new_addr.clone()) { + info!( + target: "sub-libp2p", + "🔍 Discovered new external address for our node: {}", + new_addr, + ); + } } for k in self.kademlias.values_mut() {