ComboAddress¶
IP addresses are moved around in a native format, called a ComboAddress.
ComboAddresses can be IPv4 or IPv6, and unless you want to know, you don’t need to.
- 
newCA(address) → ComboAddress¶
- Returns a - ComboAddressbased on- address- Parameters: - address (string) – The IP address, with optional port, to represent. 
- 
newCAFromRaw(rawaddress[, port]) → ComboAddress¶
- Returns a new - ComboAddressobject based on the 4- or 16-octet string. For example,- newCAFromRaw('ABCD')makes a- ComboAddressobject holding the IP- 65.66.67.68, because those are the ASCII values for those four letters.- Parameters: - rawaddress (string) – The IPv4 of IPv6 address as a 4/16 octet string
- port (int) – The optional port number
 
- 
class ComboAddress¶
- A - ComboAddressrepresents an IP address with possibly a port number. The object can be an IPv4 or an IPv6 address. It has these methods:- 
:getPort() → int¶
- Returns the port number. 
 - 
:ipdecrypt(key) → ComboAddress¶
- Decrypt this IP address as described in https://powerdns.org/ipcipher - Parameters: - key (string) – A 16 byte key. Note that this can be derived from a passphrase with the standalone function makeIPCipherKey 
 - 
:ipencrypt(key) → ComboAddress¶
- Encrypt this IP address as described in https://powerdns.org/ipcipher - Parameters: - key (string) – A 16 byte key. Note that this can be derived from a passphrase with the standalone function makeIPCipherKey 
 - 
:isIPv4() → bool¶
- Returns true if the address is an IPv4, false otherwise 
 - 
:isIPv6() → bool¶
- Returns true if the address is an IPv6, false otherwise 
 - 
:isMappedIPv4() → bool¶
- Returns true if the address is an IPv4 mapped into an IPv6, false otherwise 
 - 
:mapToIPv4() → ComboAddress¶
- Convert an IPv4 address mapped in a v6 one into an IPv4. Returns a new - ComboAddress
 - 
:getRaw() → string¶
- Returns in raw bytes format 
 - 
:tostringWithPort() → string¶
- 
:toStringWithPort() → string¶
- Returns in human-friendly format, with port number 
 - 
:truncate(bits)¶
- Truncate the - ComboAddressto the specified number of bits. This essentially zeroes all bits after- bits.- Parameters: - bits (int) – Amount of bits to truncate to 
 
- 
