nodejitsu/pkgcloud — pull request #104 by indexzero (2013-04-12 05:09:43+00:00)
Title: [api refactor] Expose methods for determining if an IP address is public...

... or private.

This will be useful for anyone using a [netmask](http://www.computerhope.com/jargon/n/netmask.htm) to determine if an IP is public or private on their network.

e.g.

``` js
var pkgcloud = require('pkgcloud'),
Netmask = require('netmask').Netmask;

var masks = {
public: new Netmask('100.127/16'),
private: new Netmask('1.127/16')
};

//
// Override isPublic and isPrivate to
// conform to the netmask.
//
pkgcloud.compute.isPrivate = function (addr) {
return masks.private.contains(addr);
};

pkgcloud.compute.isPublic = function (addr) {
return masks.public.contains(addr);
};
```