Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validator.ipRanges = function(ipRanges) {
var rangeCheck = require('range_check')
,i , current
,invalidIps = []
;
for (i = 0; i < ipRanges.length; i++) {
current = ipRanges[i].split('/');
if ( !rangeCheck.valid_ip(current[0]) ) {
invalidIps.push('"'+current[0]+'"');
}
if ( current[1] && (current[1] < 17 || current[1] > 32) ) {
invalidIps.push('"/'+ current[1]+'"');
}
}
return invalidIps.length ? new Error('Invalid IPs/ranges: '+ invalidIps.join(', ')) : true;
};