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
commit53d132ff902ff07198b0e01f8c1a030f06aa562b (patch)
tree3c964e657a3044438295fe85f4e3c50f1a3acab5 /src/transport/libp2p/ignore.rs
parent400c4e845998101b94780b101a400c04d38897da (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,