ip-address
- Version 10.2.0
- Published
- 270 kB
- No dependencies
- MIT license
Install
npm i ip-addressyarn add ip-addresspnpm add ip-addressOverview
A library for parsing IPv4 and IPv6 IP addresses in node and the browser.
Index
Variables
Classes
Address4
- address
- addressMinusSuffix
- bigInt()
- binaryZeroPad()
- correctForm()
- endAddress()
- endAddressExclusive()
- fromAddressAndMask()
- fromAddressAndWildcardMask()
- fromArpa()
- fromBigInt()
- fromByteArray()
- fromHex()
- fromInteger()
- fromUnsignedByteArray()
- fromWildcard()
- getBitsBase2()
- groupForV6()
- groups
- isBroadcast()
- isCGNAT()
- isCorrect
- isInSubnet
- isLinkLocal()
- isLoopback()
- isMulticast()
- isPrivate()
- isUnspecified()
- isValid()
- mask()
- networkForm()
- parse()
- parsedAddress
- parsedSubnet
- reverseForm()
- startAddress()
- startAddressExclusive()
- subnet
- subnetMask
- subnetMaskAddress()
- toArray()
- toGroup6()
- toHex()
- v4
- wildcardMask()
Address6
- address
- address4
- addressMinusSuffix
- bigInt()
- binaryZeroPad()
- canonicalForm()
- correctForm()
- decimal()
- elidedGroups
- elisionBegin
- elisionEnd
- endAddress()
- endAddressExclusive()
- fromAddress4()
- fromAddress4Nat64()
- fromAddressAndMask()
- fromAddressAndWildcardMask()
- fromArpa()
- fromBigInt()
- fromByteArray()
- fromUnsignedByteArray()
- fromURL()
- fromWildcard()
- getBits()
- getBitsBase16()
- getBitsBase2()
- getBitsPastSubnet()
- getScope()
- getType()
- group()
- groups
- href()
- inspect6to4()
- inspectTeredo()
- is4()
- is6to4()
- isCanonical()
- isCorrect
- isDocumentation()
- isInSubnet
- isLinkLocal()
- isLoopback()
- isMapped4()
- isMulticast()
- isTeredo()
- isULA()
- isUnspecified()
- isValid()
- link()
- mask()
- microsoftTranscription()
- networkForm()
- parse()
- parse4in6()
- parsedAddress
- parsedAddress4
- parsedSubnet
- possibleSubnets()
- regularExpression()
- regularExpressionString()
- reverseForm()
- startAddress()
- startAddressExclusive()
- subnet
- subnetMask
- subnetMaskAddress()
- to4()
- to4in6()
- to6to4()
- toAddress4Nat64()
- toByteArray()
- toUnsignedByteArray()
- v4
- wildcardMask()
- zone
Variables
variable v6
const v6: { helpers: typeof helpers };Classes
class Address4
class Address4 {}Represents an IPv4 address
Parameter address
An IPv4 address string
constructor
constructor(address: string);property address
address: string;property addressMinusSuffix
addressMinusSuffix?: string;property groups
groups: number;property isCorrect
isCorrect: (this: Address4 | import('./ipv6').Address6) => boolean;Returns true if the address is correct, false otherwise
Returns
{Boolean}
property isInSubnet
isInSubnet: (this: Address4 | Address6, address: Address4 | Address6) => boolean;Returns true if the given address is in the subnet of the current address
Returns
{boolean}
property parsedAddress
parsedAddress: string[];property parsedSubnet
parsedSubnet: string;property subnet
subnet: string;property subnetMask
subnetMask: number;property v4
v4: boolean;method bigInt
bigInt: () => bigint;Returns the address as a
bigintReturns
{bigint}
method binaryZeroPad
binaryZeroPad: () => string;Returns a zero-padded base-2 string representation of the address
Returns
{string}
method correctForm
correctForm: () => string;Returns the address in correct form: octets joined with
.and any leading zeros stripped (e.g.192.168.1.1). For IPv4 this matches the canonical dotted-decimal representation.
method endAddress
endAddress: () => Address4;The last address in the range given by this address' subnet Often referred to as the Broadcast
Returns
{Address4}
method endAddressExclusive
endAddressExclusive: () => Address4;The last host address in the range given by this address's subnet ie the last address prior to the Broadcast Address
Returns
{Address4}
method fromAddressAndMask
static fromAddressAndMask: (address: string, mask: string) => Address4;Construct an
Address4from an address and a dotted-decimal subnet mask given as separate strings (e.g. as returned by Node'sos.networkInterfaces()). ThrowsAddressErrorif the mask is non-contiguous (e.g.255.0.255.0).Example 1
var address = Address4.fromAddressAndMask('192.168.1.1', '255.255.255.0'); address.subnetMask; // 24
method fromAddressAndWildcardMask
static fromAddressAndWildcardMask: ( address: string, wildcardMask: string) => Address4;Construct an
Address4from an address and a Cisco-style wildcard mask given as separate strings (e.g.0.0.0.255for a/24). The wildcard mask is the bitwise inverse of the subnet mask. ThrowsAddressErrorif the mask is non-contiguous (e.g.0.255.0.255).Example 1
var address = Address4.fromAddressAndWildcardMask('10.0.0.1', '0.0.0.255'); address.subnetMask; // 24
method fromArpa
static fromArpa: (arpaFormAddress: string) => Address4;Return an address from in-addr.arpa form
Parameter arpaFormAddress
an 'in-addr.arpa' form ipv4 address
Returns
{Adress4}
Example 1
var address = Address4.fromArpa(42.2.0.192.in-addr.arpa.) address.correctForm(); // '192.0.2.42'
method fromBigInt
static fromBigInt: (bigInt: bigint) => Address4;Converts a BigInt to a v4 address object. The value must be in the range
[0, 2**32 - 1]; otherwiseAddressErroris thrown.Parameter bigInt
a BigInt to convert
Returns
{Address4}
method fromByteArray
static fromByteArray: (bytes: Array<number>) => Address4;Convert a byte array to an Address4 object.
To convert from a Node.js
Buffer, spread it:Address4.fromByteArray([...buf]).Parameter bytes
an array of 4 bytes (0-255)
Returns
{Address4}
method fromHex
static fromHex: (hex: string) => Address4;Converts a hex string to an IPv4 address object. Accepts 8 hex digits with optional
:separators (e.g.'7f000001'or'7f:00:00:01'). ThrowsAddressErrorfor any other length or for non-hex characters.Parameter hex
a hex string to convert
Returns
{Address4}
method fromInteger
static fromInteger: (integer: number) => Address4;Converts an integer into a IPv4 address object. The integer must be a non-negative safe integer in the range
[0, 2**32 - 1]; otherwiseAddressErroris thrown.Parameter integer
a number to convert
Returns
{Address4}
method fromUnsignedByteArray
static fromUnsignedByteArray: (bytes: Array<number>) => Address4;Convert an unsigned byte array to an Address4 object
Parameter bytes
an array of 4 unsigned bytes (0-255)
Returns
{Address4}
method fromWildcard
static fromWildcard: (input: string) => Address4;Construct an
Address4from a wildcard pattern with trailing*octets. The number of trailing wildcards determines the prefix length: each*represents 8 bits.Only trailing whole-octet wildcards are supported. Partial-octet wildcards (e.g.
192.168.0.1*) and interior wildcards (e.g.192.*.0.1) throwAddressError.Example 1
Address4.fromWildcard('192.168.0.*').subnet; // '/24' Address4.fromWildcard('192.168.*.*').subnet; // '/16' Address4.fromWildcard('*.*.*.*').subnet; // '/0'
method getBitsBase2
getBitsBase2: (start: number, end: number) => string;Returns the bits in the given range as a base-2 string
Returns
{string}
method groupForV6
groupForV6: () => string;Groups an IPv4 address for inclusion at the end of an IPv6 address
Returns
{String}
method isBroadcast
isBroadcast: () => boolean;Returns true if the address is the limited broadcast address
255.255.255.255([RFC 919](https://datatracker.ietf.org/doc/html/rfc919)).Returns
{boolean}
method isCGNAT
isCGNAT: () => boolean;Returns true if the address is in the carrier-grade NAT range
100.64.0.0/10([RFC 6598](https://datatracker.ietf.org/doc/html/rfc6598)).Returns
{boolean}
method isLinkLocal
isLinkLocal: () => boolean;Returns true if the address is in the link-local range
169.254.0.0/16([RFC 3927](https://datatracker.ietf.org/doc/html/rfc3927)).Returns
{boolean}
method isLoopback
isLoopback: () => boolean;Returns true if the address is in the loopback range
127.0.0.0/8([RFC 1122](https://datatracker.ietf.org/doc/html/rfc1122)).Returns
{boolean}
method isMulticast
isMulticast: () => boolean;Returns true if the given address is a multicast address
Returns
{boolean}
method isPrivate
isPrivate: () => boolean;Returns true if the address is in one of the [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) private address ranges (
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16).Returns
{boolean}
method isUnspecified
isUnspecified: () => boolean;Returns true if the address is the unspecified address
0.0.0.0.Returns
{boolean}
method isValid
static isValid: (address: string) => boolean;Returns true if the given string is a valid IPv4 address (with optional CIDR subnet), false otherwise. Host bits in the subnet portion are allowed (e.g.
192.168.1.5/24is valid); for strict network-address validation comparecorrectForm()tostartAddress().correctForm(), or usenetworkForm().
method mask
mask: (mask?: number) => string;Returns the first n bits of the address, defaulting to the subnet mask
Returns
{String}
method networkForm
networkForm: () => string;The network address in CIDR string form, e.g.
192.168.1.0/24for192.168.1.5/24. For an address with no explicit subnet the prefix is/32, e.g.networkForm()on192.168.1.5returns192.168.1.5/32.Returns
{string}
method parse
parse: (address: string) => string[];Parses an IPv4 address string into its four octet groups and stores the result on
this.parsedAddress. Called automatically by the constructor; you typically don't need to call it directly. ThrowsAddressErrorif the input is not a valid IPv4 address.
method reverseForm
reverseForm: (options?: common.ReverseFormOptions) => string;Return the reversed ip6.arpa form of the address
Parameter options
Parameter
{boolean} options.omitSuffix - omit the "in-addr.arpa" suffix
Returns
{String}
method startAddress
startAddress: () => Address4;The first address in the range given by this address' subnet. Often referred to as the Network Address.
Returns
{Address4}
method startAddressExclusive
startAddressExclusive: () => Address4;The first host address in the range given by this address's subnet ie the first address after the Network Address
Returns
{Address4}
method subnetMaskAddress
subnetMaskAddress: () => Address4;The dotted-decimal form of the subnet mask, e.g.
255.255.240.0for a/20. Returns anAddress4; call.correctForm()for the string.Returns
{Address4}
method toArray
toArray: () => number[];Converts an IPv4 address object to an array of bytes.
To get a Node.js
Buffer, wrap the result:Buffer.from(address.toArray()).Returns
{Array}
method toGroup6
toGroup6: () => string;Converts an IPv4 address object to an IPv6 address group
Returns
{String}
method toHex
toHex: () => string;Converts an IPv4 address object to a hex string
Returns
{String}
method wildcardMask
wildcardMask: () => Address4;The Cisco-style wildcard mask, e.g.
0.0.0.255for a/24. This is the bitwise inverse ofsubnetMaskAddress(). Returns anAddress4; call.correctForm()for the string.Returns
{Address4}
class Address6
class Address6 {}Represents an IPv6 address
Parameter address
An IPv6 address string
Parameter groups
How many octets to parse
Example 1
var address = new Address6('2001::/32');
constructor
constructor(address: string, optionalGroups?: number);property address
address: string;property address4
address4?: Address4;property addressMinusSuffix
addressMinusSuffix: string;property elidedGroups
elidedGroups?: number;property elisionBegin
elisionBegin?: number;property elisionEnd
elisionEnd?: number;property groups
groups: number;property isCorrect
isCorrect: (this: Address4 | Address6) => boolean;Returns true if the address is correct, false otherwise
Returns
{boolean}
property isInSubnet
isInSubnet: (this: Address4 | Address6, address: Address4 | Address6) => boolean;Returns true if the given address is in the subnet of the current address
Returns
{boolean}
property parsedAddress
parsedAddress: string[];property parsedAddress4
parsedAddress4?: string;property parsedSubnet
parsedSubnet: string;property subnet
subnet: string;property subnetMask
subnetMask: number;property v4
v4: boolean;property zone
zone: string;method bigInt
bigInt: () => bigint;Return the address as a BigInt
Returns
{bigint}
method binaryZeroPad
binaryZeroPad: () => string;Return a zero-padded base-2 string representation of the address
Returns
{String}
Example 1
var address = new Address6('2001:4860:4001:803::1011'); address.binaryZeroPad(); // '0010000000000001010010000110000001000000000000010000100000000011 // 0000000000000000000000000000000000000000000000000001000000010001'
method canonicalForm
canonicalForm: () => string;Returns the canonical (fully expanded) form of the address: all 8 groups, each padded to 4 hex digits, with no
::collapsing (e.g.2001:0db8:0000:0000:0000:0000:0000:0001). Useful for sorting and byte-exact comparison.
method correctForm
correctForm: () => string;Returns the address in correct form, per [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952): leading zeros stripped, the longest run of zero groups collapsed to
::, and hex digits lowercased (e.g.2001:db8::1). This is the recommended form for display.
method decimal
decimal: () => string;Return the decimal form of the address
Returns
{String}
method endAddress
endAddress: () => Address6;The last address in the range given by this address' subnet Often referred to as the Broadcast
Returns
{Address6}
method endAddressExclusive
endAddressExclusive: () => Address6;The last host address in the range given by this address's subnet ie the last address prior to the Broadcast Address
Returns
{Address6}
method fromAddress4
static fromAddress4: (address: string) => Address6;Create an IPv6-mapped address given an IPv4 address
Parameter address
An IPv4 address string
Returns
{Address6}
Example 1
var address = Address6.fromAddress4('192.168.0.1'); address.correctForm(); // '::ffff:c0a8:1' address.to4in6(); // '::ffff:192.168.0.1'
method fromAddress4Nat64
static fromAddress4Nat64: (address: string, prefix?: string) => Address6;Embed an IPv4 address into a NAT64 IPv6 address using the encoding defined by [RFC 6052](https://datatracker.ietf.org/doc/html/rfc6052). The default prefix is the well-known prefix
64:ff9b::/96. The prefix length must be one of 32, 40, 48, 56, 64, or 96; for prefixes shorter than /64 the IPv4 octets are split around the reserved bits 64–71.Example 1
Address6.fromAddress4Nat64('192.0.2.33').correctForm(); // '64:ff9b::c000:221' Address6.fromAddress4Nat64('192.0.2.33', '2001:db8::/32').correctForm(); // '2001:db8:c000:221::'
method fromAddressAndMask
static fromAddressAndMask: (address: string, mask: string) => Address6;Construct an
Address6from an address and a hex subnet mask given as separate strings (e.g. as returned by Node'sos.networkInterfaces()). ThrowsAddressErrorif the mask is non-contiguous (e.g.ffff::ffff).Example 1
var address = Address6.fromAddressAndMask('fe80::1', 'ffff:ffff:ffff:ffff::'); address.subnetMask; // 64
method fromAddressAndWildcardMask
static fromAddressAndWildcardMask: ( address: string, wildcardMask: string) => Address6;Construct an
Address6from an address and a Cisco-style wildcard mask given as separate strings (e.g.::ffff:ffff:ffff:fffffor a/64). The wildcard mask is the bitwise inverse of the subnet mask. ThrowsAddressErrorif the mask is non-contiguous.Example 1
var address = Address6.fromAddressAndWildcardMask('fe80::1', '::ffff:ffff:ffff:ffff'); address.subnetMask; // 64
method fromArpa
static fromArpa: (arpaFormAddress: string) => Address6;Return an address from ip6.arpa form
Parameter arpaFormAddress
an 'ip6.arpa' form address
Returns
{Adress6}
Example 1
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'
method fromBigInt
static fromBigInt: (bigInt: bigint) => Address6;Convert a BigInt to a v6 address object. The value must be in the range
[0, 2**128 - 1]; otherwiseAddressErroris thrown.Parameter bigInt
a BigInt to convert
Returns
{Address6}
Example 1
var bigInt = BigInt('1000000000000'); var address = Address6.fromBigInt(bigInt); address.correctForm(); // '::e8:d4a5:1000'
method fromByteArray
static fromByteArray: (bytes: Array<any>) => Address6;Convert a byte array to an Address6 object.
To convert from a Node.js
Buffer, spread it:Address6.fromByteArray([...buf]).Returns
{Address6}
method fromUnsignedByteArray
static fromUnsignedByteArray: (bytes: Array<any>) => Address6;Convert an unsigned byte array to an Address6 object.
To convert from a Node.js
Buffer, spread it:Address6.fromUnsignedByteArray([...buf]).Returns
{Address6}
method fromURL
static fromURL: ( url: string) => | { error: string; address: null; port: null } | { address: Address6; port: number | null; error?: undefined };Parse a URL (with optional bracketed host and port) into an address and port. Returns either
{ address, port }on success or{ error, address: null, port: null }if the URL could not be parsed. Ports are returned as numbers (ornullif absent or out of range).Example 1
var addressAndPort = Address6.fromURL('http://[ffff::]:8080/foo/'); addressAndPort.address.correctForm(); // 'ffff::' addressAndPort.port; // 8080
method fromWildcard
static fromWildcard: (input: string) => Address6;Construct an
Address6from a wildcard pattern with trailing*groups. The number of trailing wildcards determines the prefix length: each*represents 16 bits.::is expanded to zero groups (not wildcards) before evaluating trailing wildcards.Only trailing whole-group wildcards are supported. Partial-group wildcards (e.g.
2001:db8::0*) and interior wildcards (e.g.*::1) throwAddressError.Example 1
Address6.fromWildcard('2001:db8:*:*:*:*:*:*').subnet; // '/32' Address6.fromWildcard('2001:db8::*').subnet; // '/112' Address6.fromWildcard('*:*:*:*:*:*:*:*').subnet; // '/0'
method getBits
getBits: (start: number, end: number) => bigint;Return the bits in the given range as a BigInt
Returns
{bigint}
method getBitsBase16
getBitsBase16: (start: number, end: number) => string;Return the bits in the given range as a base-16 string
Returns
{String}
method getBitsBase2
getBitsBase2: (start: number, end: number) => string;Return the bits in the given range as a base-2 string
Returns
{String}
method getBitsPastSubnet
getBitsPastSubnet: () => string;Return the bits that are set past the subnet mask length
Returns
{String}
method getScope
getScope: () => string;Return the scope of the address. The 4-bit scope field ([RFC 4291 §2.7](https://datatracker.ietf.org/doc/html/rfc4291#section-2.7)) is only defined for multicast addresses; for unicast addresses the scope is derived from the address type per [RFC 4007 §6](https://datatracker.ietf.org/doc/html/rfc4007#section-6).
Returns
{String}
method getType
getType: () => string;Return the type of the address
Returns
{String}
method group
group: () => string;Groups an address
Returns
{String}
method href
href: (optionalPort?: number | string) => string;Returns the address as an HTTP URL with the host bracketed, e.g.
http://[2001:db8::1]/. IfoptionalPortis provided it is appended, e.g.http://[2001:db8::1]:8080/.
method inspect6to4
inspect6to4: () => SixToFourProperties;Decodes the 6to4 tunneling fields embedded in this address. Returns the 6to4 prefix and the embedded IPv4 gateway address. Only meaningful for addresses in
2002::/16.
method inspectTeredo
inspectTeredo: () => TeredoProperties;Decodes the Teredo tunneling fields embedded in this address. Returns the Teredo prefix, server IPv4, client IPv4, raw flag bits, cone-NAT flag, UDP port, and Microsoft-format flag breakdown (reserved, universal/local, group/individual, nonce). Only meaningful for addresses in
2001::/32.
method is4
is4: () => boolean;Returns true if the address was written in v4-in-v6 dotted-quad notation (e.g.
::ffff:127.0.0.1), false otherwise. This is a notation-level flag and does not reflect whether the address bits lie in the IPv4-mapped (::ffff:0:0/96) subnet — for that, see isMapped4.Returns
{boolean}
method is6to4
is6to4: () => boolean;Returns true if the address is a 6to4 address, false otherwise
Returns
{boolean}
method isCanonical
isCanonical: () => boolean;Returns true if the address is in the canonical form, false otherwise
Returns
{boolean}
method isDocumentation
isDocumentation: () => boolean;Returns true if the address is in the documentation prefix
2001:db8::/32([RFC 3849](https://datatracker.ietf.org/doc/html/rfc3849)).Returns
{boolean}
method isLinkLocal
isLinkLocal: () => boolean;Returns true if the address is a link local address, false otherwise
Returns
{boolean}
method isLoopback
isLoopback: () => boolean;Returns true if the address is a loopback address, false otherwise
Returns
{boolean}
method isMapped4
isMapped4: () => boolean;Returns true if the address is an IPv4-mapped IPv6 address in
::ffff:0:0/96([RFC 4291 §2.5.5.2](https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.2)), false otherwise. Unlike is4, this checks the underlying address bits rather than the textual notation, so::ffff:127.0.0.1and::ffff:7f00:1both return true.Returns
{boolean}
method isMulticast
isMulticast: () => boolean;Returns true if the address is a multicast address, false otherwise
Returns
{boolean}
method isTeredo
isTeredo: () => boolean;Returns true if the address is a Teredo address, false otherwise
Returns
{boolean}
method isULA
isULA: () => boolean;Returns true if the address is a Unique Local Address in
fc00::/7([RFC 4193](https://datatracker.ietf.org/doc/html/rfc4193)). ULAs are the IPv6 equivalent of IPv4 [RFC 1918](https://datatracker.ietf.org/doc/html/rfc1918) private addresses.Returns
{boolean}
method isUnspecified
isUnspecified: () => boolean;Returns true if the address is the unspecified address
::.Returns
{boolean}
method isValid
static isValid: (address: string) => boolean;Returns true if the given string is a valid IPv6 address (with optional CIDR subnet and zone identifier), false otherwise. Host bits in the subnet portion are allowed (e.g.
2001:db8::1/32is valid); for strict network-address validation comparecorrectForm()tostartAddress().correctForm(), or usenetworkForm().
method link
link: (options?: { className?: string; prefix?: string; v4?: boolean;}) => string;Returns an HTML
<a>element whosehrefencodes the address in a URL hash fragment (default prefix/#address=). Useful for linking between pages of an address-inspector UI.Parameter
options.className - CSS class for the rendered
<a>elementParameter
options.prefix - hash prefix prepended to the address (default
/#address=)Parameter
options.v4 - when true, render the address in v4-in-v6 form
method mask
mask: (mask?: number) => string;Return the first n bits of the address, defaulting to the subnet mask
Parameter mask
the number of bits to mask
Returns
{String} the first n bits of the address as a string
method microsoftTranscription
microsoftTranscription: () => string;Return the Microsoft UNC transcription of the address
Returns
{String} the Microsoft UNC transcription of the address
method networkForm
networkForm: () => string;The network address in CIDR string form, e.g.
2001:db8::/32for2001:db8::1/32. For an address with no explicit subnet the prefix is/128, e.g.networkForm()on2001:db8::1returns2001:db8::1/128.Returns
{string}
method parse
parse: (address: string) => string[];Parses an IPv6 address string into its 8 hexadecimal groups (expanding any
::elision and any trailing v4-in-v6 portion) and stores the result onthis.parsedAddress. Called automatically by the constructor; you typically don't need to call it directly. ThrowsAddressErrorif the input is malformed.
method parse4in6
parse4in6: (address: string) => string;Parses a v4-in-v6 string (e.g.
::ffff:192.168.0.1) by extracting the trailing IPv4 address intothis.address4/this.parsedAddress4and returning the address with the v4 portion converted to two v6 groups. Used internally byparse().
method possibleSubnets
possibleSubnets: (subnetSize?: number) => string;Return the number of possible subnets of a given size in the address
Parameter subnetSize
the subnet size
Returns
{String}
method regularExpression
regularExpression: (this: Address6, substringSearch?: boolean) => RegExp;Generate a regular expression that can be used to find or validate all variations of this address.
Parameter substringSearch
Returns
{RegExp}
method regularExpressionString
regularExpressionString: (this: Address6, substringSearch?: boolean) => string;Generate a regular expression string that can be used to find or validate all variations of this address
Parameter substringSearch
Returns
{string}
method reverseForm
reverseForm: (options?: common.ReverseFormOptions) => string;Return the reversed ip6.arpa form of the address
Parameter options
Parameter
{boolean} options.omitSuffix - omit the "ip6.arpa" suffix
Returns
{String}
method startAddress
startAddress: () => Address6;The first address in the range given by this address' subnet Often referred to as the Network Address.
Returns
{Address6}
method startAddressExclusive
startAddressExclusive: () => Address6;The first host address in the range given by this address's subnet ie the first address after the Network Address
Returns
{Address6}
method subnetMaskAddress
subnetMaskAddress: () => Address6;The hex form of the subnet mask, e.g.
ffff:ffff:ffff:ffff::for a/64. Returns anAddress6; call.correctForm()for the string.Returns
{Address6}
method to4
to4: () => Address4;Return the last two groups of this address as an IPv4 address string
Returns
{Address4}
Example 1
var address = new Address6('2001:4860:4001::1825:bf11'); address.to4().correctForm(); // '24.37.191.17'
method to4in6
to4in6: () => string;Return the v4-in-v6 form of the address
Returns
{String}
method to6to4
to6to4: () => Address6 | null;Return a v6 6to4 address from a v6 v4inv6 address
Returns
{Address6}
method toAddress4Nat64
toAddress4Nat64: (prefix?: string) => Address4 | null;Extract the embedded IPv4 address from a NAT64 IPv6 address using the encoding defined by [RFC 6052](https://datatracker.ietf.org/doc/html/rfc6052). The default prefix is the well-known prefix
64:ff9b::/96. Returnsnullif this address is not contained within the given prefix.Example 1
new Address6('64:ff9b::c000:221').toAddress4Nat64()!.correctForm(); // '192.0.2.33'
method toByteArray
toByteArray: () => number[];Return a byte array.
To get a Node.js
Buffer, wrap the result:Buffer.from(address.toByteArray()).Returns
{Array}
method toUnsignedByteArray
toUnsignedByteArray: () => number[];Return an unsigned byte array.
To get a Node.js
Buffer, wrap the result:Buffer.from(address.toUnsignedByteArray()).Returns
{Array}
method wildcardMask
wildcardMask: () => Address6;The Cisco-style wildcard mask, e.g.
::ffff:ffff:ffff:fffffor a/64. This is the bitwise inverse ofsubnetMaskAddress(). Returns anAddress6; call.correctForm()for the string.Returns
{Address6}
class AddressError
class AddressError extends Error {}constructor
constructor(message: string, parseMessage?: string);property parseMessage
parseMessage?: string;Package Files (4)
Dependencies (0)
No dependencies.
Dev Dependencies (22)
- @types/chai
- @types/mocha
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- c8
- chai
- eslint
- eslint_d
- eslint-config-airbnb
- eslint-config-prettier
- eslint-plugin-filenames
- eslint-plugin-import
- eslint-plugin-jsx-a11y
- eslint-plugin-prettier
- eslint-plugin-sort-imports-es6-autofix
- mocha
- monocart-coverage-reports
- prettier
- source-map-support
- tsx
- typedoc
- typescript
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ip-address.
- Markdown[](https://www.jsdocs.io/package/ip-address)
- HTML<a href="https://www.jsdocs.io/package/ip-address"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4521 ms. - Missing or incorrect documentation? Open an issue for this package.
