docs » hs.network
This module provides functions for inquiring about and monitoring changes to the network.
- Functions - API calls offered directly by the extension
- addresses
- interfaceDetails
- interfaceName
- interfaces
- primaryInterfaces
Signature | hs.network.addresses([interface_list]) -> table |
---|---|
Type | Function |
Description | Returns a list of the IPv4 and IPv6 addresses for the specified interfaces, or all interfaces if no arguments are given. |
Parameters |
|
Returns |
|
Notes |
|
| Signature | hs.network.interfaceDetails([interface | favorIPv6]) -> table
|
| -----------------------------------------------------|---------------------------------------------------------------------------------------------------------|
| Type | Function |
| Description | Returns details about the specified interface or the primary interface if no interface is specified. |
| Parameters |
- interface - an optional string specifying the interface to retrieve details about. Defaults to the primary interface if not specified.
- favorIPv6 - an optional boolean specifying whether or not to prefer the primary IPv6 or the primary IPv4 interface if
interface
is not specified. Defaults to false.
- A table containing key-value pairs describing interface details. Returns an empty table if no primary interface can be determined. Logs an error and returns nil if there was a problem retrieving this information.
- When determining the primary interface, the
favorIPv6
flag only determines interface search order. If you specify true for this flag, but no primary IPv6 interface exists (i.e. your DHCP server only provides an IPv4 address an IPv6 is limited to local only traffic), then the primary IPv4 interface will be used instead.
| Signature | hs.network.interfaceName([interface | favorIPv6]) -> string
|
| -----------------------------------------------------|---------------------------------------------------------------------------------------------------------|
| Type | Function |
| Description | Returns the user defined name for the specified interface or the primary interface if no interface is specified. |
| Parameters |
- interface - an optional string specifying the interface to retrieve the name for. Defaults to the primary interface if not specified.
- favorIPv6 - an optional boolean specifying whether or not to prefer the primary IPv6 or the primary IPv4 interface if
interface
is not specified. Defaults to false.
- A string containing the user defined name for the interface, if one exists, or false if the interface does not have a user defined name. Logs an error and returns nil if there was a problem retrieving this information.
- Only interfaces which show up in the System Preferences Network panel will have a user defined name.
Signature | hs.network.interfaces() -> table |
---|---|
Type | Function |
Description | Returns a list of interfaces currently active for the system. |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.network.primaryInterfaces() -> ipv4Interface, ipv6Interface |
---|---|
Type | Function |
Description | Returns the names of the primary IPv4 and IPv6 interfaces. |
Parameters |
|
Returns |
|
Notes |
|