How to use the ip.isEqual 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 casbin / node-casbin / src / util / builtinOperators.ts View on Github external
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);
  }
}
github dalhundal / sky-plus-hd / lib / sky-plus-hd_finder.js View on Github external
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);
github dalhundal / sky-plus-hd / lib / sky-plus-hd-new.js View on Github external
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);
github sqreen / tor-test / lib / store.js View on Github external
        const hasV4 = !!STORE_V4.find((x) => Ip.isEqual(x, ip));
        const hasV6 = !!STORE_V6.find((x) => Ip.isEqual(x, ip));
github Unity-Technologies / unity-cache-server / lib / unity_cache_server.js View on Github external
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;
        });
github mozilla / fxa-auth-db-mysql / lib / db / mem.js View on Github external
return P.resolve(events.filter(function (ev) {
      return ev.uid.toString('hex') === key && ip.isEqual(ev.ipAddr, addr)
    }).map(function (ev) {
      return {