cidr-tools
Advanced tools
Comparing version 2.2.1 to 2.2.2
25
index.js
@@ -148,6 +148,6 @@ "use strict"; | ||
if (size.equals(biggest)) return [part]; | ||
let start, end; | ||
if (part.start.remainder(biggest).equals(zero)) { | ||
if (size.equals(biggest) && part.start.add(size).compareTo(part.end) === 0) { | ||
return [part]; | ||
} else if (part.start.remainder(biggest).equals(zero)) { | ||
// start is matching on the size-defined boundary - ex: 0-12, use 0-8 | ||
@@ -159,8 +159,15 @@ start = part.start; | ||
start = part.end.divide(biggest).multiply(biggest); | ||
end = start.add(biggest).subtract(one); | ||
if (start.add(biggest).subtract(one).compareTo(part.end) > 0) { | ||
// divide will floor to nearest integer | ||
end = start.add(biggest.divide(two)).subtract(one); | ||
} else { | ||
end = start.add(biggest).subtract(one); | ||
} | ||
} | ||
if (end.compareTo(part.end) > 0) process.exit(); | ||
let parts = [{start, end}]; | ||
// // additional subnets on left side | ||
// additional subnets on left side | ||
if (!start.equals(part.start)) { | ||
@@ -300,8 +307,10 @@ parts = parts.concat(subparts({start: part.start, end: start.subtract(one)})); | ||
for (const exclcidr of excls[v]) { | ||
const excl = parse(exclcidr); | ||
for (const [index, basecidr] of bases[v].entries()) { | ||
const base = parse(basecidr); | ||
const excl = parse(exclcidr); | ||
const remainders = exclude(base, excl, v); | ||
bases[v] = bases[v].concat(remainders); | ||
bases[v].splice(index, 1); | ||
if (base.toString() !== remainders.toString()) { | ||
bases[v] = bases[v].concat(remainders); | ||
bases[v].splice(index, 1); | ||
} | ||
} | ||
@@ -308,0 +317,0 @@ } |
{ | ||
"name": "cidr-tools", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"author": "silverwind <me@silverwind.io>", | ||
@@ -5,0 +5,0 @@ "description": "Tools to work with IPv4 and IPv6 CIDR network lists", |
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
13249
290