How to use the ip.mask function in ip

To help you get started, we’ve selected a few ip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-red / node-red-nodes / hardware / wemo / WeMoNG.js View on Github external
}
            else {
                //new

                var ipAddr;
                //device.ip
                var interfaces = os.networkInterfaces();
                var interfaceNames = Object.keys(interfaces);
                for (var name in interfaceNames) {
                    if (interfaceNames.hasOwnProperty(name)) {
                        var addrs = interfaces[interfaceNames[name]];
                        for (var add in addrs) {
                            if (addrs[add].netmask) {
                                //node 0.12 or better
                                if (!addrs[add].internal && addrs[add].family == 'IPv4') {
                                    if (ip.isEqual(ip.mask(addrs[add].address,addrs[add].netmask),ip.mask(device.ip,addrs[add].netmask))) {
                                        ipAddr = addrs[add].address;
                                        break;
                                    }
                                }
                            }
                            else {
                                //node 0.10 not great but best we can do
                                if (!addrs[add].internal && addrs[add].family == 'IPv4') {
                                    ipAddr = addrs[add].address;
                                    break;
                                }
                            }
                        }
                        if (ipAddr) {
                            break;
                        }
github mozilla / fxa / packages / fxa-customs-server / lib / ip_blocklist.js View on Github external
function getBaseIp(addr, prefixLength) {
    return ip.mask(addr, ip.fromPrefixLen(prefixLength));
  }
github oeuillot / upnpserver / lib / ssdp.js View on Github external
SsdpServer.prototype.findHostBySubnet = function(peer){

  var mask = ['255.255.255.0','255.255.0.0','255.0.0.0'];

  var len = this.ips.length;

  for (var i=0; i < 3; i++){

    var submask    = mask[i];
    var maskedPeer = ip.mask(peer, submask)

    for (var j=0; j
github oeuillot / upnpserver / lib / ssdp.js View on Github external
SsdpServer.prototype.findHostBySubnet = function(peer){

  var mask = ['255.255.255.0','255.255.0.0','255.0.0.0'];

  var len = this.ips.length;

  for (var i=0; i < 3; i++){

    var submask    = mask[i];
    var maskedPeer = ip.mask(peer, submask)

    for (var j=0; j