rspamd_ip
rspamd_ip
is a helper module to simplify IP addresses manipulations.
Functions:
Function | Description |
---|---|
rspamd_ip.from_string(line) |
Create IP address from its string representation. |
Methods:
Method | Description |
---|---|
ip:to_string([pretty=false]) |
Converts valid IP address to string. |
ip:to_number() |
Converts valid IP address to number or list of numbers in case of IPv6. |
ip:to_table() |
Converts valid IP address to the table of numeric octets. |
ip:str_octets() |
Converts valid IP address to the table of string octets. |
ip:inversed_str_octets() |
Converts valid IP address to the table of string octets in reversed order. |
ip:__gc() |
Automatically destroys IP object. |
ip:get_version() |
Gets numeric version of ip address. |
ip:is_valid() |
Checks if an IP object is a valid IP address. |
ip:apply_mask(mask) |
Applies mask to IP address, resetting up to mask least significant bits to zero. |
ip:__eq(other) |
Compares two IP addresses. |
ip:copy() |
Performs deep copy of IP address. |
ip:is_local() |
Returns true if address is local one. |
ip:less_than(other) |
Returns true if address is less than other. |
The module rspamd_ip
defines the following functions.
rspamd_ip.from_string(line)
Create IP address from its string representation.
Parameters:
line {string}
: valid IP address string (either ipv4 or ipv6)Returns:
{ip}
: new ip object or nil
if input is invalidBack to module description.
The module rspamd_ip
defines the following methods.
ip:to_string([pretty=false])
Converts valid IP address to string
Parameters:
pretty {bool}
: print IP address with port and braces (for IPv6)Returns:
{string or nil}
: string representation of IP or nil
if IP is invalidBack to module description.
ip:to_number()
Converts valid IP address to number or list of numbers in case of IPv6
Parameters:
No parameters
Returns:
{integer(s) or nil}
: numeric representation of IP in host byte order or nil
if IP is invalidBack to module description.
ip:to_table()
Converts valid IP address to the table of numeric octets
Parameters:
No parameters
Returns:
{table or nil}
: numeric octets of IP address or nil
if IP is invalidBack to module description.
ip:str_octets()
Converts valid IP address to the table of string octets. The difference from
ip:to_table()
is that this method returns just hex strings for ipv6
addresses.
Parameters:
No parameters
Returns:
{table or nil}
: string octets of IP address or nil
if IP is invalidBack to module description.
ip:inversed_str_octets()
Converts valid IP address to the table of string octets in reversed order. The difference from
ip:to_table()
is that this method returns just hex strings for ipv6
addresses in reversed order.
Parameters:
No parameters
Returns:
{table or nil}
: string octets of IP address or nil
if IP is invalidBack to module description.
ip:__gc()
Automatically destroys IP object.
Parameters:
No parameters
Returns:
No return
Back to module description.
ip:get_version()
Gets numeric version of ip address
Parameters:
No parameters
Returns:
{number}
: 4
for IPv4 and 6
for IPv6Back to module description.
ip:is_valid()
Checks if an IP object is a valid IP address.
Parameters:
No parameters
Returns:
{boolean}
: true
if IP is valid and false
otherwiseBack to module description.
ip:apply_mask(mask)
Applies mask to IP address, resetting up to mask
least significant bits to zero.
Parameters:
mask {integer}
: how many bits to resetReturns:
{ip}
: new IP object with mask
bits resetBack to module description.
ip:__eq(other)
Compares two IP addresses
Parameters:
other {ip}
: IP to compareReturns:
{boolean}
: true
if two objects are the sameBack to module description.
ip:copy()
Performs deep copy of IP address.
Parameters:
No parameters
Returns:
{ip}
: a fresh copy of IP addressBack to module description.
ip:is_local()
Returns true if address is local one
Parameters:
No parameters
Returns:
{boolean}
: true
if address is localBack to module description.
ip:less_than(other)
Returns true if address is less than other
Parameters:
No parameters
Returns:
{boolean}
: no descriptionBack to module description.
Back to top.