From 53d132ff902ff07198b0e01f8c1a030f06aa562b Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 1 Nov 2026 13:30:12 +0100 Subject: libp2p: one Book::usable for all dials --- src/transport/libp2p/ignore.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/transport/libp2p/ignore.rs') diff --git a/src/transport/libp2p/ignore.rs b/src/transport/libp2p/ignore.rs index 2fcbd6f..6062839 100644 --- a/src/transport/libp2p/ignore.rs +++ b/src/transport/libp2p/ignore.rs @@ -155,6 +155,29 @@ impl ::libp2p::swarm::NetworkBehaviour for Ignoring { Ok(::libp2p::swarm::dummy::ConnectionHandler) } + /// Dials libp2p makes itself (hole punching, AutoNAT, the DHT) to addresses all in + /// ranges left out are refused before they go out; ours never go there + /// (`Book::usable`). A dial with an address elsewhere too goes, and a connection it + /// makes in a range left out is refused once established (below). + fn handle_pending_outbound_connection( + &mut self, + _connection_id: ConnectionId, + _maybe_peer: Option, + addresses: &[Multiaddr], + _effective_role: ::libp2p::core::Endpoint, + ) -> Result, ::libp2p::swarm::ConnectionDenied> { + if let Some(first) = addresses.first() + && addresses + .iter() + .all(|address| ignored(&self.ranges, address)) + { + return Err(::libp2p::swarm::ConnectionDenied::new(IgnoredAddress( + first.clone(), + ))); + } + Ok(Vec::new()) + } + fn handle_established_outbound_connection( &mut self, _connection_id: ConnectionId, -- cgit v1.3.1