Address4(address)

Represents an IPv4 address

Parameters

  • string address :

    An IPv4 address string

Static members

.fromBigInteger(bigInteger)

Converts a BigInteger to a v4 address object

fromBigInteger(bigInteger)

Converts a BigInteger to a v4 address object

Parameters

  • BigInteger bigInteger :

    a BigInteger to convert

Returns

Address4
.fromHex(hex)

Converts a hex string to an IPv4 address object

fromHex(hex)

Converts a hex string to an IPv4 address object

Parameters

  • string hex :

    a hex string to convert

Returns

Address4
.fromInteger(integer)

Converts an integer into a IPv4 address object

fromInteger(integer)

Converts an integer into a IPv4 address object

Parameters

  • integer integer :

    a number to convert

Returns

Address4

Instance members

#bigInteger

Returns the address as a BigInteger

bigInteger

Returns the address as a BigInteger

Returns

BigInteger
#binaryZeroPad

Returns a zero-padded base-2 string representation of the address

binaryZeroPad

Returns a zero-padded base-2 string representation of the address

Returns

string
#correctForm

Returns the correct form of an address

correctForm

Returns the correct form of an address

Returns

String
#endAddress

The last address in the range given by this address' subnet Often referred to as the Broadcast

endAddress

The last address in the range given by this address' subnet Often referred to as the Broadcast

Returns

Address4
#getBitsBase2(start, end)

Returns the bits in the given range as a base-2 string

getBitsBase2(start, end)

Returns the bits in the given range as a base-2 string

Parameters

  • start :
  • end :

Returns

string
#isCorrect

Returns true if the address is correct, false otherwise

isCorrect

Returns true if the address is correct, false otherwise

Returns

Boolean
#isInSubnet

Returns true if the given address is in the subnet of the current address

isInSubnet

Returns true if the given address is in the subnet of the current address

Returns

boolean
#isValid

Return true if the address is valid

isValid

Return true if the address is valid

Returns

Boolean
#mask(optionalMask)

Returns the first n bits of the address, defaulting to the subnet mask

mask(optionalMask)

Returns the first n bits of the address, defaulting to the subnet mask

Parameters

  • optionalMask :

Returns

String
#startAddress

The first address in the range given by this address' subnet. Often referred to as the Network Address.

startAddress

The first address in the range given by this address' subnet. Often referred to as the Network Address.

Returns

Address4
#toArray

Converts an IPv4 address object to an array of bytes

toArray

Converts an IPv4 address object to an array of bytes

Returns

Array
#toGroup6

Converts an IPv4 address object to an IPv6 address group

toGroup6

Converts an IPv4 address object to an IPv6 address group

Returns

String
#toHex

Converts an IPv4 address object to a hex string

toHex

Converts an IPv4 address object to a hex string

Returns

String

Address6(address, [groups], optionalGroups)

Represents an IPv6 address

Parameters

  • string address :

    An IPv6 address string

  • [number] groups (default 8) :

    How many octets to parse

  • optionalGroups :

Examples

var address = new Address6('2001::/32');

Static members

.RE_BAD_ADDRESS

A regular expression that matches an incorrect IPv6 address

RE_BAD_ADDRESS

A regular expression that matches an incorrect IPv6 address

.RE_BAD_CHARACTERS

A regular expression that matches bad characters in an IPv6 address

RE_BAD_CHARACTERS

A regular expression that matches bad characters in an IPv6 address

.RE_SUBNET_STRING

A regular expression that matches an IPv6 subnet

RE_SUBNET_STRING

A regular expression that matches an IPv6 subnet

.RE_ZONE_STRING

A regular expression that matches an IPv6 zone

RE_ZONE_STRING

A regular expression that matches an IPv6 zone

.fromAddress4(address, address4)

Create an IPv6-mapped address given an IPv4 address

fromAddress4(address, address4)

Create an IPv6-mapped address given an IPv4 address

Parameters

  • string address :

    An IPv4 address string

  • address4 :

Returns

Address6

Examples

var address = Address6.fromAddress4('192.168.0.1');
            address.correctForm(); // '::ffff:c0a8:1'
            address.to4in6(); // '::ffff:192.168.0.1'
.fromBigInteger(bigInteger)

Convert a BigInteger to a v6 address object

fromBigInteger(bigInteger)

