Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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;
}
function getBaseIp(addr, prefixLength) {
return ip.mask(addr, ip.fromPrefixLen(prefixLength));
}
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
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