#hs.network.configuration

This sub-module provides access to the current location set configuration settings in the system's dynamic store.


#API Overview

Constructors - API calls which return an object, typically one that offers API methods

Methods - API calls which can only be made on an object returned by a constructor


#API Documentation

#Constructors

Signaturehs.network.configuration.open() -> storeObject
TypeConstructor
DescriptionOpens a session to the dynamic store maintained by the System Configuration server.
Parameters
  • None
Returns
  • the storeObject
NotesNone
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 48

#Methods

Signaturehs.network.configuration:computerName() -> name, encoding
TypeMethod
DescriptionReturns the name of the computer as specified in the Sharing Preferences, and its string encoding
Parameters
  • None
Returns
  • name - the computer name
  • encoding - the encoding type
Notes
  • You can also retrieve this information as key-value pairs with hs.network.configuration:contents("Setup:/System")
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 194

Signaturehs.network.configuration:consoleUser() -> name, uid, gid
TypeMethod
DescriptionReturns the name of the user currently logged into the system, including the users id and primary group id
Parameters
  • None
Returns
  • name - the user name
  • uid - the user ID for the user
  • gid - the user's primary group ID
Notes
  • You can also retrieve this information as key-value pairs with hs.network.configuration:contents("State:/Users/ConsoleUser")
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 245

Signaturehs.network.configuration:contents([keys], [pattern]) -> table
TypeMethod
DescriptionReturn the contents of the store for the specified keys or keys matching the specified pattern(s)
Parameters
  • keys - a string or table of strings containing the keys or patterns of keys, if pattern is true. Defaults to all keys.
  • pattern - a boolean indicating wether or not the string(s) provided are to be considered regular expression patterns (true) or literal strings to match (false). Defaults to false.
Returns
  • a table of key-value pairs from the dynamic store which match the specified keys or key patterns.
Notes
  • if no parameters are provided, then all key-value pairs in the dynamic store are returned.
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 86

Signaturehs.network.configuration:dhcpInfo([serviceID]) -> table
TypeMethod
DescriptionReturn the DHCP information for the specified service or the primary service if no parameter is specified.
Parameters
  • serviceID - an optional string containing the service ID of the interface for which to return DHCP info. If this parameter is not provided, then the default (primary) service is queried.
Returns
  • a table containing DHCP information including lease time and DHCP options
Notes
  • a list of possible Service ID's can be retrieved with hs.network.configuration:contents("Setup:/Network/Global/IPv4")
  • generates an error if the service ID is invalid or was not assigned an IP address via DHCP.
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 161

Signaturehs.network.configuration:hostname() -> name
TypeMethod
DescriptionReturns the current local host name for the computer
Parameters
  • None
Returns
  • name - the local host name
Notes
  • You can also retrieve this information as key-value pairs with hs.network.configuration:contents("Setup:/System")
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 278

Signaturehs.network.configuration:keys([keypattern]) -> table
TypeMethod
DescriptionReturn the keys in the dynamic store which match the specified pattern
Parameters
  • keypattern - a regular expression specifying which keys to return (defaults to ".*", or all keys)
Returns
  • a table of keys from the dynamic store.
NotesNone
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 136

Signaturehs.network.configuration:location() -> location
TypeMethod
DescriptionReturns the current location identifier
Parameters
  • None
Returns
  • location - the UUID for the currently active network location
Notes
  • You can also retrieve this information as key-value pairs with hs.network.configuration:contents("Setup:")
  • If you have different locations defined in the Network preferences panel, this can be used to determine the currently active location.
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 397

Signaturehs.network.configuration:locations() -> table
TypeMethod
DescriptionReturns all configured locations
Parameters
  • None
Returns
  • a table of key-value pairs mapping location UUIDs to their names
NotesNone
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 425

Signaturehs.network.configuration:monitorKeys([keys], [pattern]) -> storeObject
TypeMethod
DescriptionSpecify the key(s) or key pattern(s) to monitor for changes.
Parameters
  • keys - a string or table of strings containing the keys or patterns of keys, if pattern is true. Defaults to all keys.
  • pattern - a boolean indicating wether or not the string(s) provided are to be considered regular expression patterns (true) or literal strings to match (false). Defaults to false.
Returns
  • the store Object
Notes
  • if no parameters are provided, then all key-value pairs in the dynamic store are monitored for changes.
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 572

Signaturehs.network.configuration:proxies() -> table
TypeMethod
DescriptionReturns information about the currently active proxies, if any
Parameters
  • None
Returns
  • a table of key-value pairs describing the current proxies in effect, both globally, and scoped to specific interfaces.
Notes
  • You can also retrieve this information as key-value pairs with hs.network.configuration:contents("State:/Network/Global/Proxies")
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 461

Signaturehs.network.configuration:setCallback(function) -> storeObject
TypeMethod
DescriptionSet or remove the callback function for a store object
Parameters
  • a function or nil to set or remove the store object callback function
Returns
  • the store object
Notes
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 488

Signaturehs.network.configuration:setLocation(location) -> boolean
TypeMethod
DescriptionSwitches to a new location
Parameters
  • location - string containing name or UUID of new location
Returns
  • bool - true if the location was successfully changed, false if there was an error
NotesNone
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 316

Signaturehs.network.configuration:start() -> storeObject
TypeMethod
DescriptionStarts watching the store object for changes to the monitored keys and invokes the callback function (if any) when a change occurs.
Parameters
  • None
Returns
  • the store object
Notes
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 523

Signaturehs.network.configuration:stop() -> storeObject
TypeMethod
DescriptionStops watching the store object for changes.
Parameters
  • None
Returns
  • the store object
NotesNone
ExamplesNone
Sourceextensions/network/libnetwork_configuration.m line 550