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) → :class:`ComboAddress`

Returns a ComboAddress based on address

Parameters:address (string) – The IP address, with optional port, to represent.
class ComboAddress

A ComboAddress represents 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.

: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

:tostring() → string
:toString() → string

Returns in human-friendly format

:tostringWithPort() → string
:toStringWithPort() → string

Returns in human-friendly format, with port number

:truncate(bits)

Truncate the ComboAddress to the specified number of bits. This essentially zeroes all bits after bits.

Parameters:bits (int) – Amount of bits to truncate to