Convert a BigInteger to a v6 address object

Parameters

  • BigInteger bigInteger :

    a BigInteger to convert

Returns

Address6

Examples

var bigInteger = new BigInteger('1000000000000');
            var address = Address6.fromBigInteger(bigInteger);
            address.correctForm(); // '::e8:d4a5:1000'
.fromByteArray(bytes)

Convert a byte array to an Address6 object

fromByteArray(bytes)

Convert a byte array to an Address6 object

Parameters

  • bytes :

Returns

Address6
.fromURL(url)

Convert a URL (with optional port number) to an address object

fromURL(url)

Convert a URL (with optional port number) to an address object

Parameters

  • string url :

    a URL with optional port number

Returns

Address6

Examples

var addressAndPort = Address6.fromURL('http://[ffff::]:8080/foo/');
            addressAndPort.address.correctForm(); // 'ffff::'
            addressAndPort.port; // 8080
.fromUnsignedByteArray(bytes)

Convert an unsigned byte array to an Address6 object

fromUnsignedByteArray(bytes)

Convert an unsigned byte array to an Address6 object

Parameters

  • bytes :

Returns

Address6
.fromArpa(ip6.arpa)

Convert an ip6.arpa address to an Address6 object

fromArpa(ip6.arpa)

Convert an ip6.arpa address to an Address6 object

Parameters

Returns

Address6

Examples

var address= Address6.fromArpa('e.f.f.f.3.c.2.6.f.f.f.e.6.6.8.e.1.0.6.7.9.4.e.c.0.0.0.0.1.0.0.2.ip6.arpa.');
                address.correctForm(); // '2001:0:ce49:7601:e866:efff:62c3:fffe'
              

Instance members

#bigInteger

Return the address as a BigInteger

bigInteger

Return the address as a BigInteger

Returns

BigInteger
#binaryZeroPad

Return a zero-padded base-2 string representation of the address

binaryZeroPad

Return a zero-padded base-2 string representation of the address

Returns

String

Examples

var address = new Address6('2001:4860:4001:803::1011');
            address.binaryZeroPad();
            // '0010000000000001010010000110000001000000000000010000100000000011
            //  0000000000000000000000000000000000000000000000000001000000010001'
#canonicalForm

Return the canonical form of the address

canonicalForm

Return the canonical form of the address

Returns

String
#correctForm

Return the correct form of the address

correctForm

Return the correct form of the address

Returns

String
#decimal

Return the decimal form of the address

decimal

Return the decimal form of the address

Returns

String
#endAddress

The last address in the range given by this address' subnet

endAddress

The last address in the range given by this address' subnet

Returns

Address6
#getBits(start, end)

Return the bits in the given range as a BigInteger

getBits(start, end)

Return the bits in the given range as a BigInteger

Parameters

  • start :
  • end :

Returns

BigInteger
#getBitsBase16(start, end)

Return the bits in the given range as a base-16 string

getBitsBase16(start, end)

Return the bits in the given range as a base-16 string

Parameters

  • start :
  • end :

Returns

String
#getBitsBase2(start, end)

Return the bits in the given range as a base-2 string

getBitsBase2(start, end)

Return the bits in the given range as a base-2 string

Parameters

  • start :
  • end :

Returns

String
#getBitsPastSubnet

Return the bits that are set past the subnet mask length

getBitsPastSubnet

Return the bits that are set past the subnet mask length

Returns

String
#getScope

Return the scope of the address

getScope

Return the scope of the address

Returns

String
#getType

Return the type of the address

getType

Return the type of the address

Returns

String
#inspect6to4

Return an object containing the 6to4 properties of the address

inspect6to4

Return an object containing the 6to4 properties of the address

Returns

Object
#inspectTeredo

Return an object containing the Teredo properties of the address

inspectTeredo

Return an object containing the Teredo properties of the address

Returns

Object
#is4

Returns true if the address is a v4-in-v6 address, false otherwise

is4

Returns true if the address is a v4-in-v6 address, false otherwise

Returns

boolean
#is6to4

Returns true if the address is a 6to4 address, false otherwise

is6to4

Returns true if the address is a 6to4 address, false otherwise

Returns

boolean
#isCanonical

Returns true if the address is in the canonical form, false otherwise

isCanonical

Returns true if the address is in the canonical form, false otherwise

Returns

