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 object can be compared against a NetMaskGroup object with the NetMaskGroup:match function.
To compare the address (so not the port) of two ComboAddresses instances, use :equal:
a = newCA("[::1]:56")
b = newCA("[::1]:53")
a == b -- false, reference mismatch
a:toStringWithPort() == b:toStringWithPort() -- 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.
-
equal(ComboAddress):
bool¶ Compare the address to another
ComboAddressobject. The port numbers are not relevant.
-
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.
-
equal(ComboAddress):