How to use the isPrivate function from ip
Find comprehensive JavaScript ip.isPrivate code examples handpicked from public code repositorys.
GitHub: firewalla/firewalla
122 123 124 125 126 127 128 129 130 131
const host = obj.host; const uri = obj.uri; let localIP = null; let flowDirection = null; if (iptool.isPrivate(srcIP) && iptool.isPrivate(destIP)) return; let intf = sysManager.getInterfaceViaIP(srcIP); if (intf) {
117
463
0
GitHub: firewalla/firewalla
315 316 317 318 319 320 321 322 323 324
if (obj["qtype_name"] === "PTR") { // reverse DNS query, the IP address is in the query parameter, the domain is in the answers if (obj["query"].endsWith(".in-addr.arpa")) { // ipv4 reverse DNS query const address = obj["query"].substring(0, obj["query"].length - ".in-addr.arpa".length).split('.').reverse().join('.'); if (!address || !iptool.isV4Format(address) || iptool.isPrivate(address)) return; const domains = obj["answers"].filter(answer => !firewalla.isReservedBlockingIP(answer) && !iptool.isV4Format(answer) && !iptool.isV6Format(answer) && isDomainValid(answer)).map(answer => formulateHostname(answer)); if (domains.length == 0) return;
117
463
0
41 42 43 44 45 46 47 48 49 50
}).then(response => { return res.json( { publicIp: response.data.ip, privateIp: ip.address(), isPrivate: ip.isPrivate(response.data.ip) }); }).catch(err => { console.log(err)
4
19
0
46 47 48 49 50 51 52 53 54 55
isIPMask(val: any): boolean { const reg = /^(((128|192|224|240|248|252|254)\.0\.0\.0)|(255\.(0|128|192|224|240|248|252|254)\.0\.0)|(255\.255\.(0|128|192|224|240|248|252|254)\.0)|(255\.255\.255\.(0|128|192|224|240|248|252|254)))$/ return reg.test(val); } //console.log("127.0.0.1 is private network?", ip.isPrivate('127.0.0.1')); //let str = ip.cidrSubnet('192.168.1.134/26'); //console.log(str) isCIDR(val: any): boolean { let str = val.split('/');
1
1
1
44 45 46 47 48 49 50 51 52 53 54
* Tests if input is an IP address is a private ip address. * @param {string} ip * @returns {boolean} */ ipDash.isPrivateIP = function (ip) { return nodeIp.isPrivate(ip); }; /** * Tests if input is an IP address is a public ip address.
0
1
0
GitHub: Orloxx23/TaplyDesktop
200 201 202 203 204 205 206 207 208 209 210 211
// We get the user's IP function getUserIp() { const ethernetIp = osIp.networkInterfaces()['Ethernet']; const wifiIp = osIp.networkInterfaces()['Wi-Fi']; if (wifiIp && ip.isPrivate(wifiIp[1].address)) { userIp = wifiIp[1].address; } if (ethernetIp && ip.isPrivate(ethernetIp[1].address)) {
0
1
0
12 13 14 15 16 17 18 19 20 21 22 23
// // ### function isPrivate (addr) // Determines if an IP address is private. // exports.isPrivate = ip.isPrivate; // // ### function isPublic (addr) // Determines if an IP address is public.
0
0
0
GitHub: haozero99/Internet-limit
43 44 45 46 47 48 49 50 51 52
if (options.trustedHeaderSequence instanceof Array) { trustedHeaderSequence = options.trustedHeaderSequence.map(c => c.toLowerCase()); } function checkWhitelist(ipToCheck) { return options.whitelist.has(ipToCheck) || (options.allowPrivate && ip.isPrivate(ipToCheck)); } function checkBlacklist(ipToCheck) { return !options.blacklist.has(ipToCheck);
0
0
0
ip.address is the most popular function in ip (635 examples)