Class: Hosts

LuCI.Network.Hosts

The LuCI.Network.Hosts class encapsulates host information aggregated from multiple sources and provides convenience functions to access the host information by different criteria.

Methods

getHostnameByIP6Addr(ipaddr) → {null|string}

Lookup the hostname associated with the given IPv6 address.

Parameters:
Name Type Description
ipaddr string

The IPv6 address to lookup.

Source:
Returns:

Returns the hostname associated with the given IPv6 or null if no matching host could be found or if no hostname is known for the corresponding host.

Type
null | string

getHostnameByIPAddr(ipaddr) → {null|string}

Lookup the hostname associated with the given IPv4 address.

Parameters:
Name Type Description
ipaddr string

The IPv4 address to lookup.

Source:
Returns:

Returns the hostname associated with the given IPv4 or null if no matching host could be found or if no hostname is known for the corresponding host.

Type
null | string

getHostnameByMACAddr(mac) → {null|string}

Lookup the hostname associated with the given MAC address.

Parameters:
Name Type Description
mac string

The MAC address to lookup.

Source:
Returns:

Returns the hostname associated with the given MAC or null if no matching host could be found or if no hostname is known for the corresponding host.

Type
null | string

getIP6AddrByMACAddr(mac) → {null|string}

Lookup the IPv6 address associated with the given MAC address.

Parameters:
Name Type Description
mac string

The MAC address to lookup.

Source:
Returns:

Returns the IPv6 address associated with the given MAC or null if no matching host could be found or if no IPv6 address is known for the corresponding host.

Type
null | string

getIPAddrByMACAddr(mac) → {null|string}

Lookup the IPv4 address associated with the given MAC address.

Parameters:
Name Type Description
mac string

The MAC address to lookup.

Source:
Returns:

Returns the IPv4 address associated with the given MAC or null if no matching host could be found or if no IPv4 address is known for the corresponding host.

Type
null | string

getMACAddrByIP6Addr(ipaddr) → {null|string}

Lookup the MAC address associated with the given IPv6 address.

Parameters:
Name Type Description
ipaddr string

The IPv6 address to lookup.

Source:
Returns:

Returns the MAC address associated with the given IPv6 or null if no matching host could be found or if no MAC address is known for the corresponding host.

Type
null | string

getMACAddrByIPAddr(ipaddr) → {null|string}

Lookup the MAC address associated with the given IPv4 address.

Parameters:
Name Type Description
ipaddr string

The IPv4 address to lookup.

Source:
Returns:

Returns the MAC address associated with the given IPv4 or null if no matching host could be found or if no MAC address is known for the corresponding host.

Type
null | string

getMACHints(preferIp6opt) → {Array.<Array.<string>>}

Return an array of (MAC address, name hint) tuples sorted by MAC address.

Parameters:
Name Type Attributes Default Description
preferIp6 boolean <optional>
false

Whether to prefer IPv6 addresses (true) or IPv4 addresses (false) as name hint when no hostname is known for a specific MAC address.

Source:
Returns:

Returns an array of arrays containing a name hint for each found MAC address on the system. The array is sorted ascending by MAC.

Each item of the resulting array is a two element array with the MAC being the first element and the name hint being the second element. The name hint is either the hostname, an IPv4 or an IPv6 address related to the MAC address.

If no hostname but both IPv4 and IPv6 addresses are known, the preferIP6 flag specifies whether the IPv6 or the IPv4 address is used as hint.

Type
Array.<Array.<string>>