Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function ipMatch(ip1: string, ip2: string): boolean {
// check ip1
if (!(ip.isV4Format(ip1) || ip.isV6Format(ip1))) {
throw new Error('invalid argument: ip1 in ipMatch() function is not an IP address.');
}
// check ip2
const cidrParts: string[] = ip2.split('/');
if (cidrParts.length === 2) {
return ip.cidrSubnet(ip2).contains(ip1);
} else {
if (!(ip.isV4Format(ip2) || ip.isV6Format(ip2))) {
console.log(ip2);
throw new Error('invalid argument: ip2 in ipMatch() function is not an IP address.');
}
return ip.isEqual(ip1, ip2);
}
}
ssdpClient.on('response', function(headers, statusCode, rInfo) {
/* If ipAddress param is present, check if the response matches */
if (!ipAddress || ip.isEqual(rInfo.address,ipAddress)) {
clearTimeout(timeoutTimer);
ssdpClient._stop();
resolve({
headers: headers,
rInfo: rInfo
});
}
});
ssdpClient.search(serviceUrn);
ssdpClient.on('response', function(headers, statusCode, rInfo) {
/* If ipAddress param is present, check if the response matches */
if (!ipAddress || ip.isEqual(rInfo.address,ipAddress)) {
clearTimeout(timeoutTimer);
ssdpClient._stop();
deferred.resolve({
headers: headers,
rInfo: rInfo
});
}
});
ssdpClient.search(serviceUrn);
const hasV4 = !!STORE_V4.find((x) => Ip.isEqual(x, ip));
const hasV6 = !!STORE_V6.find((x) => Ip.isEqual(x, ip));
const mirrors = mirror.map(async m => {
const result = await helpers.parseAndValidateAddressString(m, consts.DEFAULT_PORT);
if((ip.isEqual(myIp, result.host) || ip.isEqual("127.0.0.1", result.host)) && myPort === result.port) {
throw new Error("Cannot mirror to self!");
}
return result;
});
return P.resolve(events.filter(function (ev) {
return ev.uid.toString('hex') === key && ip.isEqual(ev.ipAddr, addr)
}).map(function (ev) {
return {