Checks if the IP address is IPv4.
true
if the IP address is IPv4, otherwise false
.
Checks if the IP address is IPv6.
true
if the IP address is IPv6, otherwise false
.
Serializes the IP address to a JSON-compatible format.
The IP address as a string.
Returns the IP address as a string.
The IP address.
Returns the primitive value of the IP address.
The IP address as a string.
Static
canChecks if a value can be parsed as a valid IPAddress
.
The IP address to check, either as a string or an IPAddress
instance.
true
if the IP address can be parsed, otherwise false
.
Static
fromStatic
fromExtracts an IP address from a Request
object by checking the
CF-Connecting-IP
header.
The incoming request containing headers.
A new IPAddress
instance if the IP is present in the headers, otherwise null
.
The
IPAddress
class represents an IP address, providing methods to validate, parse, and determine the version of the IP address (IPv4 or IPv6).The class supports constructing from a string or another
IPAddress
instance, as well as extracting an IP address from a request header. It also provides utility methods for checking IP version and serializing the IP address.Example