aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/libp2p/ignore.rs
diff options
context:
space:
mode:
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,