"Fossies" - the Fresh Open Source Software Archive

Member "pdns-auth-4.2.0/docs/lua-records/reference/comboaddress.rst" (27 Aug 2019, 2985 Bytes) of package /linux/misc/dns/pdns-auth-4.2.0.tar.gz:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

ComboAddress objects

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.

Functions and methods of a ComboAddress

newCA(address) -> ComboAddress

Returns a new ComboAddress object based on address

param string address

The IP address, with optional port, to represent

addr = newCA("")

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:

ComboAddress:getPort() -> int

Returns the port number.

ComboAddress:isIPv4() -> bool

Returns true if the address is an IPv4, false otherwise

ComboAddress:isIPv6() -> bool

Returns true if the address is an IPv6, false otherwise

ComboAddress:isMappedIPv4() -> bool

Returns true if the address is an IPv4 mapped into an IPv6, false otherwise

ComboAddress:mapToIPv4() -> ComboAddress

Convert an IPv4 address mapped in a v6 one into an IPv4. Returns a new ComboAddress

ComboAddress:toString() -> string

Returns in human-friendly format

ComboAddress:getRaw() -> string

Returns in raw bytes format format

ComboAddress:toStringWithPort() -> string

Returns in human-friendly format, with port number


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

param int bits

Amount of bits to truncate to

ComboAddressSet objects

We provide a convenient object class that can store unique ComboAddresses in no particular order and allows fast retrieval of individual elements based on their values

addr = newCA("")
myset = newCAS()
if myset:check(addr) then -- prints "found!"

Functions and methods of a ComboAddressSet

newCAS() -> ComboAddressSet

Returns an empty ComboAddressSet object

A ComboAddressSet can store multiple ComboAddress

It has these methods:


Add the given addr to set. addr can be of the following types

param ComboAddress addr

The ComboAddress object to add to set

param string addr

Handy way to add ComboAddress from its string representation

param [string] addr

Add the given list of addresses to the set

addr = newCA("")
myset = newCAS()
myset:add({"::1/128", ""})