Skip to content

Commit

Permalink
Do not normalize cidr
Browse files Browse the repository at this point in the history
  • Loading branch information
lohfu committed Jun 28, 2023
1 parent 01503ae commit 91befa9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {networkInterfaces} from 'node:os';
import {gateway4async, gateway4sync, gateway6async, gateway6sync} from 'default-gateway';
import {contains, normalize} from 'cidr-tools';
import {contains} from 'cidr-tools';

function findIp({gateway}) {
// Look for the matching interface in all local interfaces
for (const addresses of Object.values(networkInterfaces())) {
for (const {cidr} of addresses) {
if (contains(cidr, gateway)) {
return normalize(cidr).split('/')[0];
return cidr.split('/')[0];
}
}
}
Expand Down

0 comments on commit 91befa9

Please sign in to comment.