Methods for converting to and from Address instances.

Static methods

staticall (family:IpFamily):Address

Returns the IP address representing all hosts for the given IP family.

  • For IPv4, the address is 0.0.0.0.
  • For IPv6, the address is ::.

@:value({ ipv6mapped : false })staticequals (a:Address, b:Address, ipv6mapped:Bool = false):Bool

Returns true if a and b are the same IP address.

If ipv6mapped is true, bot a and b are mapped to IPv6 (using mapToIpv6) before the comparison.

staticisIp (address:String):Bool

Returns true if address represents a valid IPv4 or IPv6 address.

staticisIpv4 (address:String):Bool

Returns true if address represents a valid IPv4 address.

staticisIpv6 (address:String):Bool

Returns true if address represents a valid IPv6 address.

staticlocalhost (family:IpFamily):Address

Returns the IP address representing the local hosts for the given IP family.

  • For IPv4, the address is 127.0.0.1.
  • For IPv6, the address is ::1.

staticmapToIpv6 (address:Address):Address

Returns the IPv6 version of the given address. IPv6 addresses are returned unmodified, IPv4 addresses are mapped to IPv6 using the :ffff:0:0/96 IPv4 transition prefix.

"127.0.0.1".toIpv4().mapToIpv6().toString(); // ::ffff:7f00:1

statictoIp (address:String):Null<Address>

Tries to convert the String address to an Address instance. Returns the parsed Address or null if address does not represent a valid IP address.

statictoIpv4 (address:String):Null<Address>

Tries to convert the String address to an IPv4 Address instance. Returns the parsed Address or null if address does not represent a valid IPv4 address.

statictoIpv6 (address:String):Null<Address>

Tries to convert the String address to an IPv6 Address instance. Returns the parsed Address or null if address does not represent a valid IPv6 address.

statictoString (address:Address):String

Converts an Address to a String.

  • IPv4 addresses are represented with the dotted quad format, e.g. 192.168.0.1.
  • IPv6 addresses are represented with the standard lowercased hexadecimal representation, with :: used to mark a long stretch of zeros.