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.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/transport/libp2p/ignore.rs b/src/transport/libp2p/ignore.rs
index 659ec91..51e1f45 100644
--- a/src/transport/libp2p/ignore.rs
+++ b/src/transport/libp2p/ignore.rs
@@ -37,6 +37,13 @@ impl FromStr for IpRange {
}
impl IpRange {
+ /// Whether every address of `other` is in this range too.
+ pub(super) fn covers(&self, other: &IpRange) -> bool {
+ self.network.is_ipv4() == other.network.is_ipv4()
+ && self.prefix <= other.prefix
+ && self.contains(other.network)
+ }
+
pub(super) fn contains(&self, ip: std::net::IpAddr) -> bool {
use std::net::IpAddr;
match (self.network, ip) {