Skip to content

Commit

Permalink
fix for some missing ipv6 prefixes (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
massimocandela committed Nov 15, 2020
1 parent 5e215c4 commit 87e029f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "./build.sh",
"compile": "babel src -d dist",
"release": "dotenv release-it",
"serve": "babel-node index.js",
"serve": "babel-node src/index.js",
"inspect": "node --inspect --require @babel/register index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down Expand Up @@ -46,7 +46,7 @@
"dependencies": {
"axios": "^0.20.0",
"batch-promises": "0.0.3",
"bulk-whois-parser": "^1.0.7",
"bulk-whois-parser": "^1.0.8",
"cli-progress": "^3.8.2",
"ip-address": "^6.4.0",
"ip-sub": "^1.0.14",
Expand Down
2 changes: 1 addition & 1 deletion src/csvParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const checkPrefix = (prefix) => {
prefix += (ipUtils.getAddressFamily(prefix) === 4) ? "/32" : "/128";
}

return prefix;
return (ipUtils.isValidPrefix(prefix)) ? prefix.toLowerCase() : null;
};

class Geofeed {
Expand Down
13 changes: 6 additions & 7 deletions src/finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,10 @@ export default class Finder {

validateGeofeeds = (geofeeds) => {
return geofeeds
.filter(geofeed =>
geofeed &&
!!geofeed.inetnum && geofeed.inetnum === geofeed.prefix ||
ipUtils.isSubnet(geofeed.inetnum, geofeed.prefix)
);
.filter(geofeed => {
return geofeed && !!geofeed.inetnum && !!geofeed.prefix &&
(geofeed.inetnum === geofeed.prefix || ipUtils.isSubnet(geofeed.inetnum, geofeed.prefix));
});

};

Expand Down Expand Up @@ -173,9 +172,9 @@ export default class Finder {
// If there is a less specific inetnum contradicting a more specific inetnum
// Contradicting here means, the less specific is declaring something in the more specific range
if (lessSpecificInetnum.valid &&
(moreSpecificInetnumPrefix === lessSpecificInetnumPrefix || ipUtils.isSubnet(lessSpecificInetnumPrefix, moreSpecificInetnumPrefix))) {
(moreSpecificInetnumPrefix === lessSpecificInetnumPrefix ||
ipUtils.isSubnet(moreSpecificInetnumPrefix, lessSpecificInetnumPrefix))) {
lessSpecificInetnum.valid = false;
// console.log(`WARNING: prefix:${moreSpecificInetnumPrefix} declared in inetnum:${moreSpecificInetnum.inetnum} conflicts with prefix:${lessSpecificInetnumPrefix} declared in inetnum:${lessSpecificInetnum.inetnum}`);
}
}

Expand Down

0 comments on commit 87e029f

Please sign in to comment.