- Source
Classes
Methods
addNetwork(name, optionsopt) → {Promise.<(null|LuCI.network.Protocol)>}
Adds a new network of the given name and update it with the given uci option values.
If a network with the given name already exist but is empty, then this function will update its option, otherwise it will do nothing.
| Name | Type | Attributes | Description |
|---|---|---|---|
name | string | The name of the network to add. Must be in the format | |
options | Object.<string, (string|Array.<string>)> | <optional> | An object of uci option values to set on the new network or to update in an existing, empty network. |
- Source
Returns a promise resolving to the Protocol subclass instance describing the added network or resolving to null if the name was invalid or if a non-empty network of the given name already existed.
- Type:
- Promise.<(null|LuCI.network.Protocol)>
addWifiNetwork(options) → {Promise.<(null|LuCI.network.WifiNetwork)>}
Adds a new wireless network to the configuration and sets its options to the provided values.
| Name | Type | Description |
|---|---|---|
options | Object.<string, (string|Array.<string>)> | The options to set for the newly added wireless network. This object must at least contain a |
- Source
Returns a promise resolving to a WifiNetwork instance describing the newly added wireless network or null if the given options were invalid or if the associated radio device could not be found.
- Type:
- Promise.<(null|LuCI.network.WifiNetwork)>
deleteNetwork(name) → {Promise.<boolean>}
Deletes the given network and its references from the network and firewall configuration.
| Name | Type | Description |
|---|---|---|
name | string | The name of the network to delete. |
- Source
Returns a promise resolving to either true if the network and references to it were successfully deleted from the configuration or false if the given network could not be found.
- Type:
- Promise.<boolean>
deleteWifiNetwork(netname) → {Promise.<boolean>}
Deletes the given wireless network from the configuration.
| Name | Type | Description |
|---|---|---|
netname | string | The name of the network to remove. This may be either a network ID in the form |
- Source
Returns a promise resolving to true if the wireless network has been successfully deleted from the configuration or false if it could not be found.
- Type:
- Promise.<boolean>
flushCache() → {Promise.<Object>}
Flushes the local network state cache and fetches updated information from the remote ubus apis.
- Source
Returns a promise resolving to the internal network state object.
- Type:
- Promise.<Object>
formatWifiEncryption(encryption) → {null|string}
Converts a given encryption entry into a human readable string such as mixed WPA/WPA2 PSK (TKIP, CCMP) or WPA3 SAE (CCMP).
| Name | Type | Description |
|---|---|---|
encryption | LuCI. | The wireless encryption entry to convert. |
- Source
Returns the description string for the given encryption entry or null if the given entry was invalid.
- Type:
- null |
string
getDSLModemType() → {Promise.<(null|string)>}
Queries the internal DSL modem type from board information.
- Source
Returns a promise resolving to the type of the internal modem (e.g. vdsl) or to null if no internal modem is present.
- Type:
- Promise.<(null|string)>
getDevice(name) → {Promise.<(null|LuCI.network.Device)>}
Get a Device instance describing the given network device.
| Name | Type | Description |
|---|---|---|
name | string | The name of the network device to get, e.g. |
- Source
Returns a promise resolving to the Device instance describing the network device or null if the given device name could not be found.
- Type:
- Promise.<(null|LuCI.network.Device)>
getDevices() → {Promise.<Array.<LuCI.network.Device>>}
Get a sorted list of all found network devices.
- Source
Returns a promise resolving to a sorted array of Device class instances describing the network devices found on the system.
- Type:
- Promise.<Array.<LuCI.network.Device>>
getHostHints() → {Promise.<LuCI.network.Hosts>}
Queries aggregated information about known hosts.
This function aggregates information from various sources such as DHCP lease databases, ARP and IPv6 neighbour entries, wireless association list etc. and returns a Hosts class instance describing the found hosts.
- Source
Returns a Hosts instance describing a host known on the system.
- Type:
- Promise.<LuCI.network.Hosts>
getIfnameOf(obj) → {null|string}
Obtains the network device name of the given object.
| Name | Type | Description |
|---|---|---|
obj | LuCI. | The object to get the device name from. |
- Source
Returns a string containing the device name or null if the given object could not be converted to a name.
- Type:
- null |
string
getNetwork(name) → {Promise.<(null|LuCI.network.Protocol)>}
Get a Protocol instance describing the network with the given name.
| Name | Type | Description |
|---|---|---|
name | string | The logical interface name of the network get, e.g. |
- Source
Returns a promise resolving to a Protocol subclass instance describing the network or null if the network did not exist.
- Type:
- Promise.<(null|LuCI.network.Protocol)>
getNetworks() → {Promise.<Array.<LuCI.network.Protocol>>}
Gets an array containing all known networks.
- Source
Returns a promise resolving to a name-sorted array of Protocol subclass instances describing all known networks.
- Type:
- Promise.<Array.<LuCI.network.Protocol>>
getProtocol(protoname, netnameopt) → {null|LuCI.network.Protocol}
Instantiates the given Protocol back-end, optionally using the given network name.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
protoname | string | The protocol back-end to use, e.g. | ||
netname | string | <optional> | __dummy__ | The network name to use for the instantiated protocol. This should be usually set to one of the interfaces described in /etc/config/network but it is allowed to omit it, e.g. to query protocol capabilities without the need for an existing interface. |
- Source
Returns the instantiated protocol back-end class or null if the given protocol isn't known.
- Type:
- null |
LuCI. network. Protocol
getProtocols() → {Array.<LuCI.network.Protocol>}
Obtains instances of all known Protocol back-end classes.
- Source
Returns an array of protocol class instances.
- Type:
- Array.<LuCI.network.Protocol>
getSwitchTopologies() → {Promise.<Object.<string, LuCI.network.SwitchTopology>>}
Returns the topologies of all swconfig switches found on the system.
- Source
Returns a promise resolving to an object containing the topologies of each switch. The object keys correspond to the name of the switches such as switch0, the values are SwitchTopology objects describing the layout.
- Type:
- Promise.<Object.<string, LuCI.network.SwitchTopology>>
getWAN6Networks() → {Promise.<Array.<LuCI.network.Protocol>>}
Get IPv6 wan networks.
This function looks up all networks having a default ::/0 route and returns them as an array.
- Source
Returns a promise resolving to an array of Protocol subclass instances describing the found IPv6 default route interfaces.
- Type:
- Promise.<Array.<LuCI.network.Protocol>>
getWANNetworks() → {Promise.<Array.<LuCI.network.Protocol>>}
Get IPv4 wan networks.
This function looks up all networks having a default 0.0.0.0/0 route and returns them as an array.
- Source
Returns a promise resolving to an array of Protocol subclass instances describing the found default route interfaces.
- Type:
- Promise.<Array.<LuCI.network.Protocol>>
getWifiDevice(devname) → {Promise.<(null|LuCI.network.WifiDevice)>}
Get a WifiDevice instance describing the given wireless radio.
| Name | Type | Description |
|---|---|---|
devname | string | The configuration name of the wireless radio to look up, e.g. |
- Source
Returns a promise resolving to the WifiDevice instance describing the underlying radio device or null if the wireless radio could not be found.
- Type:
- Promise.<(null|LuCI.network.WifiDevice)>
getWifiDevices() → {Promise.<Array.<LuCI.network.WifiDevice>>}
Obtain a list of all configured radio devices.
- Source
Returns a promise resolving to an array of WifiDevice instances describing the wireless radios configured in the system. The order of the array corresponds to the order of the radios in the configuration.
- Type:
- Promise.<Array.<LuCI.network.WifiDevice>>
getWifiNetwork(netname) → {Promise.<(null|LuCI.network.WifiNetwork)>}
Get a WifiNetwork instance describing the given wireless network.
| Name | Type | Description |
|---|---|---|
netname | string | The name of the wireless network to look up. This may be either an uci configuration section ID, a network ID in the form |
- Source
Returns a promise resolving to the WifiNetwork instance describing the wireless network or null if the corresponding network could not be found.
- Type:
- Promise.<(null|LuCI.network.WifiNetwork)>
getWifiNetworks() → {Promise.<Array.<LuCI.network.WifiNetwork>>}
Get an array of all WifiNetwork instances describing the wireless networks present on the system.
- Source
Returns a promise resolving to an array of WifiNetwork instances describing the wireless networks. The array will be empty if no networks are found.
- Type:
- Promise.<Array.<LuCI.network.WifiNetwork>>
isIgnoredDevice(name) → {boolean}
Test if a given network device name is in the list of patterns for device names to ignore.
Ignored device names are usually Linux network devices which are spawned implicitly by kernel modules such as tunl0 or hwsim0 and which are unsuitable for use in network configuration.
| Name | Type | Description |
|---|---|---|
name | string | The device name to test. |
- Source
Returns true if the given name is in the ignore-pattern list, else returns false.
- Type:
- boolean
maskToPrefix(netmask, v6opt) → {null|number}
Converts the given netmask to a prefix size in bits.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
netmask | string | The netmask to convert into a bits count. | ||
v6 | boolean | <optional> | false | Whether to parse the given netmask as IPv4 ( |
- Source
Returns the number of prefix bits contained in the netmask or null if the given netmask value was invalid.
- Type:
- null |
number
prefixToMask(bits, v6opt) → {null|string}
Converts the given prefix size in bits to a netmask.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
bits | number | The prefix size in bits. | ||
v6 | boolean | <optional> | false | Whether to convert the bits value into an IPv4 netmask ( |
- Source
Returns a string containing the netmask corresponding to the bit count or null when the given amount of bits exceeds the maximum possible value of 32 for IPv4 or 128 for IPv6.
- Type:
- null |
string
registerErrorCode(code, message) → {boolean}
Registers a new human readable translation string for a Protocol error code.
| Name | Type | Description |
|---|---|---|
code | string | The |
message | string | The message to use as a translation for the given protocol error code. |
- Source
Returns true if the error code description has been added or false if either the arguments were invalid or if there already was a description for the given code.
- Type:
- boolean
registerPatternVirtual(pat)
Registers a new regular expression pattern to recognize virtual interfaces.
| Name | Type | Description |
|---|---|---|
pat | RegExp | A |
- Source
registerProtocol(protoname, methods) → {LuCI.network.Protocol}
Registers a new Protocol subclass with the given methods and returns the resulting subclass value.
This function internally calls baseclass.extend() on the Network.Protocol base class.
| Name | Type | Description |
|---|---|---|
protoname | string | The name of the new protocol to register. |
methods | Object.<string, *> | The member methods and values of the new |
- Source
Returns the new Protocol subclass.
- Type:
- LuCI.
network. Protocol
renameNetwork(oldName, newName) → {Promise.<boolean>}
Rename the given network and its references to a new name.
| Name | Type | Description |
|---|---|---|
oldName | string | The current name of the network. |
newName | string | The name to rename the network to, must be in the format |
- Source
Returns a promise resolving to either true if the network was successfully renamed or false if the new name was invalid, if a network with the new name already exists or if the network to rename could not be found.
- Type:
- Promise.<boolean>
Type Definitions
SwitchTopology
Describes a swconfig switch topology by specifying the CPU connections and external port labels of a switch.
- Object.<string, (Object|Array)>
| Name | Type | Description |
|---|---|---|
netdevs | Object.<number, string> | The |
ports | Array.<Object.<string, (boolean|number|string)>> | The
|
- Source
WifiEncryption
An encryption entry describes active wireless encryption settings such as the used key management protocols, active ciphers and protocol versions.
- Object.<string, (boolean|Array.<(number|string)>)>
| Name | Type | Attributes | Description |
|---|---|---|---|
enabled | boolean | Specifies whether any kind of encryption, such as | |
wep | Array.<string> | <optional> | When the |
wpa | Array.<number> | <optional> | When the |
authentication | Array.<string> | <optional> | The |
ciphers | Array.<string> | <optional> | If either WEP or WPA encryption is active, then the |
- Source
WifiPeerEntry
A wireless peer entry describes the properties of a remote wireless peer associated with a local network.
- Object.<string, (boolean|number|string|LuCI.network.WifiRateEntry)>
| Name | Type | Attributes | Description |
|---|---|---|---|
mac | string | The MAC address (BSSID). | |
signal | number | The received signal strength. | |
signal_avg | number | <optional> | The average signal strength if supported by the driver. |
noise | number | <optional> | The current noise floor of the radio. May be |
inactive | number | The number of milliseconds the peer has been inactive, e.g. due to power-saving. | |
connected_time | number | The number of milliseconds the peer is associated to this network. | |
thr | number | <optional> | The estimated throughput of the peer, May be |
authorized | boolean | Specifies whether the peer is authorized to associate to this network. | |
authenticated | boolean | Specifies whether the peer completed authentication to this network. | |
preamble | string | The preamble mode used by the peer. May be | |
wme | boolean | Specifies whether the peer supports WME/WMM capabilities. | |
mfp | boolean | Specifies whether management frame protection is active. | |
tdls | boolean | Specifies whether TDLS is active. | |
mesh_llid | number | <optional> | The mesh LLID, may be |
mesh_plid | number | <optional> | The mesh PLID, may be |
mesh_plink | string | <optional> | The mesh peer link state description, may be an empty string ( The following states are known:
|
mesh_local_PS | number | <optional> | The local power-save mode for the peer link, may be an empty string ( The following modes are known:
|
mesh_peer_PS | number | <optional> | The remote power-save mode for the peer link, may be an empty string ( The following modes are known:
|
mesh_non_peer_PS | number | <optional> | The power-save mode for all non-peer neighbours, may be an empty string ( The following modes are known:
|
rx | LuCI. | Describes the receiving wireless rate from the peer. | |
tx | LuCI. | Describes the transmitting wireless rate to the peer. |
- Source
WifiRateEntry
A wireless rate entry describes the properties of a wireless transmission rate to or from a peer.
- Object.<string, (boolean|number)>
| Name | Type | Attributes | Description |
|---|---|---|---|
drop_misc | number | <optional> | The amount of received misc. packages that have been dropped, e.g. due to corruption or missing authentication. Only applicable to receiving rates. |
packets | number | The amount of packets that have been received or sent. | |
bytes | number | The amount of bytes that have been received or sent. | |
failed | number | <optional> | The amount of failed transmission attempts. Only applicable to transmit rates. |
retries | number | <optional> | The amount of retried transmissions. Only applicable to transmit rates. |
is_ht | boolean | Specifies whether this rate is an HT (IEEE 802.11n) rate. | |
is_vht | boolean | Specifies whether this rate is an VHT (IEEE 802.11ac) rate. | |
mhz | number | The channel width in MHz used for the transmission. | |
rate | number | The bitrate in bit/s of the transmission. | |
mcs | number | <optional> | The MCS index of the used transmission rate. Only applicable to HT or VHT rates. |
40mhz | number | <optional> | Specifies whether the transmission rate used 40MHz wide channel. Only applicable to HT or VHT rates. Note: this option exists for backwards compatibility only, and its use is discouraged. The |
short_gi | boolean | <optional> | Specifies whether a short guard interval is used for the transmission. Only applicable to HT or VHT rates. |
nss | number | <optional> | Specifies the number of spatial streams used by the transmission. Only applicable to VHT rates. |
he | boolean | <optional> | Specifies whether this rate is an HE (IEEE 802.11ax) rate. |
he_gi | number | <optional> | Specifies whether the guard interval used for the transmission. Only applicable to HE rates. |
he_dcm | number | <optional> | Specifies whether dual concurrent modulation is used for the transmission. Only applicable to HE rates. |
eht | boolean | <optional> | Specifies whether this rate is an EHT (IEEE 802.11be) rate. |
eht_gi | number | <optional> | Specifies whether the guard interval is used for the transmission. Only applicable to EHT rates. |
eht_dcm | number | <optional> | Specifies whether dual concurrent modulation is used for the transmission. Only applicable to EHT rates. |
- Source
WifiScanResult
A wireless scan result object describes a neighbouring wireless network found in the vicinity.
- Object.<string, (number|string|LuCI.network.WifiEncryption)>
| Name | Type | Description |
|---|---|---|
ssid | string | The SSID / Mesh ID of the network. |
bssid | string | The BSSID if the network. |
mode | string | The operation mode of the network ( |
channel | number | The wireless channel of the network. |
signal | number | The received signal strength of the network in dBm. |
quality | number | The numeric quality level of the signal, can be used in conjunction with |
quality_max | number | The maximum possible quality level of the signal, can be used in conjunction with |
encryption | LuCI. | The encryption used by the wireless network. |
- Source