util.net
Prosody provides an API for handling IP addresses.
Using
Reference
net.local_addresses(type, link_local)
Returns a table of the available local addresses.
The type parameter can be either "ipv4", "ipv6" or "both", and defaults to "both" if not provided.
The link_local boolean parameter additionally returns addresses specific to the local area, which won’t be routed globally.
Example:
net.pton(address)
Converts an IP address from its string representation to the network- order byte representation.
For instance "127.0.0.1" will return "\x7f\x00\x00\x01".
net.ntop(address)
Converts an IP address from its network-order byte representation to the string representation.
For instance "\x7f\x00\x00\x01" will return "127.0.0.1".