Filter a list of IPv4 addresses based on a list of exclusion IPs or addresses containing wildcards.
filterIps(['1.2.3.4', '1.2.3.5', '1.2.4.5'], '1.2.3.*') => ['1.2.4.5']
$ npm install --save filter-ips
const filterIps = require('filter-ips');
const ips = ['1.2.3.4', '1.2.3.5', '1.2.3.6', '1.2.3.7'];
const exclusions = ['1.2.3.4', '1.2.3.6'];
filterIps(ips, exclusions);
//=> ['1.2.3.5', '1.2.3.7'];
const filterIps = require('filter-ips');
const ips = [
'1.2.3.4',
'240.230.29.1',
'240.230.29.2',
'255.255.255.255',
'255.255.255.254'
];
const exclusions = ['1.2.3.4', '255.*.*.*'];
filterIps(ips, exclusions);
//=> ['240.230.29.1', '240.230.29.2'];
Returns a new array of filtered ips
Type: <array>[<string>]
A list of IPv4 addresses.
Type: <array>[<string>]
| <string>
A list of exclusions to be omitted from the list of IPs entered. Exclusion items can be a specific address or address containing wildcards.
ip-class - 🔠 Return the classful network class (A, B, C, D, E) of an IPv4 address
MIT © Brandon Him