boolean
#isCorrect

Returns true if the address is correct, false otherwise

isCorrect

Returns true if the address is correct, false otherwise

Returns

boolean
#isInSubnet

Returns true if the given address is in the subnet of the current address

isInSubnet

Returns true if the given address is in the subnet of the current address

Returns

boolean
#isLinkLocal

Returns true if the address is a link local address, false otherwise

isLinkLocal

Returns true if the address is a link local address, false otherwise

Returns

boolean
#isLoopback

Returns true if the address is a loopback address, false otherwise

isLoopback

Returns true if the address is a loopback address, false otherwise

Returns

boolean
#isMulticast

Returns true if the address is a multicast address, false otherwise

isMulticast

Returns true if the address is a multicast address, false otherwise

Returns

boolean
#isTeredo

Returns true if the address is a Teredo address, false otherwise

isTeredo

Returns true if the address is a Teredo address, false otherwise

Returns

boolean
#isValid

Returns true if the address is valid, false otherwise

isValid

Returns true if the address is valid, false otherwise

Returns

boolean
#mask([mask], optionalMask)

Return the first n bits of the address, defaulting to the subnet mask

mask([mask], optionalMask)

Return the first n bits of the address, defaulting to the subnet mask

Parameters

  • [number] mask (default subnet) :

    the number of bits to mask

  • optionalMask :

Returns

String :

the first n bits of the address as a string

#microsoftTranscription

Return the Microsoft UNC transcription of the address

microsoftTranscription

Return the Microsoft UNC transcription of the address

Returns

String :

the Microsoft UNC transcription of the address

#possibleSubnets([size], optionalSubnetSize)

Return the number of possible subnets of a given size in the address

possibleSubnets([size], optionalSubnetSize)

Return the number of possible subnets of a given size in the address

Parameters

  • [number] size (default 128) :

    the subnet size

  • optionalSubnetSize :

Returns

String
#regularExpression(optionalSubString, optionalSubstring)

Generate a regular expression that can be used to find or validate all variations of this address.

regularExpression(optionalSubString, optionalSubstring)

Generate a regular expression that can be used to find or validate all variations of this address.

Parameters

  • string optionalSubString :
  • optionalSubstring :

Returns

RegExp
#regularExpressionString(optionalSubString)

Generate a regular expression string that can be used to find or validate all variations of this address

regularExpressionString(optionalSubString)

Generate a regular expression string that can be used to find or validate all variations of this address

Parameters

Returns

string
#reverseForm(options)

Return the reversed ip6.arpa form of the address

reverseForm(options)

Return the reversed ip6.arpa form of the address

Parameters

  • Object options :
    • boolean options.omitSuffix

      omit the "ip6.arpa" suffix

Returns

String
#startAddress

The first address in the range given by this address' subnet

startAddress

The first address in the range given by this address' subnet

Returns

Address6
#to4

Return the last two groups of this address as an IPv4 address string

to4

Return the last two groups of this address as an IPv4 address string

Returns

String

Examples

var address = new Address6('2001:4860:4001::1825:bf11');
            address.to4(); // '24.37.191.17'
#to4in6

Return the v4-in-v6 form of the address

to4in6

Return the v4-in-v6 form of the address

Returns

String
#to6to4

Return a v6 6to4 address from a v6 v4inv6 address

to6to4

Return a v6 6to4 address from a v6 v4inv6 address

Returns

Address6
#toByteArray

Return a byte array

toByteArray

Return a byte array

Returns

Array
#toUnsignedByteArray

Return an unsigned byte array

toUnsignedByteArray

Return an unsigned byte array

Returns

Array

group

Groups an address

Returns

String

href(optionalPort)

Parameters

  • optionalPort :

Returns

String :

the address in link form with a default port of 80

Parameters

  • options :

Returns

String :

a link suitable for conveying the address via a URL hash

simpleGroup(addressString, offset)

Groups an address

Parameters

  • addressString :
  • offset :

Returns

String :

a grouped address

spanAll(s, optionalOffset)

Parameters

  • s :
  • optionalOffset :

Returns

String :

the string with each character contained in a

spanLeadingZeroes(address)

Parameters

  • address :

Returns

String :

the string with leading zeroes contained in a

spanAllZeroes(s)

Parameters

  • s :

Returns

String :

the string with all zeroes contained in a