diff options
| author | tv <tv@krebsco.de> | 2026-10-31 22:05:01 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 22:05:01 +0100 |
| commit | dfd2a91578d826b5e46da7d9b141c7ff3d6c5075 (patch) | |
| tree | 2affe115978829b08351fe89b03452d7e9a2fb24 /src/transport/libp2p/ignore.rs | |
| parent | 49e12ce4cc40deeac1cc1d1c77bc15b390dc5773 (diff) | |
libp2p: don't relay through ignored
Diffstat (limited to 'src/transport/libp2p/ignore.rs')
| -rw-r--r-- | src/transport/libp2p/ignore.rs | 15 |
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 { |
