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).

Parameters:
NameTypeDescription
aArray.<number>

Addend as 4 × 16-bit words (little-endian)

nnumber

Value to add (integer carry)

Returns:

Sum as 4 × 16-bit words (little-endian)

Type: 
Array.<number>

calculateBroadcast(s, use_cfgvalue) → {string}

Calculate the broadcast IP for a given IP.

Parameters:
NameTypeDescription
sNode

the ui element to test.

use_cfgvalueboolean

whether to use the config or form value.

Returns:
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.

Parameters:
NameTypeDescription
stringstring

Input string used to derive the color

Returns:

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]
Parameters:
NameTypeAttributesDefaultDescription
lowernumber<optional>
0

Lower bound (when two args supplied)

uppernumber<optional>
0

Upper bound (when one or two args supplied)

Returns:

Random value (float in [0,1] or integer in requested range)

Type: 
number

getColorForName(forNamenullable) → {string}

Generate a colour for a name.

Parameters:
NameTypeAttributesDescription
forNamestring<nullable>
Returns:
Type: 
string

getDevices(network) → {Array.<string>}

Get bridge devices or Layer 3 devices of a network object.

Parameters:
NameTypeDescription
networkobject
Returns:
Type: 
Array.<string>

getGroups() → {Array.<string>}

Get users found in /etc/group.

Returns:
Type: 
Array.<string>

getUsers() → {Array.<string>}

Get users found in /etc/passwd.

Returns:
Type: 
Array.<string>

handleCgiIoReply(res) → {string}

Handle a CGI-IO reply.

Parameters:
NameTypeDescription
resobject
Throws:
Error
Returns:
Type: 
string

handleRpcReply(expect, rc) → {number}

Handle an RPC reply.

Parameters:
NameTypeDescription
expectobject
rcnumber
Source
Throws:
Error
Returns:
Type: 
number

initFirewallState() → {Promise}

Load the firewall configuration.

Returns:
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.

Returns:

32-bit pseudo-random integer (JS number)

Type: 
number

isCIDR(value) → {boolean}

Determine whether a provided value is a CIDR format IP string.

Parameters:
NameTypeDescription
valuestring

the IP string to test.

Returns:
Type: 
boolean

isContained(x, y) → {boolean}

Determines containment of two provided parameters. Can be arrays or objects.

Parameters:
NameTypeDescription
x*
y*
Returns:
Type: 
boolean

isEmpty(object, ignore) → {boolean}

Determine whether an object is empty.

Parameters:
NameTypeDescription
objectobject

object to enumerate.

ignorestring

property to ignore.

Returns:
Type: 
boolean

isEqual(x, y) → {boolean}

Determines equality of two provided parameters. Can be arrays or objects.

Parameters:
NameTypeDescription
x*
y*
Returns:
Type: 
boolean

lookupZone(namenullable) → (nullable) {Zone}

Look up a firewall zone.

Parameters:
NameTypeAttributesDescription
namestring<nullable>
Returns:
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.

Parameters:
NameTypeDescription
aArray.<number>

Multiplicand (4 × 16-bit words, little-endian)

bArray.<number>

Multiplier (4 × 16-bit words, little-endian)

Returns:

Product as 4 × 16-bit words (little-endian)

Type: 
Array.<number>

parseEnum(snullable, values) → {string}

Parse an enum value.

Parameters:
NameTypeAttributesDescription
sstring<nullable>
valuesArray.<string>
Returns:
Type: 
string

parsePolicy(snullable, defaultValueopt) → (nullable) {string}

Parse a policy value, or defaultValue if not found.

Parameters:
NameTypeAttributesDefaultDescription
sstring<nullable>
defaultValueArray.<string><optional>
['DROP', 'REJECT', 'ACCEPT']
Returns:
Type: 
string

scrubMenu(node) → {Node}

Erase the menu node

Parameters:
NameTypeDescription
nodeNode
Returns:
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.

Parameters:
NameTypeDescription
nnumber

Seed value (32-bit integer)

Returns:
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.

Parameters:
NameTypeDescription
aArray.<number>

Source value as 4 × 16-bit words (little-endian)

nnumber

Number of bits to shift right (non-negative integer)

Returns:

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.

Parameters:
NameTypeDescription
section_idstring
valuestring
Returns:
Type: 
boolean