diff options
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 { |
