Skip to content

Commit 1c799bf

Browse files
authored
Merge pull request #20 from NoOne-dev/main
Fix/supernet CIDR calculations
2 parents 380ee21 + 83770cf commit 1c799bf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/utils/supernet-calculations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function findSupernet(networks: NetworkInput[]): { network: string; cidr: number
152152

153153
// Find the smallest CIDR that can contain all networks
154154
let supernetCidr = 32;
155-
for (let cidr = 1; cidr <= 30; cidr++) {
155+
for (let cidr = 30; cidr >= 1; cidr--) {
156156
const mask = 0xffffffff << (32 - cidr);
157157
const supernetStart = minAddress & (mask >>> 0);
158158
const supernetEnd = supernetStart + Math.pow(2, 32 - cidr) - 1;

0 commit comments

Comments
 (0)