How to use the toLong function from ip
Find comprehensive JavaScript ip.toLong code examples handpicked from public code repositorys.
GitHub: firewalla/firewalla
89 90 91 92 93 94 95 96 97 98
class SysManager { constructor() { // loglevel is already ignored if (instance == null) { log.info('Initializing SysManager') rclient.hdel("sys:network:info", "oper"); this.multicastlow = iptool.toLong("224.0.0.0"); this.multicasthigh = iptool.toLong("239.255.255.255"); this.repo = {}; this.ipIntfCache = new LRU({max: 4096, maxAge: 900 * 1000}); // reduce call to inMySubnets4/6 in getInterfaceViaIP4/6, which is CPU intensive, the cache will be flushed if network info is updated this.iptablesReady = false;
117
463
0
+ 11 other calls in file
GitHub: noobaa/noobaa-core
95 96 97 98 99 100 101 102 103 104
} return ip; } function ip_to_long(ip) { return ip_module.toLong(unwrap_ipv6(ip)); } async function retrieve_public_ip() { const IPIFY_TIMEOUT = 30 * 1000;
70
229
17
62 63 64 65 66 67 68 69 70 71
for (var i = addresses.length; i--;) { var address = addresses[i] if (address.family === 'IPv4' && !address.internal) { var subnet = ip.subnet(address.address, address.netmask) var current = ip.toLong(subnet.firstAddress) var last = ip.toLong(subnet.lastAddress) - 1 while (current++ < last) result.push(ip.fromLong(current)) } } }
25
122
0
106 107 108 109 110 111 112 113 114 115
const testRange = (ip, constraint, mode) => { const filteredSet = _.filter(getIps(), (constraint) => { if (constraint.length > 1) { const startIp = iputil.toLong(constraint[0]) const endIp = iputil.toLong(constraint[1]) const longIp = iputil.toLong(ip) return longIp >= startIp && longIp <= endIp } else { return ip === constraint[0] }
17
60
0
+ 2 other calls in file
GitHub: stagehacks/Cue-View
23 24 25 26 27 28 29 30 31 32
for (let i = addresses.length; i--; ) { const address = addresses[i]; if (address.family === 'IPv4' && !address.internal && address.address.substring(0, 3) !== '169') { let subnet = ip.subnet(address.address, address.netmask); let current = ip.toLong(subnet.firstAddress); let last = ip.toLong(subnet.lastAddress) - 1; address.searchTruncated = false; if (last - current > 2296) { subnet = ip.subnet(address.address, '255.255.248.0');
2
31
0
+ 11 other calls in file
GitHub: markzhan/ip2
28 29 30 31 32 33 34 35 36 37
console.log(ip.isPrivate(ipaddr) ? 'Private IP:' : 'IP:', ipaddr); } else if (id === 'ip') { if (ip.isPrivate(ret[0])) { console.log('Private IP:', ip.toLong(ret[0])); } else { console.log('IP2LONG: ' + ip.toLong(ret[0])); info.internetip(ret[0]); if (options.parent.chinese) { info.ipcn(ret[0]) }
1
1
2
+ 5 other calls in file
73 74 75 76 77 78 79 80 81 82
if(ip.subnet(val[1], val[2]).contains(val[0])) return true; else return false; } isMaskInSubnet(val: any): boolean { console.log(ip.toLong(val[0]), ip.toLong(ip.cidrSubnet(val[1]).subnetMask), "子网掩码", "期望子网掩码") if(ip.toLong(val[0]) == ip.toLong(ip.cidrSubnet(val[1]).subnetMask)) return true; else return false; }
1
1
1
+ 7 other calls in file
GitHub: mpangrazzi/cidr-grep
18 19 20 21 22 23 24 25 26 27
var n = objectAssign(Object.create(network), ip.cidrSubnet(cidr)); n.cidr = cidr; n.firstAddressLong = ip.toLong(n.firstAddress); n.lastAddressLong = ip.toLong(n.lastAddress); return n; };
0
9
2
+ 5 other calls in file
GitHub: smartprix/koa-request
74 75 76 77 78 79 80 81 82 83
// match range if (cidr.includes('-')) { const parts = cidr.split('-'); const ipStart = ipLib.toLong(parts[0].trim()); const ipEnd = ipLib.toLong(parts[1].trim()); ranges.push([ipStart, ipEnd]); } // match a single ip or ips like (123.156)
0
1
3
+ 7 other calls in file
25 26 27 28 29 30 31 32 33 34
var info = ip.cidrSubnet(cidr); // Add if (info) { this.ranges[cidr] = [ ip.toLong(info.firstAddress), ip.toLong(info.lastAddress) ]; } }; Matcher.prototype.removeNetworkClass = function(cidr) {
7
0
2
+ 3 other calls in file
GitHub: PetteriHellman/ipbackend1
100 101 102 103 104 105 106 107 108 109 110 111
}) //haetaan seuraava vapaa viereikkäin oleva IP-blokki const nextFreeIPBlock = (network, taken, size, role) => { const max = ip.toLong(network.hostMax) const min = ip.toLong(network.hostMin) //tarkistus, että haetaan vain 1-5 IP:tä, jos hakijana käyttäjä if (role === 'user' && (size < 1 || size > 5)) throw new Error('Invalid amount requested as ' + role)
2
0
0
GitHub: natesilva/rir-parser
100 101 102 103 104 105 106 107 108 109
var country = range.country; var curr = start; // generate individual IPs at start of range var bordermask = ip.toLong('0.0.0.255'); var endmask = ip.toLong('255.255.255.255'); var increment = 1; while (curr < ((end & endmask) >>> 0) && ((curr & bordermask) >>> 0)) { pushTarget.push(
0
1
0
+ 14 other calls in file
33 34 35 36 37 38 39 40 41 42
* @param {String} toIp * @returns {String[]} */ const getIPsWithinRange = (fromIp, toIp) => { const from = ip.toLong(fromIp) const to = ip.toLong(toIp) const IPs = [] for (let i = from; i <= to; i++) { IPs.push(ip.fromLong(i)) }
1
0
0
+ 5 other calls in file
45 46 47 48 49 50 51 52 53
var e = this.entry; if (e.lastIp) { r = ++e.lastIp; if (r >= Ip.toLong(e.dval.end)) { r = undefined; } }
1
0
0
GitHub: thdung3/wallet-sample
5 6 7 8 9 10 11 12 13 14 15 16 17
const serviceToken = process.env.SERVICE_TOKEN; const generator = new FlakeId({ // Prevent multiple servers collision id: ip.toLong(ip.address()) % 1024, }); function capTransactions(transactions, maximumAmount) { let total = new Decimal(0);
0
0
0
30 31 32 33 34 35 36 37 38 39
let cnt = 0; let list = []; networks.map(async (network) => { for(let i = ip.toLong(network.firstAddress), l = ip.toLong(network.lastAddress); i < l + 1; i++){ let address = ip.fromLong(i) if (myAddress.indexOf(address) != -1) continue; cnt++;
0
0
0
GitHub: wuzhiping/snapdrop
237 238 239 240 241 242 243 244 245 246
seed: this.id.hashCode() }) // console.dir(req.headers); let from = req.headers['client-ip'] || req.headers['x-forwarded-for'] || ""; if(from) from = ip.toLong(from) % 1000; this.name = { model: ua.device.model, os: ua.os.name,
0
0
0
+ 2 other calls in file
GitHub: atefBB/browserify-app
395 396 397 398 399 400 401 402 403 404
return ip.mask(addr, mask); }; ip.subnet = function(addr, mask) { var networkAddress = ip.toLong(ip.mask(addr, mask)); // Calculate the mask's length. var maskBuffer = ip.toBuffer(mask); var maskLength = 0;
0
0
1
+ 5 other calls in file
ip.address is the most popular function in ip (635 examples)