diff --git a/sn_networking/src/event.rs b/sn_networking/src/event.rs index b912936653..31e04f19c9 100644 --- a/sn_networking/src/event.rs +++ b/sn_networking/src/event.rs @@ -163,7 +163,6 @@ pub enum NetworkEvent { #[derive(Debug, Clone)] pub enum TerminateNodeReason { HardDiskWriteError, - BehindNAT, } // Manually implement Debug as `#[debug(with = "unverified_record_fmt")]` not working as expected. @@ -257,6 +256,13 @@ impl SwarmDriver { event_string = "kad_event"; self.handle_kad_event(kad_event)?; } + SwarmEvent::Behaviour(NodeEvent::Dcutr(event)) => { + event_string = "dcutr_event"; + info!( + "Dcutr with remote peer: {:?} is: {:?}", + event.remote_peer_id, event.result + ); + } SwarmEvent::Behaviour(NodeEvent::RelayClient(event)) => { event_string = "relay_client_event"; @@ -419,14 +425,6 @@ impl SwarmDriver { .kademlia .add_address(&peer_id, multiaddr.clone()); } - - if self.relay_manager.are_we_behind_nat(&mut self.swarm) { - warn!("Node reported as being behind NAT for not having enough incoming connections. This can be a false positive. Do nothing."); - - // self.send_event(NetworkEvent::TerminateNode { - // reason: TerminateNodeReason::BehindNAT, - // }) - } } } trace!( diff --git a/sn_networking/src/relay_manager.rs b/sn_networking/src/relay_manager.rs index 58bfcad00f..720a1fc1cf 100644 --- a/sn_networking/src/relay_manager.rs +++ b/sn_networking/src/relay_manager.rs @@ -14,7 +14,6 @@ use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; const MAX_CONCURRENT_RELAY_CONNECTIONS: usize = 3; const MAX_POTENTIAL_CANDIDATES: usize = 15; -const MAX_PEERS_IN_RT_DURING_NAT_CHECK: usize = 30; /// To manager relayed connections. #[derive(Debug)] @@ -65,30 +64,6 @@ impl RelayManager { || self.waiting_for_reservation.contains_key(peer_id) } - /// If we have 0 incoming connection even after we have a lot of peers, then we are behind a NAT - pub(crate) fn are_we_behind_nat(&self, swarm: &mut Swarm) -> bool { - if swarm - .network_info() - .connection_counters() - .num_established_incoming() - == 0 - || swarm - .network_info() - .connection_counters() - .num_pending_incoming() - == 0 - { - let mut total_peers = 0; - for kbucket in swarm.behaviour_mut().kademlia.kbuckets() { - total_peers += kbucket.num_entries(); - if total_peers > MAX_PEERS_IN_RT_DURING_NAT_CHECK { - return true; - } - } - } - false - } - /// Add a potential candidate to the list if it satisfies all the identify checks and also supports the relay server /// protocol. pub(crate) fn add_potential_candidates(