Methods
add(a, n) → {Array.<number>}
Add a small integer to a 64-bit value represented as four 16-bit words.
Treats a as a little-endian 64-bit value (4 × 16-bit words). Adds the integer n to the least-significant word and propagates carry across subsequent 16-bit words. The result is truncated to 64 bits and returned as a 4-element array of 16-bit words (little-endian).
| Name | Type | Description |
|---|---|---|
a | Array.<number> | Addend as 4 × 16-bit words (little-endian) |
n | number | Value to add (integer carry) |
- Source
Sum as 4 × 16-bit words (little-endian)
- Type:
- Array.<number>
calculateBroadcast(s, use_cfgvalue) → {string}
Calculate the broadcast IP for a given IP.
| Name | Type | Description |
|---|---|---|
s | Node | the ui element to test. |
use_cfgvalue | boolean | whether to use the config or form value. |
- Source
- Type:
- string
derive_color(string) → {string}
Derive a deterministic hex color from an input string.
The color is produced by seeding the PRNG from a string-derived hash and producing RGB components. Returns a #rrggbb hex string.
| Name | Type | Description |
|---|---|---|
string | string | Input string used to derive the color |
- Source
Hex color string in #rrggbb format
- Type:
- string
get(loweropt, upperopt) → {number}
Return a pseudo-random value.
Overloads:
- get() -> number in [0, 1]
- get(upper) -> integer in [1, upper]
- get(lower, upper) -> integer in [lower, upper]
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
lower | number | <optional> | 0 | Lower bound (when two args supplied) |
upper | number | <optional> | 0 | Upper bound (when one or two args supplied) |
- Source
Random value (float in [0,1] or integer in requested range)
- Type:
- number
getColorForName(forNamenullable) → {string}
Generate a colour for a name.
| Name | Type | Attributes | Description |
|---|---|---|---|
forName | string | <nullable> |
- Source
- Type:
- string
getDevices(network) → {Array.<string>}
Get bridge devices or Layer 3 devices of a network object.
| Name | Type | Description |
|---|---|---|
network | object |
- Source
- Type:
- Array.<string>
getGroups() → {Array.<string>}
Get users found in /etc/group.
- Source
- Type:
- Array.<string>
getUsers() → {Array.<string>}
Get users found in /etc/passwd.
- Source
- Type:
- Array.<string>
handleCgiIoReply(res) → {string}
Handle a CGI-IO reply.
| Name | Type | Description |
|---|---|---|
res | object |
- Type:
- string
handleRpcReply(expect, rc) → {number}
Handle an RPC reply.
| Name | Type | Description |
|---|---|---|
expect | object | |
rc | number |
- Type:
- number
initFirewallState() → {Promise}
Load the firewall configuration.
- Source
- Type:
- Promise
int() → {number}
Produce the next PRNG 32-bit integer.
Advances the internal state and returns a 32-bit pseudo-random integer derived from the current state.
- Source
32-bit pseudo-random integer (JS number)
- Type:
- number
isCIDR(value) → {boolean}
Determine whether a provided value is a CIDR format IP string.
| Name | Type | Description |
|---|---|---|
value | string | the IP string to test. |
- Source
- Type:
- boolean
isContained(x, y) → {boolean}
Determines containment of two provided parameters. Can be arrays or objects.
| Name | Type | Description |
|---|---|---|
x | * | |
y | * |
- Type:
- boolean
isEmpty(object, ignore) → {boolean}
Determine whether an object is empty.
| Name | Type | Description |
|---|---|---|
object | object | object to enumerate. |
ignore | string | property to ignore. |
- Type:
- boolean
isEqual(x, y) → {boolean}
Determines equality of two provided parameters. Can be arrays or objects.
| Name | Type | Description |
|---|---|---|
x | * | |
y | * |
- Type:
- boolean
lookupZone(namenullable) → (nullable) {Zone}
Look up a firewall zone.
| Name | Type | Attributes | Description |
|---|---|---|---|
name | string | <nullable> |
- Source
- Type:
- Zone
mul(a, b) → {Array.<number>}
Multiply two 64-bit values represented as arrays of four 16-bit words.
Arrays use little-endian word order (least-significant 16-bit word first). The result is truncated to the lower 64 bits and returned as a 4-element array of 16-bit words.
| Name | Type | Description |
|---|---|---|
a | Array.<number> | Multiplicand (4 × 16-bit words, little-endian) |
b | Array.<number> | Multiplier (4 × 16-bit words, little-endian) |
- Source
Product as 4 × 16-bit words (little-endian)
- Type:
- Array.<number>
parseEnum(snullable, values) → {string}
Parse an enum value.
| Name | Type | Attributes | Description |
|---|---|---|---|
s | string | <nullable> | |
values | Array.<string> |
- Source
- Type:
- string
parsePolicy(snullable, defaultValueopt) → (nullable) {string}
Parse a policy value, or defaultValue if not found.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
s | string | <nullable> | ||
defaultValue | Array.<string> | <optional> | ['DROP', 'REJECT', 'ACCEPT'] |
- Source
- Type:
- string
scrubMenu(node) → {Node}
Erase the menu node
| Name | Type | Description |
|---|---|---|
node | Node |
- Type:
- Node
seed(n) → {void}
Seed the PRNG state.
The seed is treated as a 32-bit integer; the lower 16 bits are stored in s[0], the upper 16 bits in s[1]. s[2] and s[3] are zeroed.
| Name | Type | Description |
|---|---|---|
n | number | Seed value (32-bit integer) |
- Source
- Type:
- void
shr(a, n) → {Array.<number>}
Shift a 64-bit value (4 × 16-bit words, little-endian) right by n bits.
The input array is treated as little-endian 16-bit words. Bits shifted out on the right are discarded; the returned array contains the lower 64-bit result after the logical right shift.
| Name | Type | Description |
|---|---|---|
a | Array.<number> | Source value as 4 × 16-bit words (little-endian) |
n | number | Number of bits to shift right (non-negative integer) |
- Source
Shifted value as 4 × 16-bit words (little-endian)
- Type:
- Array.<number>
validateBroadcast(section_id, value) → {boolean}
Validate a broadcast IP for a section value.
| Name | Type | Description |
|---|---|---|
section_id | string | |
value | string |
- Source
- Type:
- boolean