cidr-tools
Advanced tools
Comparing version 2.1.2 to 2.2.0
22
index.js
@@ -310,7 +310,21 @@ "use strict"; | ||
cidrTools.overlap = (a, b) => { | ||
a = parse(a); | ||
b = parse(b); | ||
const aNets = uniq(Array.isArray(a) ? a : [a]); | ||
const bNets = uniq(Array.isArray(b) ? b : [b]); | ||
if (a.address.v4 !== b.address.v4) return false; | ||
return overlap(a, b); | ||
for (let a of aNets) { | ||
for (let b of bNets) { | ||
a = parse(a); | ||
b = parse(b); | ||
if (a.address.v4 !== b.address.v4) { | ||
continue; | ||
} | ||
if (overlap(a, b)) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
}; |
{ | ||
"name": "cidr-tools", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"author": "silverwind <me@silverwind.io>", | ||
@@ -5,0 +5,0 @@ "description": "Tools to work with IPv4 and IPv6 CIDR network lists", |
@@ -49,6 +49,6 @@ # cidr-tools | ||
- `networkA` *String*: A CIDR or IP address. | ||
- `networkB` *String*: A CIDR or IP address. | ||
- `networksA` *String* or *Array*: One or more CIDR or IP address. | ||
- `networksB` *String* or *Array*: One or more CIDR or IP address. | ||
Returns a boolean that indicates if the networks overlap (intersect) each other. | ||
Returns a boolean that indicates if the networks A overlap (intersect) with networks B. | ||
@@ -55,0 +55,0 @@ ### cidrTools.normalize(network) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12534
271