Skip to content

Providing function to check ip validation and convert CIDR notation to IP ranges. also allowing for single ips to be converted to long and back again

Notifications You must be signed in to change notification settings

markwillis82/ipFunctions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipFunctions

Providing functionality to check ip validation and convert CIDR notation to IP ranges. also allowing for single ips to be converted to long and back again.

Build Status

example

var cidr = require('./lib/cidr');

console.log('ip2long: 127.0.0.1 -> ' +cidr.ip2long('127.0.0.1'));
console.log('long2ip: 2130706433 -> ' +cidr.long2ip(2130706433));
console.log('incorrect IP: ' +cidr.ip2long('test'));

var range = cidr.cidrToRange('127.0.0.1/16');
console.log('CIDR Range: 127.0.0.1/16 -> ' + range[0] + ' :: ' + range[1]);

functions

ip2long(); // convert ip String to Number (returns false if invalid)
long2ip(); // convert ip Number to String (returns false if invalid)
cidrToRange(); // convert CIDR range to 2 item array (lowest IP and highest IP) (returns false if invalid)
checkIp(); // check if IP string is valid
checkCIDR(); // check if CIDR string is valid

install

With npm

npm install -g ipFunctions

license

MIT

About

Providing function to check ip validation and convert CIDR notation to IP ranges. also allowing for single ips to be converted to long and back again

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published