How to use the ip-address.Address6 function in ip-address

To help you get started, we’ve selected a few ip-address 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 Comcast / Speed-testJS / modules / domain.js View on Github external
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;
      });
    });
github exokitxr / zeo / lib / hub.js View on Github external
  const _ip6To4 = ip6 => new ipAddress.Address6(ip6).to4().address;
  // const _ip4To6 = ip4 => '::ffff:' + ip4;
github berty / berty / client / react-native / tools / dashboard / node-geoip / scripts / updatedb.js View on Github external
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
github thameera / awsip / entry.js View on Github external
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')
github OpenNMS / opennms-js / src / internal / Util.ts View on Github external
public static toIPAddress(addr?: string) {
    if (addr) {
      if (addr.indexOf(':') >= 0) {
        return new Address6(addr);
      } else {
        return new Address4(addr);
      }
    }
    return undefined;
  }
github thameera / awsip / entry.js View on Github external
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()
}
github validitylabs / hopr / src / network / natTraversal / base / udp6.js View on Github external
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'
        })
github key-networks / ztncui / src / controllers / networkController.js View on Github external
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;
github RiseVision / rise-node / packages / core-utils / src / checkIpInList.ts View on Github external
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`);
}
/**
github nttgin / BGPalerter / src / ipUtils.js View on Github external
isValidIP: function(ip) {

        try {
            if (ip.indexOf(":") === -1) {
                return new Address4(ip).isValid();
            } else {
                return new Address6(ip).isValid();
            }
        } catch (e) {
            return false;
        }
    },

ip-address

A library for parsing IPv4 and IPv6 IP addresses in node and the browser.

MIT
Latest version published 7 months ago

Package Health Score

84 / 100
Full package analysis