https://github.com/eviltik/cidr-clean
Merge CIDRs list, cleanup, and handle overlaps
https://github.com/eviltik/cidr-clean
cidr
Last synced: over 1 year ago
JSON representation
Merge CIDRs list, cleanup, and handle overlaps
- Host: GitHub
- URL: https://github.com/eviltik/cidr-clean
- Owner: eviltik
- License: mit
- Created: 2017-10-31T00:36:24.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T19:54:21.000Z (over 3 years ago)
- Last Synced: 2024-10-15T11:01:11.755Z (almost 2 years ago)
- Topics: cidr
- Language: JavaScript
- Homepage:
- Size: 519 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cidr-clean
-----------

[](https://badge.fury.io/js/cidr-clean)
[](https://opensource.org/licenses/mit-license.php)
[](https://david-dm.org/eviltik/cidr-clean)
What for ?
----------
Clean an array of CIDR
* remove duplicates
* remove comments
* remove bad CIDRs
* remove extra spaces
* choose the heaviest network in case of overlap
Installation
------------
```
$ npm install cidr-clean
```
Usage
-----
```
const cidrClean = require('cidr-clean');
let list = [
'#mycomment',
'10.1.2.0/23',
'110.1.3.248/30',
'1.2.3.4/10'
];
console.log(cidrClean(list));
# output: ['10.1.2.0/23', '110.1.3.248/30', '1.2.3.4/10'];
# note, you can cidrClean(list1, list2) for merging 2 cidr lists
```
Todo
----
* optional callback with all events (remove, overlap)