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
commit661deff21ebddaa3a94fafea99f7d8cfaae790dc (patch)
tree1bf3c3f2c7c609f19fb24fa55d3b739690f49d7f /src/transport/libp2p/ignore.rs
parentf2cfe1f9e033c6d514e8335d8fb82ba925339c58 (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 {