aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/libp2p/ignore.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 22:05:01 +0100
committertv <tv@krebsco.de>2026-10-31 22:05:01 +0100
commit4e98b4ce361b98fdb2f7f4a89e57a99060dab9f8 (patch)
treec1239f1e4fbc2330eeadb9e4278138a920fd0140 /src/transport/libp2p/ignore.rs
parentb331dba289f372938b11b3cb3c8ca37ff46a47a8 (diff)
libp2p: don't relay through ignored
Diffstat (limited to 'src/transport/libp2p/ignore.rs')
-rw-r--r--src/transport/libp2p/ignore.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/transport/libp2p/ignore.rs b/src/transport/libp2p/ignore.rs
index 51e1f45..ab59a3e 100644
--- a/src/transport/libp2p/ignore.rs
+++ b/src/transport/libp2p/ignore.rs
@@ -78,6 +78,21 @@ pub(super) fn ignored(ranges: &[IpRange], address: &Multiaddr) -> bool {
ranges.iter().any(|range| range.contains(ip))
}
+/// Whether `address` can only be reached over a range of `ranges`: a direct address
+/// there, or one through a relay whose own address is there (dialling the relay is
+/// refused, `Ignoring`). For what's kept and dialled; connections are judged by
+/// `ignored`.
+pub(super) fn left_out(ranges: &[IpRange], address: &Multiaddr) -> bool {
+ if !is_relayed(address) {
+ return ignored(ranges, address);
+ }
+ let relay: Multiaddr = address
+ .iter()
+ .take_while(|protocol| !matches!(protocol, Protocol::P2pCircuit))
+ .collect();
+ ignored(ranges, &without_peer(relay))
+}
+
/// Keeps connections off the address ranges `libp2p-ignore` names, whoever dialled:
/// hole punching and identify bring addresses there too, and a peer may dial us there.
pub(super) struct Ignoring {