Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ifaces[ifname].forEach(function (iface) {
if (iface.internal !== false) {
// skip over internal (i.e. 127.0.0.1)
return;
}
//set IPv4 address
if ('IPv4' === iface.family) {
var address4 = new ipAddress.Address4(iface.address);
if (address4.isValid()) {
global.AddressIpv4 = iface.address;
global.hasAddressIpv4 = true;
}
}
//set IPv6 address
if (('IPv6' === iface.family)) {
var address6 = new ipAddress.Address6(iface.address);
//Only globally scoped IPv6 addresses can be reached externally
if(address6.isValid() && address6.getScope() === 'Global'){
global.AddressIpv6 = iface.address;
global.hasAddressIpv6 = true;
}
}
++alias;
});
});
const _ip6To4 = ip6 => new ipAddress.Address6(ip6).to4().address;
// const _ip4To6 = ip4 => '::ffff:' + ip4;
var locId
var b
var bsz
var lat
var lon
var area
var i
lines++
if (fields[0].match(/:/)) {
// IPv6
var offset = 0
bsz = 48
rngip = new Address6(fields[0])
sip = utils.aton6(rngip.startAddress().correctForm())
eip = utils.aton6(rngip.endAddress().correctForm())
locId = parseInt(fields[1], 10)
locId = cityLookup[locId]
b = Buffer.alloc(bsz)
b.fill(0)
for (i = 0; i < sip.length; i++) {
b.writeUInt32BE(sip[i], offset)
offset += 4
}
for (i = 0; i < eip.length; i++) {
b.writeUInt32BE(eip[i], offset)
offset += 4
window.AWS_RANGE_6 = j.ipv6_prefixes.map(p => {
const addr = new IpAddr.Address6(p.ipv6_prefix)
return {
addr,
region: p.region,
service: p.service
}
}).reverse()
console.log('...done IP range fetch')
public static toIPAddress(addr?: string) {
if (addr) {
if (addr.indexOf(':') >= 0) {
return new Address6(addr);
} else {
return new Address4(addr);
}
}
return undefined;
}
const search = async () => {
const ipstr = document.getElementById('ip').value
if (!ipstr.trim()) return display('')
if (!fetched) {
return display('Loading...')
}
const ip4 = new IpAddr.Address4(ipstr)
const ip6 = new IpAddr.Address6(ipstr)
if (ip4.valid) {
showResults(AWS_RANGE_4.find(p => ip4.isInSubnet(p.addr)))
} else if (ip6.valid) {
showResults(AWS_RANGE_6.find(p => ip6.isInSubnet(p.addr)))
} else {
display('Not a valid IP address')
}
document.getElementById('ip').focus()
}
const addrs = groupBy(multiaddrs, ma => {
const addr = new Address6(ma.toOptions().host)
if (addr.isLoopback()) return 'loopback'
if (addr.isLinkLocal()) return 'link-local'
return 'global'
})
network.routes.forEach(function(item) {
let ipv4 = new ipaddr.Address4(value);
let target4 = new ipaddr.Address4(item.target);
if (ipv4.isValid() && target4.isValid()) {
if (ipv4.isInSubnet(target4)) ipAddressInManagedRoute = true;
}
let ipv6 = new ipaddr.Address6(value);
let target6 = new ipaddr.Address6(item.target);
if (ipv6.isValid() && target6.isValid()) {
if (ipv6.isInSubnet(target6)) ipAddressInManagedRoute = true;
}
});
return ipAddressInManagedRoute;
function getAddressClass(addr: string): Address4 | Address6 {
const address4 = new Address4(addr);
if (address4.isValid()) {
return address4;
}
const address6 = new Address6(addr);
if (address6.isValid()) {
return address6;
}
throw new Error(`Address ${addr} is neither v4 or v6`);
}
/**
isValidIP: function(ip) {
try {
if (ip.indexOf(":") === -1) {
return new Address4(ip).isValid();
} else {
return new Address6(ip).isValid();
}
} catch (e) {
return false;
}
},