aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/libp2p/ignore.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 13:30:12 +0100
committertv <tv@krebsco.de>2026-11-01 13:30:12 +0100
commit7a6eda9ca3abcb64bd41a6b85ea56a5b3f8b0b51 (patch)
tree7b95ad34c96da254a3672ba680e81df0280805af /src/transport/libp2p/ignore.rs
parentfec2900523cba5a70b7f0f67f2b132c7a655a926 (diff)
libp2p: one Book::usable for all dials
Diffstat (limited to 'src/transport/libp2p/ignore.rs')
-rw-r--r--src/transport/libp2p/ignore.rs23
1 files changed, 23 insertions, 0 deletions
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<PeerId>,
+ addresses: &[Multiaddr],
+ _effective_role: ::libp2p::core::Endpoint,
+ ) -> Result<Vec<Multiaddr>, ::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,