Check whether or not an hostname refer to a private IP
npm install hostname-is-private
> Check whether or not an hostname refers to a private IP
``shell`
npm install hostname-is-private
#### isPrivate(hostname: {String}, f: (err : {Error,Null}, isPrivate: {Boolean}))
`javascript
var isPrivate = require('hostname-is-private').isPrivate;
isPrivate('127.0.0.1.xip.io', function(err, isPrivate){
console.log(err === null, isPrivate == true);
});
isPrivate('localhost', function(err, isPrivate){
console.log(err === null, isPrivate === true);
});
isPrivate('google.com', function(err, isPrivate){
console.log(err === null, isPrivate === false);
});
`
#### isPrivateIncludingPublicIp(hostname: {String}, f: (err : {Error,Null}, isPrivateIncludingPublicIp: {Boolean}))
`javascript
var isPrivateIncludingPublicIp = require('hostname-is-private').isPrivateIncludingPublicIp;
isPrivateIncludingPublicIp('YOUR-PUBLIC-IP.xip.io', function(err, isPrivate){
console.log(err === null, isPrivate == true);
});
isPrivate('localhost', function(err, isPrivate){
console.log(err === null, isPrivate === true);
});
isPrivate('google.com', function(err, isPrivate){
console.log(err === null, isPrivate === false);
});
``
It uses dns.lookup underneath and ip.isPrivate to check if the resolved IP is private (or not).