How to use the ip-address.v6.Address 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 GothAck / javascript-x-server / src / x_protocol.js View on Github external
constructor(idStr, sendData) {
    this.id = idStr;
    this.idBuf = new EndianBuffer(idStr);
    var host_type = this.idBuf.readUInt8(18);
    if (host_type === 4) {
      this.host_type = 'Internet';
      this.host = Array.apply(null, new Array(4))
        .map(function (v, i) {
          console.log(i)
          return this.idBuf.readUInt8(i);
        }, this)
        .join('.');
    } else {
      this.host_type = 'InternetV6';
      this.host = (new v6.Address(
          Array.apply(null, new Array(8))
            .map(function (v, i) {
              return this.idBuf.readUInt16(i * 2)
            }, this)
            .join(':')
      )).correctForm()
    }
    this.port = this.idBuf.readUInt16(16);
    this.idLog = this.host_type + '[' + this.host + ']' + this.port
    this.sendData = sendData;
    this.endian = false;
    this.state = 0;
    this.sequence = 1;
  }
  end() {
github PaddeK / node-maxmind-db / lib / IPAddress.js View on Github external
exports.parseIPv6 = function parseIPv6(ip) {
    var v6Address = new IPv6.Address(ip);
    if (!v6Address.isValid()) {
        throw new Error("Invalid IPv6 address");
    }
    return v6Address.parsedAddress;
};

ip-address

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

MIT
Latest version published 1 month ago

Package Health Score

85 / 100
Full package analysis