The ComboAddress class

IP addresses are moved around in a native format, called ComboAddress within PowerDNS. ComboAddresses can be IPv4 or IPv6, and unless you want to know, you don’t need to.

Make a ComboAddress with:

newCA("::1")

A ComboAddress can be compared against a NetmaskGroup with the NetMaskGroup:match() function.

To compare the address (so not the port) of two ComboAddresses, use :equal:

a = newCA("[::1]:56")
b = newCA("[::1]:53")
a == b     -- false, port mismatch
a:equal(b) -- true

To convert an address to human-friendly representation, use :toString or :toStringWithPort. To get only the port number, use :getPort().

newCA(address) → ComboAddress

Creates a ComboAddress.

Parameters:address (string) – The address to convert
class ComboAddress

An object representing an IP address and port tuple.

:getPort() → int

The portnumber.

:getRaw() → str

A bytestring representing the address.

:isIPv4() → bool

True if the address is an IPv4 address.

:isIPv6() → bool

True if the address is an IPv6 address.

:isMappedIPv4() → bool

True if the address is an IPv4 address mapped into an IPv6 one.

:mapToIPv4() → ComboAddress

If the address is an IPv4 mapped into an IPv6 one, return the corresponding IPv4 ComboAddress.

:toString() → str

Returns the IP address without the port number as a string.

:toStringWithPort() → str

Returns the IP address with the port number as a string.

:truncate(bits)

Truncate to the supplied number of bits

Parameters:bits (int) – The number of bits to truncate to