luci-base: js linting fixes / ES6 treatment
authorPaul Donald <redacted>
Sat, 14 Feb 2026 18:46:15 +0000 (19:46 +0100)
committerPaul Donald <redacted>
Mon, 16 Feb 2026 00:42:57 +0000 (01:42 +0100)
prevent global variable bleed and reduce size somewhat

-cbi
-network
-protocol/static
-rpc
-tools/widgets
-tools/views
-uci

protocols

Signed-off-by: Paul Donald <redacted>
12 files changed:
modules/luci-base/htdocs/luci-static/resources/cbi.js
modules/luci-base/htdocs/luci-static/resources/fs.js
modules/luci-base/htdocs/luci-static/resources/network.js
modules/luci-base/htdocs/luci-static/resources/protocol/static.js
modules/luci-base/htdocs/luci-static/resources/tools/views.js
modules/luci-base/htdocs/luci-static/resources/tools/widgets.js
modules/luci-base/htdocs/luci-static/resources/uci.js
protocols/luci-proto-3g/htdocs/luci-static/resources/protocol/3g.js
protocols/luci-proto-openconnect/htdocs/luci-static/resources/protocol/openconnect.js
protocols/luci-proto-openfortivpn/htdocs/luci-static/resources/protocol/openfortivpn.js
protocols/luci-proto-relay/htdocs/luci-static/resources/protocol/relay.js
protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js

index 1b89542c9664874fcd6d01f8c9be022037225585..1a637dcd68352a123db65455413551cb0afdca46 100644 (file)
@@ -19,8 +19,8 @@
  * defined here are registered as global `window.*` symbols.
  * @module LuCI.cbi
  */
-var cbi_d = [];
-var cbi_strings = { path: {}, label: {} };
+const cbi_d = [];
+const cbi_strings = { path: {}, label: {} };
 
 /**
  * Read signed 8-bit integer from a byte array at the given offset.
@@ -29,7 +29,7 @@ var cbi_strings = { path: {}, label: {} };
  * @returns {number} Signed 8-bit value (returned as unsigned number).
  */
 function s8(bytes, off) {
-       var n = bytes[off];
+       const n = bytes[off];
        return (n > 0x7F) ? (n - 256) >>> 0 : n;
 }
 
@@ -53,10 +53,10 @@ function sfh(s) {
        if (s === null || s.length === 0)
                return null;
 
-       var bytes = [];
+       const bytes = [];
 
-       for (var i = 0; i < s.length; i++) {
-               var ch = s.charCodeAt(i);
+       for (let i = 0; i < s.length; i++) {
+               let ch = s.charCodeAt(i);
 
                // Handle surrogate pairs
                if (ch >= 0xD800 && ch <= 0xDBFF && i + 1 < s.length) {
@@ -86,9 +86,9 @@ function sfh(s) {
        if (!bytes.length)
                return null;
 
-       var hash = (bytes.length >>> 0),
-           len = (bytes.length >>> 2),
-           off = 0, tmp;
+       let hash = (bytes.length >>> 0);
+       let len = (bytes.length >>> 2);
+       let off = 0, tmp;
 
        while (len--) {
                hash += u16(bytes, off);
@@ -300,7 +300,7 @@ function cbi_d_update() {
  * placeholders with interactive widgets.
  */
 function cbi_init() {
-       var nodes;
+       let nodes;
 
        document.querySelectorAll('.cbi-dropdown').forEach(function(node) {
                cbi_dropdown_init(node);
@@ -309,65 +309,65 @@ function cbi_init() {
 
        nodes = document.querySelectorAll('[data-strings]');
 
-       for (let i = 0, node; (node = nodes[i]) !== undefined; i++) {
-               var str = JSON.parse(node.getAttribute('data-strings'));
-               for (var key in str) {
-                       for (var key2 in str[key]) {
-                               var dst = cbi_strings[key] || (cbi_strings[key] = { });
-                                   dst[key2] = str[key][key2];
+       for (let n of nodes) {
+               const str = JSON.parse(n.getAttribute('data-strings'));
+               for (let key in str) {
+                       for (let key2 in str[key]) {
+                               const dst = cbi_strings[key] || (cbi_strings[key] = { });
+                               dst[key2] = str[key][key2];
                        }
                }
        }
 
        nodes = document.querySelectorAll('[data-depends]');
 
-       for (let i = 0, node; (node = nodes[i]) !== undefined; i++) {
-               var index = parseInt(node.getAttribute('data-index'), 10);
-               var depends = JSON.parse(node.getAttribute('data-depends'));
+       for (let n of nodes) {
+               const index = parseInt(n.getAttribute('data-index'), 10);
+               const depends = JSON.parse(n.getAttribute('data-depends'));
                if (!isNaN(index) && depends.length > 0) {
-                       for (let alt = 0; alt < depends.length; alt++)
-                               cbi_d_add(node, depends[alt], index);
+                       for (let a of depends)
+                               cbi_d_add(n, depends[a], index);
                }
        }
 
        nodes = document.querySelectorAll('[data-update]');
 
-       for (let i = 0, node; (node = nodes[i]) !== undefined; i++) {
-               var events = node.getAttribute('data-update').split(' ');
-               for (let j = 0, event; (event = events[j]) !== undefined; j++)
-                       node.addEventListener(event, cbi_d_update);
+       for (let n of nodes) {
+               const events = n.getAttribute('data-update').split(' ');
+               for (let ev of events)
+                       n.addEventListener(ev, cbi_d_update);
        }
 
        nodes = document.querySelectorAll('[data-choices]');
 
-       for (let i = 0, node; (node = nodes[i]) !== undefined; i++) {
-               let choices = JSON.parse(node.getAttribute('data-choices')),
-                   options = {};
+       for (let node of nodes) {
+               const choices = JSON.parse(node.getAttribute('data-choices'));
+               const options = {};
 
                for (let j = 0; j < choices[0].length; j++)
                        options[choices[0][j]] = choices[1][j];
 
-               var def = (node.getAttribute('data-optional') === 'true')
+               const def = (node.getAttribute('data-optional') === 'true')
                        ? node.placeholder || '' : null;
 
-               var cb = new L.ui.Combobox(node.value, options, {
+               const cb = new L.ui.Combobox(node.value, options, {
                        name: node.getAttribute('name'),
                        sort: choices[0],
                        select_placeholder: def || _('-- Please choose --'),
                        custom_placeholder: node.getAttribute('data-manual') || _('-- custom --')
                });
 
-               var n = cb.render();
+               const n = cb.render();
                n.addEventListener('cbi-dropdown-change', cbi_d_update);
                node.parentNode.replaceChild(n, node);
        }
 
        nodes = document.querySelectorAll('[data-dynlist]');
 
-       for (let i = 0, node; (node = nodes[i]) !== undefined; i++) {
-               let choices = JSON.parse(node.getAttribute('data-dynlist')),
-                   values = JSON.parse(node.getAttribute('data-values') || '[]'),
-                   options = null;
+       for (let node of nodes) {
+               const choices = JSON.parse(node.getAttribute('data-dynlist'));
+               const values = JSON.parse(node.getAttribute('data-values') || '[]');
+               let options = null;
 
                if (choices[0] && choices[0].length) {
                        options = {};
@@ -391,7 +391,7 @@ function cbi_init() {
 
        nodes = document.querySelectorAll('[data-type]');
 
-       for (let i = 0, node; (node = nodes[i]) !== undefined; i++) {
+       for (let node of nodes) {
                cbi_validate_field(node, node.getAttribute('data-optional') === 'true',
                                   node.getAttribute('data-type'));
        }
@@ -415,9 +415,9 @@ function cbi_init() {
        var tasks = [];
 
        document.querySelectorAll('[data-ui-widget]').forEach(function(node) {
-               let args = JSON.parse(node.getAttribute('data-ui-widget') || '[]'),
-                   widget = new (Function.prototype.bind.apply(L.ui[args[0]], args)),
-                   markup = widget.render();
+               const args = JSON.parse(node.getAttribute('data-ui-widget') || '[]');
+               const widget = new (Function.prototype.bind.apply(L.ui[args[0]], args));
+               const markup = widget.render();
 
                tasks.push(Promise.resolve(markup).then(function(markup) {
                        markup.addEventListener('widget-change', cbi_d_update);
@@ -441,8 +441,8 @@ function cbi_validate_form(form, errmsg)
                return true;
 
        if (form.cbi_validators) {
-               for (var i = 0; i < form.cbi_validators.length; i++) {
-                       var validator = form.cbi_validators[i];
+               for (let fv of form.cbi_validators) {
+                       const validator = fv;
 
                        if (!validator() && errmsg) {
                                alert(errmsg);
@@ -584,10 +584,10 @@ function cbi_row_swap(elem, up, store)
  */
 function cbi_tag_last(container)
 {
-       var last;
+       let last;
 
-       for (var i = 0; i < container.childNodes.length; i++) {
-               var c = container.childNodes[i];
+       for (let cn of container.childNodes) {
+               var c = cn;
                if (matchesElem(c, 'div')) {
                        c.classList.remove('cbi-value-last');
                        last = c;
@@ -608,7 +608,7 @@ function cbi_tag_last(container)
  */
 function cbi_submit(elem, name, value, action)
 {
-       var form = elem.form || findParent(elem, 'form');
+       const form = elem.form || findParent(elem, 'form');
 
        if (!form)
                return false;
@@ -644,8 +644,8 @@ String.prototype.format = function()
        if (!RegExp)
                return;
 
-       var html_esc = [/&/g, '&#38;', /"/g, '&#34;', /'/g, '&#39;', /</g, '&#60;', />/g, '&#62;'];
-       var quot_esc = [/"/g, '&#34;', /'/g, '&#39;'];
+       const html_esc = [/&/g, '&#38;', /"/g, '&#34;', /'/g, '&#39;', /</g, '&#60;', />/g, '&#62;'];
+       const quot_esc = [/"/g, '&#34;', /'/g, '&#39;'];
 
        /**
         * Escape a string.
@@ -656,7 +656,7 @@ String.prototype.format = function()
         * @returns {string}
         */
        function esc(s, r) {
-               var t = typeof(s);
+               const t = typeof(s);
 
                if (s == null || t === 'object' || t === 'function')
                        return '';
@@ -664,32 +664,31 @@ String.prototype.format = function()
                if (t !== 'string')
                        s = String(s);
 
-               for (var i = 0; i < r.length; i += 2)
+               for (let i = 0; i < r.length; i += 2)
                        s = s.replace(r[i], r[i+1]);
 
                return s;
        }
 
-       var str = this;
-       var out = '';
-       var re = /^(([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X|q|h|j|t|m))/;
-       var a = b = [], numSubstitutions = 0, numMatches = 0;
+       let str = this;
+       let subst, n, pad;
+       let out = '';
+       const re = /^(([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X|q|h|j|t|m))/;
+       let a = [], numSubstitutions = 0;
 
        while ((a = re.exec(str)) !== null) {
-               var m = a[1];
-               var leftpart = a[2], pPad = a[3], pJustify = a[4], pMinLength = a[5];
-               var pPrecision = a[6], pType = a[7];
-
-               numMatches++;
+               const m = a[1];
+               let leftpart = a[2], pPad = a[3], pJustify = a[4], pMinLength = a[5];
+               let pPrecision = a[6], pType = a[7];
 
                if (pType == '%') {
                        subst = '%';
                }
                else {
                        if (numSubstitutions < arguments.length) {
-                               var param = arguments[numSubstitutions++];
+                               let param = arguments[numSubstitutions++];
 
-                               var pad = '';
+                               pad = '';
                                if (pPad && pPad.substr(0,1) == "'")
                                        pad = leftpart.substr(1,1);
                                else if (pPad)
@@ -697,19 +696,11 @@ String.prototype.format = function()
                                else
                                        pad = ' ';
 
-                               var justifyRight = true;
-                               if (pJustify && pJustify === "-")
-                                       justifyRight = false;
-
-                               var minLength = -1;
-                               if (pMinLength)
-                                       minLength = +pMinLength;
-
                                var precision = -1;
                                if (pPrecision && pType == 'f')
                                        precision = +pPrecision.substring(1);
 
-                               var subst = param;
+                               subst = param;
 
                                switch(pType) {
                                        case 'b':
@@ -725,7 +716,7 @@ String.prototype.format = function()
                                                break;
 
                                        case 'u':
-                                               var n = +param || 0;
+                                               n = +param || 0;
                                                subst = Math.floor((n < 0) ? 0x100000000 + n : n).toFixed(0);
                                                break;
 
@@ -845,10 +836,10 @@ String.prototype.nobr = function()
  */
 String.format = function()
 {
-       var a = [ ];
+       const a = [ ];
 
-       for (var i = 1; i < arguments.length; i++)
-               a.push(arguments[i]);
+       for (let ar of arguments)
+               a.push(ar);
 
        return ''.format.apply(arguments[0], a);
 }
@@ -862,10 +853,10 @@ String.format = function()
  */
 String.nobr = function()
 {
-       var a = [ ];
+       const a = [ ];
 
-       for (var i = 1; i < arguments.length; i++)
-               a.push(arguments[i]);
+       for (let ar of arguments)
+               a.push(ar);
 
        return ''.nobr.apply(arguments[0], a);
 }
@@ -927,7 +918,7 @@ function cbi_dropdown_init(sb) {
        if (sb && L.dom.findClassInstance(sb) instanceof L.ui.Dropdown)
                return;
 
-       var dl = new L.ui.Dropdown(sb, null, { name: sb.getAttribute('name') });
+       const dl = new L.ui.Dropdown(sb, null, { name: sb.getAttribute('name') });
        return dl.bind(sb);
 }
 
@@ -938,12 +929,12 @@ function cbi_dropdown_init(sb) {
  * @param {string} [placeholder] - Placeholder text when empty.
  */
 function cbi_update_table(table, data, placeholder) {
-       var target = isElem(table) ? table : document.querySelector(table);
+       const target = isElem(table) ? table : document.querySelector(table);
 
        if (!isElem(target))
                return;
 
-       var t = L.dom.findClassInstance(target);
+       let t = L.dom.findClassInstance(target);
 
        if (!(t instanceof L.ui.Table)) {
                t = new L.ui.Table(target);
index 630373d656209cada2c9c942f5ff6ec24e091c26..94e9cd4e4f1fbc76be436ef71078f39248ee7a60 100644 (file)
  * @property {string} [stderr] - The stderr produced by the command, if any
  */
 
-var callFileList, callFileStat, callFileRead, callFileWrite, callFileRemove,
-    callFileExec, callFileMD5;
-
-callFileList = rpc.declare({
+const callFileList = rpc.declare({
        object: 'file',
        method: 'list',
        params: [ 'path' ]
 });
 
-callFileStat = rpc.declare({
+const callFileStat = rpc.declare({
        object: 'file',
        method: 'stat',
        params: [ 'path' ]
 });
 
-callFileRead = rpc.declare({
+const callFileRead = rpc.declare({
        object: 'file',
        method: 'read',
        params: [ 'path' ]
 });
 
-callFileWrite = rpc.declare({
+const callFileWrite = rpc.declare({
        object: 'file',
        method: 'write',
        params: [ 'path', 'data', 'mode' ]
 });
 
-callFileRemove = rpc.declare({
+const callFileRemove = rpc.declare({
        object: 'file',
        method: 'remove',
        params: [ 'path' ]
 });
 
-callFileExec = rpc.declare({
+const callFileExec = rpc.declare({
        object: 'file',
        method: 'exec',
        params: [ 'command', 'params', 'env' ]
 });
 
-callFileMD5 = rpc.declare({
-       object: 'file',
-       method: 'md5',
-       params: [ 'path' ]
-});
-
-var rpcErrors = [
+const rpcErrors = [
        null,
        'InvalidCommandError',
        'InvalidArgumentError',
@@ -183,7 +174,7 @@ var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
         * Returns a promise resolving to an array of stat detail objects or
         * rejecting with an error stating the failure reason.
         */
-       list: function(path) {
+       list(path) {
                return callFileList(path).then(handleRpcReply.bind(this, { entries: [] }));
        },
 
@@ -197,7 +188,7 @@ var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
         * Returns a promise resolving to a stat detail object or
         * rejecting with an error stating the failure reason.
         */
-       stat: function(path) {
+       stat(path) {
                return callFileStat(path).then(handleRpcReply.bind(this, { '': {} }));
        },
 
@@ -212,7 +203,7 @@ var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
         * Returns a promise resolving to a string containing the file contents or
         * rejecting with an error stating the failure reason.
         */
-       read: function(path) {
+       read(path) {
                return callFileRead(path).then(handleRpcReply.bind(this, { data: '' }));
        },
 
@@ -238,7 +229,7 @@ var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
         * Returns a promise resolving to `0` or rejecting with an error stating
         * the failure reason.
         */
-       write: function(path, data, mode) {
+       write(path, data, mode) {
                data = (data != null) ? String(data) : '';
                mode = (mode != null) ? mode : 420; // 0644
                return callFileWrite(path, data, mode).then(handleRpcReply.bind(this, { '': 0 }));
@@ -254,7 +245,7 @@ var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
         * Returns a promise resolving to `0` or rejecting with an error stating
         * the failure reason.
         */
-       remove: function(path) {
+       remove(path) {
                return callFileRemove(path).then(handleRpcReply.bind(this, { '': 0 }));
        },
 
@@ -283,7 +274,7 @@ var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
         * Returns a promise resolving to an object describing the execution
         * results or rejecting with an error stating the failure reason.
         */
-       exec: function(command, params, env) {
+       exec(command, params, env) {
                if (!Array.isArray(params))
                        params = null;
 
@@ -311,7 +302,7 @@ var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
         * Returns a promise resolving to the file contents or the empty string
         * on failure.
         */
-       trimmed: function(path) {
+       trimmed(path) {
                return L.resolveDefault(this.read(path), '').then(function(s) {
                        return s.trim();
                });
@@ -332,7 +323,7 @@ var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
         * Returns a promise resolving to an array containing the stripped lines
         * of the given file or `[]` on failure.
         */
-       lines: function(path) {
+       lines(path) {
                return L.resolveDefault(this.read(path), '').then(function(s) {
                        var lines = [];
 
@@ -373,7 +364,7 @@ var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
         * to the specified type or rejecting with an error stating the failure
         * reason.
         */
-       read_direct: function(path, type) {
+       read_direct(path, type) {
                var postdata = 'sessionid=%s&path=%s'
                        .format(encodeURIComponent(L.env.sessionid), encodeURIComponent(path));
 
@@ -430,7 +421,7 @@ var FileSystem = baseclass.extend(/** @lends LuCI.fs.prototype */ {
         * according to the specified type or rejecting with an error stating the
         * failure reason.
         */
-       exec_direct: function(command, params, type, latin1, stderr, responseProgress) {
+       exec_direct(command, params, type, latin1, stderr, responseProgress) {
                var cmdstr = String(command)
                        .replace(/\\/g, '\\\\').replace(/(\s)/g, '\\$1');
 
index a7651d0b019c9a4cacb55da8669d4b288a578dfd..176e16e9a5d616b349b0423c0a6aa62ad09663a0 100644 (file)
@@ -5,7 +5,7 @@
 'require baseclass';
 'require firewall';
 
-var proto_errors = {
+const proto_errors = {
        CONNECT_FAILED:                 _('Connection attempt failed'),
        INVALID_ADDRESS:                _('IP address is invalid'),
        INVALID_GATEWAY:                _('Gateway address is invalid'),
@@ -21,7 +21,7 @@ var proto_errors = {
        PIN_FAILED:                             _('PIN code rejected')
 };
 
-var iface_patterns_ignore = [
+const iface_patterns_ignore = [
        /^wmaster\d+/,
        /^wifi\d+/,
        /^hwsim\d+/,
@@ -37,46 +37,46 @@ var iface_patterns_ignore = [
        /^lo$/
 ];
 
-var iface_patterns_wireless = [
+const iface_patterns_wireless = [
        /^wlan\d+/,
        /^wl\d+/,
        /^ath\d+/,
        /^\w+\.network\d+/
 ];
 
-var iface_patterns_virtual = [ ];
+const iface_patterns_virtual = [ ];
 
-var callLuciNetworkDevices = rpc.declare({
+const callLuciNetworkDevices = rpc.declare({
        object: 'luci-rpc',
        method: 'getNetworkDevices',
        expect: { '': {} }
 });
 
-var callLuciWirelessDevices = rpc.declare({
+const callLuciWirelessDevices = rpc.declare({
        object: 'luci-rpc',
        method: 'getWirelessDevices',
        expect: { '': {} }
 });
 
-var callLuciBoardJSON = rpc.declare({
+const callLuciBoardJSON = rpc.declare({
        object: 'luci-rpc',
        method: 'getBoardJSON'
 });
 
-var callLuciHostHints = rpc.declare({
+const callLuciHostHints = rpc.declare({
        object: 'luci-rpc',
        method: 'getHostHints',
        expect: { '': {} }
 });
 
-var callIwinfoAssoclist = rpc.declare({
+const callIwinfoAssoclist = rpc.declare({
        object: 'iwinfo',
        method: 'assoclist',
        params: [ 'device', 'mac' ],
        expect: { results: [] }
 });
 
-var callIwinfoScan = rpc.declare({
+const callIwinfoScan = rpc.declare({
        object: 'iwinfo',
        method: 'scan',
        params: [ 'device' ],
@@ -84,24 +84,24 @@ var callIwinfoScan = rpc.declare({
        expect: { results: [] }
 });
 
-var callNetworkInterfaceDump = rpc.declare({
+const callNetworkInterfaceDump = rpc.declare({
        object: 'network.interface',
        method: 'dump',
        expect: { 'interface': [] }
 });
 
-var callNetworkProtoHandlers = rpc.declare({
+const callNetworkProtoHandlers = rpc.declare({
        object: 'network',
        method: 'get_proto_handlers',
        expect: { '': {} }
 });
 
-var _init = null,
-    _state = null,
-    _protocols = {},
-    _protospecs = {};
+let _init = null;
+let _state = null;
+const _protocols = {};
+const _protospecs = {};
 
-function getProtocolHandlers(cache) {
+function getProtocolHandlers() {
        return callNetworkProtoHandlers().then(function(protos) {
                /* Prevent attempt to load "protocol/bonding" */
                delete protos.bonding;
@@ -130,17 +130,16 @@ function getProtocolHandlers(cache) {
 }
 
 function getWifiStateBySid(sid) {
-       var s = uci.get('wireless', sid);
+       const s = uci.get('wireless', sid);
 
        if (s != null && s['.type'] == 'wifi-iface') {
-               for (var radioname in _state.radios) {
-                       for (var i = 0; i < _state.radios[radioname].interfaces.length; i++) {
-                               var netstate = _state.radios[radioname].interfaces[i];
+               for (let radioname in _state.radios) {
+                       for (let netstate of _state.radios[radioname].interfaces) {
 
                                if (typeof(netstate.section) != 'string')
                                        continue;
 
-                               var s2 = uci.get('wireless', netstate.section);
+                               const s2 = uci.get('wireless', netstate.section);
 
                                if (s2 != null && s['.type'] == s2['.type'] && s['.name'] == s2['.name']) {
                                        if (s2['.anonymous'] == false && netstate.section.charAt(0) == '@')
@@ -156,9 +155,8 @@ function getWifiStateBySid(sid) {
 }
 
 function getWifiStateByIfname(ifname) {
-       for (var radioname in _state.radios) {
-               for (var i = 0; i < _state.radios[radioname].interfaces.length; i++) {
-                       var netstate = _state.radios[radioname].interfaces[i];
+       for (let radioname in _state.radios) {
+               for (let netstate of _state.radios[radioname].interfaces) {
 
                        if (typeof(netstate.ifname) != 'string')
                                continue;
@@ -172,23 +170,24 @@ function getWifiStateByIfname(ifname) {
 }
 
 function isWifiIfname(ifname) {
-       for (var i = 0; i < iface_patterns_wireless.length; i++)
-               if (iface_patterns_wireless[i].test(ifname))
+       for (let ifp of iface_patterns_wireless)
+               if (ifp.test(ifname))
                        return true;
 
        return false;
 }
 
 function getWifiSidByNetid(netid) {
-       var m = /^(\w+)\.network(\d+)$/.exec(netid);
+       const m = /^(\w+)\.network(\d+)$/.exec(netid);
        if (m) {
-               var sections = uci.sections('wireless', 'wifi-iface');
-               for (var i = 0, n = 0; i < sections.length; i++) {
-                       if (sections[i].device != m[1])
+               const sections = uci.sections('wireless', 'wifi-iface');
+               let n = 0;
+               for (let s of sections) {
+                       if (s.device != m[1])
                                continue;
 
                        if (++n == +m[2])
-                               return sections[i]['.name'];
+                               return s['.name'];
                }
        }
 
@@ -196,12 +195,12 @@ function getWifiSidByNetid(netid) {
 }
 
 function getWifiSidByIfname(ifname) {
-       var sid = getWifiSidByNetid(ifname);
+       const sid = getWifiSidByNetid(ifname);
 
        if (sid != null)
                return sid;
 
-       var res = getWifiStateByIfname(ifname);
+       const res = getWifiStateByIfname(ifname);
 
        if (res != null && L.isObject(res[2]) && typeof(res[2].section) == 'string')
                return res[2].section;
@@ -210,18 +209,19 @@ function getWifiSidByIfname(ifname) {
 }
 
 function getWifiNetidBySid(sid) {
-       var s = uci.get('wireless', sid);
+       const s = uci.get('wireless', sid);
        if (s != null && s['.type'] == 'wifi-iface') {
-               var radioname = s.device;
+               const radioname = s.device;
                if (typeof(radioname) == 'string') {
-                       var sections = uci.sections('wireless', 'wifi-iface');
-                       for (var i = 0, n = 0; i < sections.length; i++) {
-                               if (sections[i].device != s.device)
+                       const sections = uci.sections('wireless', 'wifi-iface');
+                       let n = 0;
+                       for (let s of sections) {
+                               if (s.device != s.device)
                                        continue;
 
                                n++;
 
-                               if (sections[i]['.name'] != s['.name'])
+                               if (s['.name'] != s['.name'])
                                        continue;
 
                                return [ '%s.network%d'.format(s.device, n), s.device ];
@@ -234,17 +234,17 @@ function getWifiNetidBySid(sid) {
 }
 
 function getWifiNetidByNetname(name) {
-       var sections = uci.sections('wireless', 'wifi-iface');
-       for (var i = 0; i < sections.length; i++) {
-               if (typeof(sections[i].network) != 'string')
+       const sections = uci.sections('wireless', 'wifi-iface');
+       for (let s of sections) {
+               if (typeof(s.network) != 'string')
                        continue;
 
-               var nets = sections[i].network.split(/\s+/);
-               for (var j = 0; j < nets.length; j++) {
-                       if (nets[j] != name)
+               const nets = s.network.split(/\s+/);
+               for (let n of nets) {
+                       if (n != name)
                                continue;
 
-                       return getWifiNetidBySid(sections[i]['.name']);
+                       return getWifiNetidBySid(s['.name']);
                }
        }
 
@@ -252,25 +252,25 @@ function getWifiNetidByNetname(name) {
 }
 
 function isVirtualIfname(ifname) {
-       for (var i = 0; i < iface_patterns_virtual.length; i++)
-               if (iface_patterns_virtual[i].test(ifname))
+       for (let nfp of iface_patterns_virtual)
+               if (nfp.test(ifname))
                        return true;
 
        return false;
 }
 
 function isIgnoredIfname(ifname) {
-       for (var i = 0; i < iface_patterns_ignore.length; i++)
-               if (iface_patterns_ignore[i].test(ifname))
+       for (let nfpi of iface_patterns_ignore)
+               if (nfpi.test(ifname))
                        return true;
 
        return false;
 }
 
 function appendValue(config, section, option, value) {
-       var values = uci.get(config, section, option),
-           isArray = Array.isArray(values),
-           rv = false;
+       let values = uci.get(config, section, option);
+       const isArray = Array.isArray(values);
+       let rv = false;
 
        if (isArray == false)
                values = L.toArray(values);
@@ -286,14 +286,14 @@ function appendValue(config, section, option, value) {
 }
 
 function removeValue(config, section, option, value) {
-       var values = uci.get(config, section, option),
-           isArray = Array.isArray(values),
-           rv = false;
+       let values = uci.get(config, section, option);
+       const isArray = Array.isArray(values);
+       let rv = false;
 
        if (isArray == false)
                values = L.toArray(values);
 
-       for (var i = values.length - 1; i >= 0; i--) {
+       for (let i = values.length - 1; i >= 0; i--) {
                if (values[i] == value) {
                        values.splice(i, 1);
                        rv = true;
@@ -309,14 +309,14 @@ function removeValue(config, section, option, value) {
 }
 
 function prefixToMask(bits, v6) {
-       var w = v6 ? 128 : 32,
-           m = [];
+       const w = v6 ? 128 : 32;
+       const m = [];
 
        if (bits > w)
                return null;
 
-       for (var i = 0; i < w / 16; i++) {
-               var b = Math.min(16, bits);
+       for (let i = 0; i < w / 16; i++) {
+               const b = Math.min(16, bits);
                m.push((0xffff << (16 - b)) & 0xffff);
                bits -= b;
        }
@@ -328,14 +328,14 @@ function prefixToMask(bits, v6) {
 }
 
 function maskToPrefix(mask, v6) {
-       var m = v6 ? validation.parseIPv6(mask) : validation.parseIPv4(mask);
+       const m = v6 ? validation.parseIPv6(mask) : validation.parseIPv4(mask);
 
        if (!m)
                return null;
 
-       var bits = 0;
+       let bits = 0;
 
-       for (var i = 0, z = false; i < m.length; i++) {
+       for (let i = 0, z = false; i < m.length; i++) {
                z = z || !m[i];
 
                while (!z && (m[i] & (v6 ? 0x8000 : 0x80))) {
@@ -363,19 +363,16 @@ function initNetworkState(refresh) {
                        L.resolveDefault(uci.load('network')),
                        hasWifi ? L.resolveDefault(uci.load('wireless')) : L.resolveDefault(),
                        L.resolveDefault(uci.load('luci'))
-               ]).then(function(data) {
-                       var netifd_ifaces = data[0],
-                           board_json    = data[1],
-                           luci_devs     = data[2];
+               ]).then(function([netifd_ifaces, board_json, luci_devs, radios, hosts]) {
 
-                       var s = {
+                       const s = {
                                isTunnel: {}, isBridge: {}, isSwitch: {}, isWifi: {},
-                               ifaces: netifd_ifaces, radios: data[3], hosts: data[4],
+                               ifaces: netifd_ifaces, radios: radios, hosts: hosts,
                                netdevs: {}, bridges: {}, switches: {}, hostapd: {}
                        };
 
-                       for (var name in luci_devs) {
-                               var dev = luci_devs[name];
+                       for (let name in luci_devs) {
+                               const dev = luci_devs[name];
 
                                if (isVirtualIfname(name))
                                        s.isTunnel[name] = true;
@@ -402,29 +399,29 @@ function initNetworkState(refresh) {
                                };
 
                                if (Array.isArray(dev.ipaddrs))
-                                       for (var i = 0; i < dev.ipaddrs.length; i++)
-                                               s.netdevs[name].ipaddrs.push(dev.ipaddrs[i].address + '/' + dev.ipaddrs[i].netmask);
+                                       for (let ip of dev.ipaddrs)
+                                               s.netdevs[name].ipaddrs.push(ip.address + '/' + ip.netmask);
 
                                if (Array.isArray(dev.ip6addrs))
-                                       for (var i = 0; i < dev.ip6addrs.length; i++)
-                                               s.netdevs[name].ip6addrs.push(dev.ip6addrs[i].address + '/' + dev.ip6addrs[i].netmask);
+                                       for (let ip6 of dev.ip6addrs)
+                                               s.netdevs[name].ip6addrs.push(ip6.address + '/' + ip6.netmask);
                        }
 
-                       for (var name in luci_devs) {
-                               var dev = luci_devs[name];
+                       for (let name in luci_devs) {
+                               const dev = luci_devs[name];
 
                                if (!dev.bridge)
                                        continue;
 
-                               var b = {
+                               const b = {
                                        name:    name,
                                        id:      dev.id,
                                        stp:     dev.stp,
                                        ifnames: []
                                };
 
-                               for (var i = 0; dev.ports && i < dev.ports.length; i++) {
-                                       var subdev = s.netdevs[dev.ports[i]];
+                               for (let port of dev.ports) {
+                                       const subdev = s.netdevs[port];
 
                                        if (subdev == null)
                                                continue;
@@ -437,8 +434,8 @@ function initNetworkState(refresh) {
                                s.isBridge[name] = true;
                        }
 
-                       for (var name in luci_devs) {
-                               var dev = luci_devs[name];
+                       for (let name in luci_devs) {
+                               const dev = luci_devs[name];
 
                                if (!dev.parent || dev.devtype != 'dsa')
                                        continue;
@@ -448,19 +445,19 @@ function initNetworkState(refresh) {
                        }
 
                        if (L.isObject(board_json.switch)) {
-                               for (var switchname in board_json.switch) {
-                                       var layout = board_json.switch[switchname],
-                                           netdevs = {},
-                                           nports = {},
-                                           ports = [],
-                                           pnum = null,
-                                           role = null;
+                               for (let switchname in board_json.switch) {
+                                       const layout = board_json.switch[switchname];
+                                       const netdevs = {};
+                                       const nports = {};
+                                       const ports = [];
+                                       let pnum = null;
+                                       let role = null;
 
                                        if (L.isObject(layout) && Array.isArray(layout.ports)) {
-                                               for (var i = 0, port; (port = layout.ports[i]) != null; i++) {
+                                               for (let port of layout.ports) {
                                                        if (typeof(port) == 'object' && typeof(port.num) == 'number' &&
                                                                (typeof(port.role) == 'string' || typeof(port.device) == 'string')) {
-                                                               var spec = {
+                                                               const spec = {
                                                                        num:   port.num,
                                                                        role:  port.role || 'cpu',
                                                                        index: (port.index != null) ? port.index : port.num
@@ -483,7 +480,7 @@ function initNetworkState(refresh) {
                                                        return L.naturalCompare(a.role, b.role) || L.naturalCompare(a.index, b.index);
                                                });
 
-                                               for (var i = 0, port; (port = ports[i]) != null; i++) {
+                                               for (let port of ports) {
                                                        if (port.role != role) {
                                                                role = port.role;
                                                                pnum = 1;
@@ -514,18 +511,18 @@ function initNetworkState(refresh) {
 
                        _init = null;
 
-                       var objects = [];
+                       const objects = [];
 
                        if (L.isObject(s.radios))
-                               for (var radio in s.radios)
+                               for (let radio in s.radios)
                                        if (L.isObject(s.radios[radio]) && Array.isArray(s.radios[radio].interfaces))
-                                               for (var i = 0; i < s.radios[radio].interfaces.length; i++)
-                                                       if (L.isObject(s.radios[radio].interfaces[i]) && s.radios[radio].interfaces[i].ifname)
-                                                               objects.push('hostapd.%s'.format(s.radios[radio].interfaces[i].ifname));
+                                               for (let ri of s.radios[radio].interfaces)
+                                                       if (L.isObject(ri) && ri.ifname)
+                                                               objects.push('hostapd.%s'.format(ri.ifname));
 
                        return (objects.length ? L.resolveDefault(rpc.list.apply(rpc, objects), {}) : Promise.resolve({})).then(function(res) {
-                               for (var k in res) {
-                                       var m = k.match(/^hostapd\.(.+)$/);
+                               for (let k in res) {
+                                       const m = k.match(/^hostapd\.(.+)$/);
                                        if (m)
                                                s.hostapd[m[1]] = res[k];
                                }
@@ -558,9 +555,9 @@ function networkSort(a, b) {
 }
 
 function deviceSort(a, b) {
-       var typeWeigth = { wifi: 2, alias: 3 };
+       const typeWeight = { wifi: 2, alias: 3 };
 
-       return L.naturalCompare(typeWeigth[a.getType()] || 1, typeWeigth[b.getType()] || 1) ||
+       return L.naturalCompare(typeWeight[a.getType()] || 1, typeWeight[b.getType()] || 1) ||
               L.naturalCompare(a.getName(), b.getName());
 }
 
@@ -571,17 +568,17 @@ function formatWifiEncryption(enc) {
        if (!enc.enabled)
                return 'None';
 
-       var ciphers = Array.isArray(enc.ciphers)
+       const ciphers = Array.isArray(enc.ciphers)
                ? enc.ciphers.map(function(c) { return c.toUpperCase() }) : [ 'NONE' ];
 
        if (Array.isArray(enc.wep)) {
-               var has_open = false,
-                   has_shared = false;
+               let has_open = false;
+               let has_shared = false;
 
-               for (var i = 0; i < enc.wep.length; i++)
-                       if (enc.wep[i] == 'open')
+               for (let wencr of enc.wep)
+                       if (wencr == 'open')
                                has_open = true;
-                       else if (enc.wep[i] == 'shared')
+                       else if (wencr == 'shared')
                                has_shared = true;
 
                if (has_open && has_shared)
@@ -595,18 +592,18 @@ function formatWifiEncryption(enc) {
        }
 
        if (Array.isArray(enc.wpa)) {
-               var versions = [],
-                   suites = Array.isArray(enc.authentication)
+               const versions = [];
+               const suites = Array.isArray(enc.authentication)
                        ? enc.authentication.map(function(a) { return a.toUpperCase() }) : [ 'NONE' ];
 
-               for (var i = 0; i < enc.wpa.length; i++)
-                       switch (enc.wpa[i]) {
+               for (let encr of enc.wpa)
+                       switch (encr) {
                        case 1:
                                versions.push('WPA');
                                break;
 
                        default:
-                               versions.push('WPA%d'.format(enc.wpa[i]));
+                               versions.push('WPA%d'.format(encr));
                                break;
                        }
 
@@ -620,20 +617,20 @@ function formatWifiEncryption(enc) {
 }
 
 function enumerateNetworks() {
-       var uciInterfaces = uci.sections('network', 'interface'),
-           networks = {};
+       const uciInterfaces = uci.sections('network', 'interface');
+       const networks = {};
 
-       for (var i = 0; i < uciInterfaces.length; i++)
-               networks[uciInterfaces[i]['.name']] = this.instantiateNetwork(uciInterfaces[i]['.name']);
+       for (let intf of uciInterfaces)
+               networks[intf['.name']] = this.instantiateNetwork(intf['.name']);
 
-       for (var i = 0; i < _state.ifaces.length; i++)
-               if (networks[_state.ifaces[i].interface] == null)
-                       networks[_state.ifaces[i].interface] =
-                               this.instantiateNetwork(_state.ifaces[i].interface, _state.ifaces[i].proto);
+       for (let ifstate of _state.ifaces)
+               if (networks[ifstate.interface] == null)
+                       networks[ifstate.interface] =
+                               this.instantiateNetwork(ifstate.interface, ifstate.proto);
 
-       var rv = [];
+       const rv = [];
 
-       for (var network in networks)
+       for (let network in networks)
                if (networks.hasOwnProperty(network))
                        rv.push(networks[network]);
 
@@ -643,7 +640,7 @@ function enumerateNetworks() {
 }
 
 
-var Hosts, Network, Protocol, Device, WifiDevice, WifiNetwork, WifiVlan;
+let Hosts, Network, Protocol, Device, WifiDevice, WifiNetwork, WifiVlan;
 
 /**
  * @namespace LuCI.network
@@ -762,7 +759,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * @returns {Promise<Object>}
         * Returns a promise resolving to the internal network state object.
         */
-       flushCache: function() {
+       flushCache() {
                initNetworkState(true);
                return _init;
        },
@@ -784,8 +781,8 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * Returns the instantiated protocol back-end class or `null` if the given
         * protocol isn't known.
         */
-       getProtocol: function(protoname, netname) {
-               var v = _protocols[protoname];
+       getProtocol(protoname, netname) {
+               const v = _protocols[protoname];
                if (v != null)
                        return new v(netname || '__dummy__');
 
@@ -799,10 +796,10 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * @returns {Array<LuCI.network.Protocol>}
         * Returns an array of protocol class instances.
         */
-       getProtocols: function() {
-               var rv = [];
+       getProtocols() {
+               const rv = [];
 
-               for (var protoname in _protocols)
+               for (let protoname in _protocols)
                        rv.push(new _protocols[protoname]('__dummy__'));
 
                return rv;
@@ -826,30 +823,30 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * @returns {LuCI.network.Protocol}
         * Returns the new `Protocol` subclass.
         */
-       registerProtocol: function(protoname, methods) {
-               var spec = L.isObject(_protospecs) ? _protospecs[protoname] : null;
-               var proto = Protocol.extend(Object.assign({
-                       getI18n: function() {
+       registerProtocol(protoname, methods) {
+               const spec = L.isObject(_protospecs) ? _protospecs[protoname] : null;
+               const proto = Protocol.extend(Object.assign({
+                       getI18n() {
                                return protoname;
                        },
 
-                       isFloating: function() {
+                       isFloating() {
                                return false;
                        },
 
-                       isVirtual: function() {
+                       isVirtual() {
                                return (L.isObject(spec) && spec.no_device == true);
                        },
 
-                       renderFormOptions: function(section) {
+                       renderFormOptions(section) {
 
                        }
                }, methods, {
-                       __init__: function(name) {
+                       __init__(name) {
                                this.sid = name;
                        },
 
-                       getProtocol: function() {
+                       getProtocol() {
                                return protoname;
                        }
                }));
@@ -867,7 +864,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * A `RegExp` instance to match a virtual interface name
         * such as `6in4-wan` or `tun0`.
         */
-       registerPatternVirtual: function(pat) {
+       registerPatternVirtual(pat) {
                iface_patterns_virtual.push(pat);
        },
 
@@ -887,7 +884,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * if either the arguments were invalid or if there already was a
         * description for the given code.
         */
-       registerErrorCode: function(code, message) {
+       registerErrorCode(code, message) {
                if (typeof(code) == 'string' &&
                    typeof(message) == 'string' &&
                    !proto_errors.hasOwnProperty(code)) {
@@ -918,14 +915,14 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * was invalid or if a non-empty network of the given name already
         * existed.
         */
-       addNetwork: function(name, options) {
+       addNetwork(name, options) {
                return this.getNetwork(name).then(L.bind(function(existingNetwork) {
                        if (name != null && /^[a-zA-Z0-9_]+$/.test(name) && existingNetwork == null) {
-                               var sid = uci.add('network', 'interface', name);
+                               const sid = uci.add('network', 'interface', name);
 
                                if (sid != null) {
                                        if (L.isObject(options))
-                                               for (var key in options)
+                                               for (let key in options)
                                                        if (options.hasOwnProperty(key))
                                                                uci.set('network', sid, key, options[key]);
 
@@ -934,7 +931,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                        }
                        else if (existingNetwork != null && existingNetwork.isEmpty()) {
                                if (L.isObject(options))
-                                       for (var key in options)
+                                       for (let key in options)
                                                if (options.hasOwnProperty(key))
                                                        existingNetwork.set(key, options[key]);
 
@@ -955,17 +952,17 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * {@link LuCI.network.Protocol Protocol} subclass instance describing
         * the network or `null` if the network did not exist.
         */
-       getNetwork: function(name) {
+       getNetwork(name) {
                return initNetworkState().then(L.bind(function() {
-                       var section = (name != null) ? uci.get('network', name) : null;
+                       const section = (name != null) ? uci.get('network', name) : null;
 
                        if (section != null && section['.type'] == 'interface') {
                                return this.instantiateNetwork(name);
                        }
                        else if (name != null) {
-                               for (var i = 0; i < _state.ifaces.length; i++)
-                                       if (_state.ifaces[i].interface == name)
-                                               return this.instantiateNetwork(name, _state.ifaces[i].proto);
+                               for (let ifc of _state.ifaces)
+                                       if (ifc.interface == name)
+                                               return this.instantiateNetwork(name, ifc.proto);
                        }
 
                        return null;
@@ -980,7 +977,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * {@link LuCI.network.Protocol Protocol} subclass instances
         * describing all known networks.
         */
-       getNetworks: function() {
+       getNetworks() {
                return initNetworkState().then(L.bind(enumerateNetworks, this));
        },
 
@@ -996,14 +993,14 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * references to it were successfully deleted from the configuration or
         * `false` if the given network could not be found.
         */
-       deleteNetwork: function(name) {
-               var requireFirewall = Promise.resolve(L.require('firewall')).catch(function() {}),
-                   loadDHCP = L.resolveDefault(uci.load('dhcp')),
-                   network = this.instantiateNetwork(name);
+       deleteNetwork(name) {
+               const requireFirewall = Promise.resolve(L.require('firewall')).catch(function() {});
+               const loadDHCP = L.resolveDefault(uci.load('dhcp'));
+               const network = this.instantiateNetwork(name);
 
                return Promise.all([ requireFirewall, loadDHCP, initNetworkState() ]).then(function(res) {
-                       var uciInterface = uci.get('network', name),
-                           firewall = res[0];
+                       const uciInterface = uci.get('network', name);
+                       const firewall = res[0];
 
                        if (uciInterface != null && uciInterface['.type'] == 'interface') {
                                return Promise.resolve(network ? network.deleteConfiguration() : null).then(function() {
@@ -1034,7 +1031,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                                        });
 
                                        uci.sections('wireless', 'wifi-iface', function(s) {
-                                               var networks = L.toArray(s.network).filter(function(network) { return network != name });
+                                               const networks = L.toArray(s.network).filter(function(network) { return network != name });
 
                                                if (networks.length > 0)
                                                        uci.set('wireless', s['.name'], 'network', networks.join(' '));
@@ -1076,19 +1073,19 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * a network with the new name already exists or if the network to
         * rename could not be found.
         */
-       renameNetwork: function(oldName, newName) {
+       renameNetwork(oldName, newName) {
                return initNetworkState().then(function() {
                        if (newName == null || !/^[a-zA-Z0-9_]+$/.test(newName) || uci.get('network', newName) != null)
                                return false;
 
-                       var oldNetwork = uci.get('network', oldName);
+                       const oldNetwork = uci.get('network', oldName);
 
                        if (oldNetwork == null || oldNetwork['.type'] != 'interface')
                                return false;
 
-                       var sid = uci.add('network', 'interface', newName);
+                       const sid = uci.add('network', 'interface', newName);
 
-                       for (var key in oldNetwork)
+                       for (let key in oldNetwork)
                                if (oldNetwork.hasOwnProperty(key) && key.charAt(0) != '.')
                                        uci.set('network', sid, key, oldNetwork[key]);
 
@@ -1113,7 +1110,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                        });
 
                        uci.sections('wireless', 'wifi-iface', function(s) {
-                               var networks = L.toArray(s.network).map(function(network) { return (network == oldName ? newName : network) });
+                               const networks = L.toArray(s.network).map(function(network) { return (network == oldName ? newName : network) });
 
                                if (networks.length > 0)
                                        uci.set('wireless', s['.name'], 'network', networks.join(' '));
@@ -1137,7 +1134,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * the network device or `null` if the given device name could not
         * be found.
         */
-       getDevice: function(name) {
+       getDevice(name) {
                return initNetworkState().then(L.bind(function() {
                        if (name == null)
                                return null;
@@ -1145,7 +1142,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                        if (_state.netdevs.hasOwnProperty(name))
                                return this.instantiateDevice(name);
 
-                       var netid = getWifiNetidBySid(name);
+                       const netid = getWifiNetidBySid(name);
                        if (netid != null)
                                return this.instantiateDevice(netid[0]);
 
@@ -1160,27 +1157,27 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * Returns a promise resolving to a sorted array of `Device` class
         * instances describing the network devices found on the system.
         */
-       getDevices: function() {
+       getDevices() {
                return initNetworkState().then(L.bind(function() {
-                       var devices = {};
+                       const devices = {};
 
                        /* find simple devices */
-                       var uciInterfaces = uci.sections('network', 'interface');
-                       for (var i = 0; i < uciInterfaces.length; i++) {
-                               var ifnames = L.toArray(uciInterfaces[i].ifname);
+                       const uciInterfaces = uci.sections('network', 'interface');
+                       for (let uif of uciInterfaces) {
+                               const ifnames = L.toArray(uif.ifname);
 
-                               for (var j = 0; j < ifnames.length; j++) {
-                                       if (ifnames[j].charAt(0) == '@')
+                               for (let ifn of ifnames) {
+                                       if (ifn.charAt(0) == '@')
                                                continue;
 
-                                       if (isIgnoredIfname(ifnames[j]) || isVirtualIfname(ifnames[j]) || isWifiIfname(ifnames[j]))
+                                       if (isIgnoredIfname(ifn) || isVirtualIfname(ifn) || isWifiIfname(ifn))
                                                continue;
 
-                                       devices[ifnames[j]] = this.instantiateDevice(ifnames[j]);
+                                       devices[ifn] = this.instantiateDevice(ifn);
                                }
                        }
 
-                       for (var ifname in _state.netdevs) {
+                       for (let ifname in _state.netdevs) {
                                if (devices.hasOwnProperty(ifname))
                                        continue;
 
@@ -1194,20 +1191,20 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                        }
 
                        /* find VLAN devices */
-                       var uciSwitchVLANs = uci.sections('network', 'switch_vlan');
-                       for (var i = 0; i < uciSwitchVLANs.length; i++) {
-                               if (typeof(uciSwitchVLANs[i].ports) != 'string' ||
-                                   typeof(uciSwitchVLANs[i].device) != 'string' ||
-                                   !_state.switches.hasOwnProperty(uciSwitchVLANs[i].device))
+                       const uciSwitchVLANs = uci.sections('network', 'switch_vlan');
+                       for (let sw of uciSwitchVLANs) {
+                               if (typeof(sw.ports) != 'string' ||
+                                   typeof(sw.device) != 'string' ||
+                                   !_state.switches.hasOwnProperty(sw.device))
                                        continue;
 
-                               var ports = uciSwitchVLANs[i].ports.split(/\s+/);
-                               for (var j = 0; j < ports.length; j++) {
-                                       var m = ports[j].match(/^(\d+)([tu]?)$/);
+                               const ports = sw.ports.split(/\s+/);
+                               for (let p of ports) {
+                                       let m = p.match(/^(\d+)([tu]?)$/);
                                        if (m == null)
                                                continue;
 
-                                       var netdev = _state.switches[uciSwitchVLANs[i].device].netdevs[m[1]];
+                                       let netdev = _state.switches[sw.device].netdevs[m[1]];
                                        if (netdev == null)
                                                continue;
 
@@ -1219,13 +1216,13 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                                        if (m[2] != 't')
                                                continue;
 
-                                       var vid = uciSwitchVLANs[i].vid || uciSwitchVLANs[i].vlan;
+                                       let vid = sw.vid || sw.vlan;
                                            vid = (vid != null ? +vid : null);
 
                                        if (vid == null || vid < 0 || vid > 4095)
                                                continue;
 
-                                       var vlandev = '%s.%d'.format(netdev, vid);
+                                       const vlandev = '%s.%d'.format(netdev, vid);
 
                                        if (!devices.hasOwnProperty(vlandev))
                                                devices[vlandev] = this.instantiateDevice(vlandev);
@@ -1235,13 +1232,13 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                        }
 
                        /* find bridge VLAN devices */
-                       var uciBridgeVLANs = uci.sections('network', 'bridge-vlan');
-                       for (var i = 0; i < uciBridgeVLANs.length; i++) {
-                               var basedev = uciBridgeVLANs[i].device,
-                                   local = uciBridgeVLANs[i].local,
-                                   alias = uciBridgeVLANs[i].alias,
-                                   vid = +uciBridgeVLANs[i].vlan,
-                                   ports = L.toArray(uciBridgeVLANs[i].ports);
+                       const uciBridgeVLANs = uci.sections('network', 'bridge-vlan');
+                       for (let bvl of uciBridgeVLANs) {
+                               const basedev = bvl.device;
+                               const local = bvl.local;
+                               const alias = bvl.alias;
+                               const vid = +bvl.vlan;
+                               const ports = L.toArray(bvl.ports);
 
                                if (local == '0')
                                        continue;
@@ -1249,7 +1246,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                                if (isNaN(vid) || vid < 0 || vid > 4095)
                                        continue;
 
-                               var vlandev = '%s.%s'.format(basedev, alias || vid);
+                               const vlandev = '%s.%s'.format(basedev, alias || vid);
 
                                _state.isBridge[basedev] = true;
 
@@ -1263,8 +1260,8 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                                        devices[vlandev] = this.instantiateDevice(vlandev);
 
                                ports.forEach(function(port_name) {
-                                       var m = port_name.match(/^([^:]+)(?::[ut*]+)?$/),
-                                           p = m ? m[1] : null;
+                                       const m = port_name.match(/^([^:]+)(?::[ut*]+)?$/);
+                                       const p = m ? m[1] : null;
 
                                        if (!p)
                                                return;
@@ -1288,26 +1285,26 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                        }
 
                        /* find wireless interfaces */
-                       var uciWifiIfaces = uci.sections('wireless', 'wifi-iface'),
-                           networkCount = {};
+                       const uciWifiIfaces = uci.sections('wireless', 'wifi-iface');
+                       const networkCount = {};
 
-                       for (var i = 0; i < uciWifiIfaces.length; i++) {
-                               if (typeof(uciWifiIfaces[i].device) != 'string')
+                       for (let wf_if of uciWifiIfaces) {
+                               if (typeof(wf_if.device) != 'string')
                                        continue;
 
-                               networkCount[uciWifiIfaces[i].device] = (networkCount[uciWifiIfaces[i].device] || 0) + 1;
+                               networkCount[wf_if.device] = (networkCount[wf_if.device] || 0) + 1;
 
-                               var netid = '%s.network%d'.format(uciWifiIfaces[i].device, networkCount[uciWifiIfaces[i].device]);
+                               const netid = '%s.network%d'.format(wf_if.device, networkCount[wf_if.device]);
 
                                devices[netid] = this.instantiateDevice(netid);
                        }
 
                        /* find uci declared devices */
-                       var uciDevices = uci.sections('network', 'device');
+                       const uciDevices = uci.sections('network', 'device');
 
-                       for (var i = 0; i < uciDevices.length; i++) {
-                               var type = uciDevices[i].type,
-                                   name = uciDevices[i].name;
+                       for (let d of uciDevices) {
+                               const type = d.type;
+                               const name = d.name;
 
                                if (!type || !name || devices.hasOwnProperty(name))
                                        continue;
@@ -1318,9 +1315,9 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                                devices[name] = this.instantiateDevice(name);
                        }
 
-                       var rv = [];
+                       const rv = [];
 
-                       for (var netdev in devices)
+                       for (let netdev in devices)
                                if (devices.hasOwnProperty(netdev))
                                        rv.push(devices[netdev]);
 
@@ -1345,7 +1342,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * Returns `true` if the given name is in the ignore-pattern list,
         * else returns `false`.
         */
-       isIgnoredDevice: function(name) {
+       isIgnoredDevice(name) {
                return isIgnoredIfname(name);
        },
 
@@ -1362,9 +1359,9 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * the underlying radio device or `null` if the wireless radio could not
         * be found.
         */
-       getWifiDevice: function(devname) {
+       getWifiDevice(devname) {
                return initNetworkState().then(L.bind(function() {
-                       var existingDevice = uci.get('wireless', devname);
+                       const existingDevice = uci.get('wireless', devname);
 
                        if (existingDevice == null || existingDevice['.type'] != 'wifi-device')
                                return null;
@@ -1382,13 +1379,13 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * The order of the array corresponds to the order of the radios in
         * the configuration.
         */
-       getWifiDevices: function() {
+       getWifiDevices() {
                return initNetworkState().then(L.bind(function() {
-                       var uciWifiDevices = uci.sections('wireless', 'wifi-device'),
-                           rv = [];
+                       const uciWifiDevices = uci.sections('wireless', 'wifi-device');
+                       const rv = [];
 
-                       for (var i = 0; i < uciWifiDevices.length; i++) {
-                               var devname = uciWifiDevices[i]['.name'];
+                       for (let wfd of uciWifiDevices) {
+                               const devname = wfd['.name'];
                                rv.push(this.instantiateWifiDevice(devname, _state.radios[devname] || {}));
                        }
 
@@ -1411,7 +1408,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * the wireless network or `null` if the corresponding network could not
         * be found.
         */
-       getWifiNetwork: function(netname) {
+       getWifiNetwork(netname) {
                return initNetworkState()
                        .then(L.bind(this.lookupWifiNetwork, this, netname));
        },
@@ -1425,13 +1422,13 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * describing the wireless networks. The array will be empty if no networks
         * are found.
         */
-       getWifiNetworks: function() {
+       getWifiNetworks() {
                return initNetworkState().then(L.bind(function() {
-                       var wifiIfaces = uci.sections('wireless', 'wifi-iface'),
-                           rv = [];
+                       const wifiIfaces = uci.sections('wireless', 'wifi-iface');
+                       const rv = [];
 
-                       for (var i = 0; i < wifiIfaces.length; i++)
-                               rv.push(this.lookupWifiNetwork(wifiIfaces[i]['.name']));
+                       for (let wf_if of wifiIfaces)
+                               rv.push(this.lookupWifiNetwork(wf_if['.name']));
 
                        rv.sort(function(a, b) {
                                return L.naturalCompare(a.getID(), b.getID());
@@ -1455,25 +1452,25 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * the newly added wireless network or `null` if the given options
         * were invalid or if the associated radio device could not be found.
         */
-       addWifiNetwork: function(options) {
+       addWifiNetwork(options) {
                return initNetworkState().then(L.bind(function() {
                        if (options == null ||
                            typeof(options) != 'object' ||
                            typeof(options.device) != 'string')
                            return null;
 
-                       var existingDevice = uci.get('wireless', options.device);
+                       const existingDevice = uci.get('wireless', options.device);
                        if (existingDevice == null || existingDevice['.type'] != 'wifi-device')
                                return null;
 
                        /* XXX: need to add a named section (wifinet#) here */
-                       var sid = uci.add('wireless', 'wifi-iface');
-                       for (var key in options)
+                       const sid = uci.add('wireless', 'wifi-iface');
+                       for (let key in options)
                                if (options.hasOwnProperty(key))
                                        uci.set('wireless', sid, key, options[key]);
 
-                       var radioname = existingDevice['.name'],
-                           netid = getWifiNetidBySid(sid) || [];
+                       const radioname = existingDevice['.name'];
+                       const netid = getWifiNetidBySid(sid) || [];
 
                        return this.instantiateWifiNetwork(sid, radioname, _state.radios[radioname], netid[0], null);
                }, this));
@@ -1493,9 +1490,9 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * successfully deleted from the configuration or `false` if it could not
         * be found.
         */
-       deleteWifiNetwork: function(netname) {
+       deleteWifiNetwork(netname) {
                return initNetworkState().then(L.bind(function() {
-                       var sid = getWifiSidByIfname(netname);
+                       const sid = getWifiSidByIfname(netname);
 
                        if (sid == null)
                                return false;
@@ -1506,28 +1503,28 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
        },
 
        /* private */
-       getStatusByRoute: function(addr, mask) {
+       getStatusByRoute(addr, mask) {
                return initNetworkState().then(L.bind(function() {
-                       var rv = [];
+                       const rv = [];
 
-                       for (var i = 0; i < _state.ifaces.length; i++) {
-                               if (!Array.isArray(_state.ifaces[i].route))
+                       for (let sif of _state.ifaces) {
+                               if (!Array.isArray(sif.route))
                                        continue;
 
-                               for (var j = 0; j < _state.ifaces[i].route.length; j++) {
-                                       if (typeof(_state.ifaces[i].route[j]) != 'object' ||
-                                           typeof(_state.ifaces[i].route[j].target) != 'string' ||
-                                           typeof(_state.ifaces[i].route[j].mask) != 'number')
+                               for (let sifr of sif.route) {
+                                       if (typeof(sifr) != 'object' ||
+                                           typeof(sifr.target) != 'string' ||
+                                           typeof(sifr.mask) != 'number')
                                            continue;
 
-                                       if (_state.ifaces[i].route[j].table)
+                                       if (sifr.table)
                                                continue;
 
-                                       if (_state.ifaces[i].route[j].target != addr ||
-                                           _state.ifaces[i].route[j].mask != mask)
+                                       if (sifr.target != addr ||
+                                           sifr.mask != mask)
                                            continue;
 
-                                       rv.push(_state.ifaces[i]);
+                                       rv.push(sif);
                                }
                        }
 
@@ -1540,29 +1537,27 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
        },
 
        /* private */
-       getStatusByAddress: function(addr) {
+       getStatusByAddress(addr) {
                return initNetworkState().then(L.bind(function() {
-                       var rv = [];
-
-                       for (var i = 0; i < _state.ifaces.length; i++) {
-                               if (Array.isArray(_state.ifaces[i]['ipv4-address']))
-                                       for (var j = 0; j < _state.ifaces[i]['ipv4-address'].length; j++)
-                                               if (typeof(_state.ifaces[i]['ipv4-address'][j]) == 'object' &&
-                                                   _state.ifaces[i]['ipv4-address'][j].address == addr)
-                                                       return _state.ifaces[i];
-
-                               if (Array.isArray(_state.ifaces[i]['ipv6-address']))
-                                       for (var j = 0; j < _state.ifaces[i]['ipv6-address'].length; j++)
-                                               if (typeof(_state.ifaces[i]['ipv6-address'][j]) == 'object' &&
-                                                   _state.ifaces[i]['ipv6-address'][j].address == addr)
-                                                       return _state.ifaces[i];
-
-                               if (Array.isArray(_state.ifaces[i]['ipv6-prefix-assignment']))
-                                       for (var j = 0; j < _state.ifaces[i]['ipv6-prefix-assignment'].length; j++)
-                                               if (typeof(_state.ifaces[i]['ipv6-prefix-assignment'][j]) == 'object' &&
-                                                       typeof(_state.ifaces[i]['ipv6-prefix-assignment'][j]['local-address']) == 'object' &&
-                                                   _state.ifaces[i]['ipv6-prefix-assignment'][j]['local-address'].address == addr)
-                                                       return _state.ifaces[i];
+                       for (let sif of _state.ifaces) {
+                               if (Array.isArray(sif['ipv4-address']))
+                                       for (let a of sif['ipv4-address'])
+                                               if (typeof(a) == 'object' &&
+                                                   a.address == addr)
+                                                       return sif;
+
+                               if (Array.isArray(sif['ipv6-address']))
+                                       for (let a of sif['ipv6-address'])
+                                               if (typeof(a) == 'object' &&
+                                                   a.address == addr)
+                                                       return sif;
+
+                               if (Array.isArray(sif['ipv6-prefix-assignment']))
+                                       for (let a of sif['ipv6-prefix-assignment'])
+                                               if (typeof(a) == 'object' &&
+                                                       typeof(a['local-address']) == 'object' &&
+                                                   a['local-address'].address == addr)
+                                                       return sif;
                        }
 
                        return null;
@@ -1579,14 +1574,14 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * Returns a promise resolving to an array of `Protocol` subclass
         * instances describing the found default route interfaces.
         */
-       getWANNetworks: function() {
+       getWANNetworks() {
                return this.getStatusByRoute('0.0.0.0', 0).then(L.bind(function(statuses) {
-                       var rv = [], seen = {};
+                       const rv = [], seen = {};
 
-                       for (var i = 0; i < statuses.length; i++) {
-                               if (!seen.hasOwnProperty(statuses[i].interface)) {
-                                       rv.push(this.instantiateNetwork(statuses[i].interface, statuses[i].proto));
-                                       seen[statuses[i].interface] = true;
+                       for (let s of statuses) {
+                               if (!seen.hasOwnProperty(s.interface)) {
+                                       rv.push(this.instantiateNetwork(s.interface, s.proto));
+                                       seen[s.interface] = true;
                                }
                        }
 
@@ -1604,14 +1599,14 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * Returns a promise resolving to an array of `Protocol` subclass
         * instances describing the found IPv6 default route interfaces.
         */
-       getWAN6Networks: function() {
+       getWAN6Networks() {
                return this.getStatusByRoute('::', 0).then(L.bind(function(statuses) {
-                       var rv = [], seen = {};
+                       const rv = [], seen = {};
 
-                       for (var i = 0; i < statuses.length; i++) {
-                               if (!seen.hasOwnProperty(statuses[i].interface)) {
-                                       rv.push(this.instantiateNetwork(statuses[i].interface, statuses[i].proto));
-                                       seen[statuses[i].interface] = true;
+                       for (let s of statuses) {
+                               if (!seen.hasOwnProperty(s.interface)) {
+                                       rv.push(this.instantiateNetwork(s.interface, s.proto));
+                                       seen[s.interface] = true;
                                }
                        }
 
@@ -1653,25 +1648,25 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * {@link LuCI.network.SwitchTopology SwitchTopology} objects describing
         * the layout.
         */
-       getSwitchTopologies: function() {
+       getSwitchTopologies() {
                return initNetworkState().then(function() {
                        return _state.switches;
                });
        },
 
        /* private */
-       instantiateNetwork: function(name, proto) {
+       instantiateNetwork(name, proto) {
                if (name == null)
                        return null;
 
                proto = (proto == null ? (uci.get('network', name, 'proto') || 'none') : proto);
 
-               var protoClass = _protocols[proto] || Protocol;
+               const protoClass = _protocols[proto] || Protocol;
                return new protoClass(name);
        },
 
        /* private */
-       instantiateDevice: function(name, network, extend) {
+       instantiateDevice(name, network, extend) {
                if (extend != null)
                        return new (Device.extend(extend))(name, network);
 
@@ -1679,18 +1674,18 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
        },
 
        /* private */
-       instantiateWifiDevice: function(radioname, radiostate) {
+       instantiateWifiDevice(radioname, radiostate) {
                return new WifiDevice(radioname, radiostate);
        },
 
        /* private */
-       instantiateWifiNetwork: function(sid, radioname, radiostate, netid, netstate, hostapd) {
+       instantiateWifiNetwork(sid, radioname, radiostate, netid, netstate, hostapd) {
                return new WifiNetwork(sid, radioname, radiostate, netid, netstate, hostapd);
        },
 
        /* private */
-       lookupWifiNetwork: function(netname) {
-               var sid, res, netid, radioname, radiostate, netstate;
+       lookupWifiNetwork(netname) {
+               let sid, res, netid, radioname, radiostate, netstate;
 
                sid = getWifiSidByNetid(netname);
 
@@ -1748,7 +1743,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * Returns a string containing the device name or `null` if the given
         * object could not be converted to a name.
         */
-       getIfnameOf: function(obj) {
+       getIfnameOf(obj) {
                return ifnameOf(obj);
        },
 
@@ -1759,7 +1754,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * Returns a promise resolving to the type of the internal modem
         * (e.g. `vdsl`) or to `null` if no internal modem is present.
         */
-       getDSLModemType: function() {
+       getDSLModemType() {
                return initNetworkState().then(function() {
                        return _state.hasDSLModem ? _state.hasDSLModem.type : null;
                });
@@ -1776,7 +1771,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
         * @returns {Promise<LuCI.network.Hosts>}
         * Returns a `Hosts` instance describing a host known on the system.
         */
-       getHostHints: function() {
+       getHostHints() {
                return initNetworkState().then(function() {
                        return new Hosts(_state.hosts);
                });
@@ -1794,7 +1789,7 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
  * host information by different criteria.
  */
 Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
-       __init__: function(hosts) {
+       __init__(hosts) {
                this.hosts = hosts;
        },
 
@@ -1809,7 +1804,7 @@ Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
         * no matching host could be found or if no hostname is known for
         * the corresponding host.
         */
-       getHostnameByMACAddr: function(mac) {
+       getHostnameByMACAddr(mac) {
                return this.hosts[mac]
                        ? (this.hosts[mac].name || null)
                        : null;
@@ -1826,7 +1821,7 @@ Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
         * no matching host could be found or if no IPv4 address is known for
         * the corresponding host.
         */
-       getIPAddrByMACAddr: function(mac) {
+       getIPAddrByMACAddr(mac) {
                return this.hosts[mac]
                        ? (L.toArray(this.hosts[mac].ipaddrs || this.hosts[mac].ipv4)[0] || null)
                        : null;
@@ -1843,7 +1838,7 @@ Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
         * no matching host could be found or if no IPv6 address is known for
         * the corresponding host.
         */
-       getIP6AddrByMACAddr: function(mac) {
+       getIP6AddrByMACAddr(mac) {
                return this.hosts[mac]
                        ? (L.toArray(this.hosts[mac].ip6addrs || this.hosts[mac].ipv6)[0] || null)
                        : null;
@@ -1860,15 +1855,15 @@ Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
         * no matching host could be found or if no hostname is known for
         * the corresponding host.
         */
-       getHostnameByIPAddr: function(ipaddr) {
-               for (var mac in this.hosts) {
+       getHostnameByIPAddr(ipaddr) {
+               for (let mac in this.hosts) {
                        if (this.hosts[mac].name == null)
                                continue;
 
-                       var addrs = L.toArray(this.hosts[mac].ipaddrs || this.hosts[mac].ipv4);
+                       const addrs = L.toArray(this.hosts[mac].ipaddrs || this.hosts[mac].ipv4);
 
-                       for (var i = 0; i < addrs.length; i++)
-                               if (addrs[i] == ipaddr)
+                       for (let a of addrs)
+                               if (a == ipaddr)
                                        return this.hosts[mac].name;
                }
 
@@ -1886,12 +1881,12 @@ Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
         * no matching host could be found or if no MAC address is known for
         * the corresponding host.
         */
-       getMACAddrByIPAddr: function(ipaddr) {
-               for (var mac in this.hosts) {
-                       var addrs = L.toArray(this.hosts[mac].ipaddrs || this.hosts[mac].ipv4);
+       getMACAddrByIPAddr(ipaddr) {
+               for (let mac in this.hosts) {
+                       const addrs = L.toArray(this.hosts[mac].ipaddrs || this.hosts[mac].ipv4);
 
-                       for (var i = 0; i < addrs.length; i++)
-                               if (addrs[i] == ipaddr)
+                       for (let a of addrs)
+                               if (a == ipaddr)
                                        return mac;
                }
 
@@ -1909,15 +1904,15 @@ Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
         * no matching host could be found or if no hostname is known for
         * the corresponding host.
         */
-       getHostnameByIP6Addr: function(ip6addr) {
-               for (var mac in this.hosts) {
+       getHostnameByIP6Addr(ip6addr) {
+               for (let mac in this.hosts) {
                        if (this.hosts[mac].name == null)
                                continue;
 
-                       var addrs = L.toArray(this.hosts[mac].ip6addrs || this.hosts[mac].ipv6);
+                       const addrs = L.toArray(this.hosts[mac].ip6addrs || this.hosts[mac].ipv6);
 
-                       for (var i = 0; i < addrs.length; i++)
-                               if (addrs[i] == ip6addr)
+                       for (let a of addrs)
+                               if (a == ip6addr)
                                        return this.hosts[mac].name;
                }
 
@@ -1935,12 +1930,12 @@ Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
         * no matching host could be found or if no MAC address is known for
         * the corresponding host.
         */
-       getMACAddrByIP6Addr: function(ip6addr) {
-               for (var mac in this.hosts) {
-                       var addrs = L.toArray(this.hosts[mac].ip6addrs || this.hosts[mac].ipv6);
+       getMACAddrByIP6Addr(ip6addr) {
+               for (let mac in this.hosts) {
+                       const addrs = L.toArray(this.hosts[mac].ip6addrs || this.hosts[mac].ipv6);
 
-                       for (var i = 0; i < addrs.length; i++)
-                               if (addrs[i] == ip6addr)
+                       for (let a of addrs)
+                               if (a == ip6addr)
                                        return mac;
                }
 
@@ -1968,11 +1963,11 @@ Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
         * `preferIP6` flag specifies whether the IPv6 or the IPv4 address
         * is used as hint.
         */
-       getMACHints: function(preferIp6) {
-               var rv = [];
+       getMACHints(preferIp6) {
+               const rv = [];
 
-               for (var mac in this.hosts) {
-                       var hint = this.hosts[mac].name ||
+               for (let mac in this.hosts) {
+                       const hint = this.hosts[mac].name ||
                                L.toArray(this.hosts[mac][preferIp6 ? 'ip6addrs' : 'ipaddrs'] || this.hosts[mac][preferIp6 ? 'ipv6' : 'ipv4'])[0] ||
                                L.toArray(this.hosts[mac][preferIp6 ? 'ipaddrs' : 'ip6addrs'] || this.hosts[mac][preferIp6 ? 'ipv4' : 'ipv6'])[0];
 
@@ -1996,12 +1991,12 @@ Hosts = baseclass.extend(/** @lends LuCI.network.Hosts.prototype */ {
  * interface` sections in `/etc/config/network`.
  */
 Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
-       __init__: function(name) {
+       __init__(name) {
                this.sid = name;
        },
 
-       _get: function(opt) {
-               var val = uci.get('network', this.sid, opt);
+       _get(opt) {
+               const val = uci.get('network', this.sid, opt);
 
                if (Array.isArray(val))
                        return val.join(' ');
@@ -2009,12 +2004,12 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
                return val || '';
        },
 
-       _ubus: function(field) {
-               for (var i = 0; i < _state.ifaces.length; i++) {
-                       if (_state.ifaces[i].interface != this.sid)
+       _ubus(field) {
+               for (let sif of _state.ifaces) {
+                       if (sif.interface != this.sid)
                                continue;
 
-                       return (field != null ? _state.ifaces[i][field] : _state.ifaces[i]);
+                       return (field != null ? sif[field] : sif);
                }
        },
 
@@ -2028,7 +2023,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the UCI option value or `null` if the requested option is
         * not found.
         */
-       get: function(opt) {
+       get(opt) {
                return uci.get('network', this.sid, opt);
        },
 
@@ -2043,7 +2038,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * configuration.
         * @returns {null}
         */
-       set: function(opt, val) {
+       set(opt, val) {
                return uci.set('network', this.sid, opt, val);
        },
 
@@ -2054,8 +2049,8 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the name of the associated network device or `null` if
         * it could not be determined.
         */
-       getIfname: function() {
-               var ifname;
+       getIfname() {
+               let ifname;
 
                if (this.isFloating())
                        ifname = this._ubus('l3_device');
@@ -2065,7 +2060,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
                if (ifname != null)
                        return ifname;
 
-               var res = getWifiNetidByNetname(this.sid);
+               const res = getWifiNetidByNetname(this.sid);
                return (res != null ? res[0] : null);
        },
 
@@ -2080,7 +2075,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the name of the network protocol implementation, e.g.
         * `static` or `dhcp`.
         */
-       getProtocol: function() {
+       getProtocol() {
                return null;
        },
 
@@ -2094,7 +2089,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * @returns {string}
         * Returns the description string.
         */
-       getI18n: function() {
+       getI18n() {
                switch (this.getProtocol()) {
                case 'none':   return _('Unmanaged');
                case 'static': return _('Static address');
@@ -2114,7 +2109,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the value of the `type` option of the associated logical
         * interface or `null` if no `type` option is set.
         */
-       getType: function() {
+       getType() {
                return this._get('type');
        },
 
@@ -2124,7 +2119,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * @returns {string}
         * Returns the logical interface name, such as `lan` or `wan`.
         */
-       getName: function() {
+       getName() {
                return this.sid;
        },
 
@@ -2134,7 +2129,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * @returns {number}
         * Returns the uptime of the associated interface in seconds.
         */
-       getUptime: function() {
+       getUptime() {
                return this._ubus('uptime') || 0;
        },
 
@@ -2149,26 +2144,26 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the number of seconds until the lease expires or `-1`
         * if it isn't applicable to the associated protocol.
         */
-       getExpiry: function() {
-               var u = this._ubus('uptime'),
-                   d = this._ubus('data'),
-                   v6_prefixes = this._ubus('ipv6-prefix'),
-                   v6_addresses = this._ubus('ipv6-address');
+       getExpiry() {
+               const u = this._ubus('uptime');
+               const d = this._ubus('data');
+               const v6_prefixes = this._ubus('ipv6-prefix');
+               const v6_addresses = this._ubus('ipv6-address');
 
                if (typeof(u) == 'number' && d != null) {
 
                        // DHCPv4 or leasetime in data
                        if(typeof(d) == 'object' && typeof(d.leasetime) == 'number') {
-                               var r = d.leasetime - (u % d.leasetime);
+                               const r = d.leasetime - (u % d.leasetime);
                                return (r > 0 ? r : 0);
                        }
 
                        // DHCPv6, we can have multiple IPs and prefixes
                        if (Array.isArray(v6_prefixes) || Array.isArray(v6_addresses)) {
-                               var prefixes = [...v6_prefixes, ...v6_addresses];
+                               const prefixes = [...v6_prefixes, ...v6_addresses];
 
                                if(prefixes.length && typeof(prefixes[0].valid) == 'number') {
-                                       var r = prefixes[0].valid;
+                                       const r = prefixes[0].valid;
                                        return (r > 0 ? r : 0);
                                }
                        }
@@ -2184,7 +2179,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the current metric value used for device and network
         * routes spawned by the associated logical interface.
         */
-       getMetric: function() {
+       getMetric() {
                return this._ubus('metric') || 0;
        },
 
@@ -2200,8 +2195,8 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * `ubus` runtime information or `null` if the remote protocol
         * handler didn't request a zone.
         */
-       getZoneName: function() {
-               var d = this._ubus('data');
+       getZoneName() {
+               const d = this._ubus('data');
 
                if (L.isObject(d) && typeof(d.zone) == 'string')
                        return d.zone;
@@ -2216,8 +2211,8 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the primary IPv4 address registered by the protocol handler
         * or `null` if no IPv4 addresses were set.
         */
-       getIPAddr: function() {
-               var addrs = this._ubus('ipv4-address');
+       getIPAddr() {
+               const addrs = this._ubus('ipv4-address');
                return ((Array.isArray(addrs) && addrs.length) ? addrs[0].address : null);
        },
 
@@ -2229,13 +2224,13 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * registered by the protocol handler. The order of the resulting array
         * follows the order of the addresses in `ubus` runtime information.
         */
-       getIPAddrs: function() {
-               var addrs = this._ubus('ipv4-address'),
-                   rv = [];
+       getIPAddrs() {
+               const addrs = this._ubus('ipv4-address');
+               const rv = [];
 
                if (Array.isArray(addrs))
-                       for (var i = 0; i < addrs.length; i++)
-                               rv.push('%s/%d'.format(addrs[i].address, addrs[i].mask));
+                       for (let a of addrs)
+                               rv.push('%s/%d'.format(a.address, a.mask));
 
                return rv;
        },
@@ -2247,8 +2242,8 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the netmask of the primary IPv4 address registered by the
         * protocol handler or `null` if no IPv4 addresses were set.
         */
-       getNetmask: function() {
-               var addrs = this._ubus('ipv4-address');
+       getNetmask() {
+               const addrs = this._ubus('ipv4-address');
                if (Array.isArray(addrs) && addrs.length)
                        return prefixToMask(addrs[0].mask, false);
        },
@@ -2261,15 +2256,15 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns a string containing the IPv4 nexthop address of the associated
         * default route or `null` if no default route was found.
         */
-       getGatewayAddr: function() {
-               var routes = this._ubus('route');
+       getGatewayAddr() {
+               const routes = this._ubus('route');
 
                if (Array.isArray(routes))
-                       for (var i = 0; i < routes.length; i++)
-                               if (typeof(routes[i]) == 'object' &&
-                                   routes[i].target == '0.0.0.0' &&
-                                   routes[i].mask == 0)
-                                   return routes[i].nexthop;
+                       for (let r of routes)
+                               if (typeof(r) == 'object' &&
+                                   r.target == '0.0.0.0' &&
+                                   r.mask == 0)
+                                   return r.nexthop;
 
                return null;
        },
@@ -2281,14 +2276,14 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns an array of IPv4 DNS servers registered by the remote
         * protocol back-end.
         */
-       getDNSAddrs: function() {
-               var addrs = this._ubus('dns-server'),
-                   rv = [];
+       getDNSAddrs() {
+               const addrs = this._ubus('dns-server');
+               const rv = [];
 
                if (Array.isArray(addrs))
-                       for (var i = 0; i < addrs.length; i++)
-                               if (!/:/.test(addrs[i]))
-                                       rv.push(addrs[i]);
+                       for (let a of addrs)
+                               if (!/:/.test(a))
+                                       rv.push(a);
 
                return rv;
        },
@@ -2300,8 +2295,8 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the primary IPv6 address registered by the protocol handler
         * in CIDR notation or `null` if no IPv6 addresses were set.
         */
-       getIP6Addr: function() {
-               var addrs = this._ubus('ipv6-address');
+       getIP6Addr() {
+               let addrs = this._ubus('ipv6-address');
 
                if (Array.isArray(addrs) && L.isObject(addrs[0]))
                        return '%s/%d'.format(addrs[0].address, addrs[0].mask);
@@ -2322,21 +2317,21 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * registered by the protocol handler. The order of the resulting array
         * follows the order of the addresses in `ubus` runtime information.
         */
-       getIP6Addrs: function() {
-               var addrs = this._ubus('ipv6-address'),
-                   rv = [];
+       getIP6Addrs() {
+               let addrs = this._ubus('ipv6-address');
+               const rv = [];
 
                if (Array.isArray(addrs))
-                       for (var i = 0; i < addrs.length; i++)
-                               if (L.isObject(addrs[i]))
-                                       rv.push('%s/%d'.format(addrs[i].address, addrs[i].mask));
+                       for (let a of addrs)
+                               if (L.isObject(a))
+                                       rv.push('%s/%d'.format(a.address, a.mask));
 
                addrs = this._ubus('ipv6-prefix-assignment');
 
                if (Array.isArray(addrs))
-                       for (var i = 0; i < addrs.length; i++)
-                               if (L.isObject(addrs[i]) && L.isObject(addrs[i]['local-address']))
-                                       rv.push('%s/%d'.format(addrs[i]['local-address'].address, addrs[i]['local-address'].mask));
+                       for (let a of addrs)
+                               if (L.isObject(a) && L.isObject(a['local-address']))
+                                       rv.push('%s/%d'.format(a['local-address'].address, a['local-address'].mask));
 
                return rv;
        },
@@ -2349,15 +2344,15 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns a string containing the IPv6 nexthop address of the associated
         * default route or `null` if no default route was found.
         */
-       getGateway6Addr: function() {
-               var routes = this._ubus('route');
+       getGateway6Addr() {
+               const routes = this._ubus('route');
 
                if (Array.isArray(routes))
-                       for (var i = 0; i < routes.length; i++)
-                               if (typeof(routes[i]) == 'object' &&
-                                   routes[i].target == '::' &&
-                                   routes[i].mask == 0)
-                                   return routes[i].nexthop;
+                       for (let r of routes)
+                               if (typeof(r) == 'object' &&
+                                   r.target == '::' &&
+                                   r.mask == 0)
+                                   return r.nexthop;
 
                return null;
        },
@@ -2369,14 +2364,14 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns an array of IPv6 DNS servers registered by the remote
         * protocol back-end.
         */
-       getDNS6Addrs: function() {
-               var addrs = this._ubus('dns-server'),
-                   rv = [];
+       getDNS6Addrs() {
+               const addrs = this._ubus('dns-server');
+               const rv = [];
 
                if (Array.isArray(addrs))
-                       for (var i = 0; i < addrs.length; i++)
-                               if (/:/.test(addrs[i]))
-                                       rv.push(addrs[i]);
+                       for (let a of addrs)
+                               if (/:/.test(a))
+                                       rv.push(a);
 
                return rv;
        },
@@ -2388,8 +2383,8 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the routed IPv6 prefix registered by the remote protocol
         * handler or `null` if no prefix is present.
         */
-       getIP6Prefix: function() {
-               var prefixes = this._ubus('ipv6-prefix');
+       getIP6Prefix() {
+               const prefixes = this._ubus('ipv6-prefix');
 
                if (Array.isArray(prefixes) && L.isObject(prefixes[0]))
                        return '%s/%d'.format(prefixes[0].address, prefixes[0].mask);
@@ -2404,14 +2399,14 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns an array of the routed IPv6 prefixes registered by the remote 
         * protocol handler or `null` if no prefixes are present.
         */
-       getIP6Prefixes: function() {
-               var prefixes = this._ubus('ipv6-prefix');
-               var rv = [];
+       getIP6Prefixes() {
+               const prefixes = this._ubus('ipv6-prefix');
+               const rv = [];
 
                if (Array.isArray(prefixes))
-                       for (var i = 0; i < prefixes.length; i++)
-                               if (L.isObject(prefixes[i]))
-                                       rv.push('%s/%d'.format(prefixes[i].address, prefixes[i].mask));
+                       for (let p of prefixes)
+                               if (L.isObject(p))
+                                       rv.push('%s/%d'.format(p.address, p.mask));
 
                return rv.length > 0 ? rv: null;
        },
@@ -2432,17 +2427,17 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * @returns {string[]}
         * Returns an array of translated interface error messages.
         */
-       getErrors: function() {
-               var errors = this._ubus('errors'),
-                   rv = null;
+       getErrors() {
+               const errors = this._ubus('errors');
+               let rv = null;
 
                if (Array.isArray(errors)) {
-                       for (var i = 0; i < errors.length; i++) {
-                               if (!L.isObject(errors[i]) || typeof(errors[i].code) != 'string')
+                       for (let e of errors) {
+                               if (!L.isObject(e) || typeof(e.code) != 'string')
                                        continue;
 
                                rv = rv || [];
-                               rv.push(proto_errors[errors[i].code] || _('Unknown error (%s)').format(errors[i].code));
+                               rv.push(proto_errors[e.code] || _('Unknown error (%s)').format(e.code));
                        }
                }
 
@@ -2457,7 +2452,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * and when the associated protocol implementation is not marked virtual
         * or `false` when the logical interface is no bridge.
         */
-       isBridge: function() {
+       isBridge() {
                return (!this.isVirtual() && this.getType() == 'bridge');
        },
 
@@ -2474,7 +2469,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the name of the package to download, required for the protocol to
         * function, e.g. `odhcp6c` for the `dhcpv6` protocol.
         */
-       getPackageName: function() {
+       getPackageName() {
                return null;
        },
 
@@ -2492,7 +2487,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns a promise resolving if a new interface is creatable, else
         * rejects with an error message string.
         */
-       isCreateable: function(ifname) {
+       isCreateable(ifname) {
                return Promise.resolve(null);
        },
 
@@ -2508,7 +2503,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * @returns {boolean}
         * Returns `true` if the protocol support is installed, else `false`.
         */
-       isInstalled: function() {
+       isInstalled() {
                return true;
        },
 
@@ -2528,7 +2523,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns a boolean indicating whether the underlying protocol spawns
         * dynamic interfaces (`true`) or not (`false`).
         */
-       isVirtual: function() {
+       isVirtual() {
                return false;
        },
 
@@ -2549,7 +2544,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns a boolean indicating whether this protocol is floating (`true`)
         * or not (`false`).
         */
-       isFloating: function() {
+       isFloating() {
                return false;
        },
 
@@ -2565,7 +2560,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns a boolean indicating whether this interface is dynamic (`true`)
         * or not (`false`).
         */
-       isDynamic: function() {
+       isDynamic() {
                return (this._ubus('dynamic') == true);
        },
 
@@ -2575,7 +2570,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * @returns {boolean}
         * returns `true` when the interface is pending or `false` when it is not.
         */
-       isPending: function() {
+       isPending() {
                return (this._ubus('pending') == true);
        },
 
@@ -2590,13 +2585,13 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns the name of the parent interface if this logical interface
         * is an alias or `null` if it is not an alias interface.
         */
-       isAlias: function() {
-               var ifnames = L.toArray(uci.get('network', this.sid, 'device')),
-                   parent = null;
+       isAlias() {
+               const ifnames = L.toArray(uci.get('network', this.sid, 'device'));
+               let parent = null;
 
-               for (var i = 0; i < ifnames.length; i++)
-                       if (ifnames[i].charAt(0) == '@')
-                               parent = ifnames[i].substr(1);
+               for (let ifn of ifnames)
+                       if (ifn.charAt(0) == '@')
+                               parent = ifn.substr(1);
                        else if (parent != null)
                                parent = null;
 
@@ -2610,12 +2605,12 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * @returns {boolean}
         * Returns `true` if this logical interface is empty, else `false`.
         */
-       isEmpty: function() {
+       isEmpty() {
                if (this.isFloating())
                        return false;
 
-               var empty = true,
-                   device = this._get('device');
+               let empty = true;
+           const device = this._get('device');
 
                if (device != null && device.match(/\S+/))
                        empty = false;
@@ -2632,7 +2627,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * @returns {boolean}
         * Returns `true` when the interface is active or `false` when it is not.
         */
-       isUp: function() {
+       isUp() {
                return (this._ubus('up') == true);
        },
 
@@ -2649,13 +2644,13 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * argument was invalid, if the device was already part of the logical
         * interface or if the logical interface is virtual.
         */
-       addDevice: function(device) {
+       addDevice(device) {
                device = ifnameOf(device);
 
                if (device == null || this.isFloating())
                        return false;
 
-               var wif = getWifiSidByIfname(device);
+               const wif = getWifiSidByIfname(device);
 
                if (wif != null)
                        return appendValue('wireless', wif, 'network', this.sid);
@@ -2676,15 +2671,15 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * argument was invalid, if the device was already part of the logical
         * interface or if the logical interface is virtual.
         */
-       deleteDevice: function(device) {
-               var rv = false;
+       deleteDevice(device) {
+               let rv = false;
 
                device = ifnameOf(device);
 
                if (device == null || this.isFloating())
                        return false;
 
-               var wif = getWifiSidByIfname(device);
+               const wif = getWifiSidByIfname(device);
 
                if (wif != null)
                        rv = removeValue('wireless', wif, 'network', this.sid);
@@ -2703,26 +2698,26 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns a `Network.Device` class instance representing the
         * expected Linux network device according to the configuration.
         */
-       getDevice: function() {
+       getDevice() {
                if (this.isVirtual()) {
-                       var ifname = '%s-%s'.format(this.getProtocol(), this.sid);
+                       const ifname = '%s-%s'.format(this.getProtocol(), this.sid);
                        _state.isTunnel[this.getProtocol() + '-' + this.sid] = true;
                        return Network.prototype.instantiateDevice(ifname, this);
                }
                else if (this.isBridge()) {
-                       var ifname = 'br-%s'.format(this.sid);
+                       const ifname = 'br-%s'.format(this.sid);
                        _state.isBridge[ifname] = true;
                        return new Device(ifname, this);
                }
                else {
-                       var ifnames = L.toArray(uci.get('network', this.sid, 'device'));
+                       const ifnames = L.toArray(uci.get('network', this.sid, 'device'));
 
-                       for (var i = 0; i < ifnames.length; i++) {
-                               var m = ifnames[i].match(/^([^:/]+)/);
+                       for (let ifn of ifnames) {
+                               const m = ifn.match(/^([^:/]+)/);
                                return ((m && m[1]) ? Network.prototype.instantiateDevice(m[1], this) : null);
                        }
 
-                       ifname = getWifiNetidByNetname(this.sid);
+                       const ifname = getWifiNetidByNetname(this.sid);
 
                        return (ifname != null ? Network.prototype.instantiateDevice(ifname[0], this) : null);
                }
@@ -2736,8 +2731,8 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns a `Network.Device` class instance representing the Linux
         * network device currently associated with the logical interface.
         */
-       getL2Device: function() {
-               var ifname = this._ubus('device');
+       getL2Device() {
+               const ifname = this._ubus('device');
                return (ifname != null ? Network.prototype.instantiateDevice(ifname, this) : null);
        },
 
@@ -2749,8 +2744,8 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns a `Network.Device` class instance representing the Linux
         * network device currently associated with the logical interface.
         */
-       getL3Device: function() {
-               var ifname = this._ubus('l3_device');
+       getL3Device() {
+               const ifname = this._ubus('l3_device');
                return (ifname != null ? Network.prototype.instantiateDevice(ifname, this) : null);
        },
 
@@ -2764,33 +2759,33 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * logical interface does not support sub-devices, e.g. because it is
         * virtual and not a bridge.
         */
-       getDevices: function() {
-               var rv = [];
+       getDevices() {
+               const rv = [];
 
                if (!this.isBridge() && !(this.isVirtual() && !this.isFloating()))
                        return null;
 
-               var device = uci.get('network', this.sid, 'device');
+               const device = uci.get('network', this.sid, 'device');
 
                if (device && device.charAt(0) != '@') {
-                       var m = device.match(/^([^:/]+)/);
+                       const m = device.match(/^([^:/]+)/);
                        if (m != null)
                                rv.push(Network.prototype.instantiateDevice(m[1], this));
                }
 
-               var uciWifiIfaces = uci.sections('wireless', 'wifi-iface');
+               const uciWifiIfaces = uci.sections('wireless', 'wifi-iface');
 
-               for (var i = 0; i < uciWifiIfaces.length; i++) {
-                       if (typeof(uciWifiIfaces[i].device) != 'string')
+               for (let wf_if of uciWifiIfaces) {
+                       if (typeof(wf_if.device) != 'string')
                                continue;
 
-                       var networks = L.toArray(uciWifiIfaces[i].network);
+                       const networks = L.toArray(wf_if.network);
 
-                       for (var j = 0; j < networks.length; j++) {
-                               if (networks[j] != this.sid)
+                       for (let n of networks) {
+                               if (n != this.sid)
                                        continue;
 
-                               var netid = getWifiNetidBySid(uciWifiIfaces[i]['.name']);
+                               const netid = getWifiNetidBySid(wf_if['.name']);
 
                                if (netid != null)
                                        rv.push(Network.prototype.instantiateDevice(netid[0], this));
@@ -2815,7 +2810,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * Returns `true` when this logical interface contains the given network
         * device or `false` if not.
         */
-       containsDevice: function(device) {
+       containsDevice(device) {
                device = ifnameOf(device);
 
                if (device == null)
@@ -2825,20 +2820,20 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
                else if (this.isBridge() && 'br-%s'.format(this.sid) == device)
                        return true;
 
-               var name = uci.get('network', this.sid, 'device');
+               const name = uci.get('network', this.sid, 'device');
                if (name) {
-                       var m = name.match(/^([^:/]+)/);
+                       const m = name.match(/^([^:/]+)/);
                        if (m != null && m[1] == device)
                                return true;
                }
 
-               var wif = getWifiSidByIfname(device);
+               const wif = getWifiSidByIfname(device);
 
                if (wif != null) {
-                       var networks = L.toArray(uci.get('wireless', wif, 'network'));
+                       const networks = L.toArray(uci.get('wireless', wif, 'network'));
 
-                       for (var i = 0; i < networks.length; i++)
-                               if (networks[i] == this.sid)
+                       for (let n of networks)
+                               if (n == this.sid)
                                        return true;
                }
 
@@ -2862,7 +2857,7 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
         * resolved promise value is ignored. If the returned promise is rejected,
         * the interface removal will be aborted.
         */
-       deleteConfiguration: function() {}
+       deleteConfiguration() {}
 });
 
 /**
@@ -2875,12 +2870,12 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
  * device and allows querying device details such as packet statistics or MTU.
  */
 Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
-       __init__: function(device, network) {
-               var wif = getWifiSidByIfname(device);
+       __init__(device, network) {
+               const wif = getWifiSidByIfname(device);
 
                if (wif != null) {
-                       var res = getWifiStateBySid(wif) || [],
-                           netid = getWifiNetidBySid(wif) || [];
+                       const res = getWifiStateBySid(wif) || [];
+                       const netid = getWifiNetidBySid(wif) || [];
 
                        this.wif    = new WifiNetwork(wif, res[0], res[1], netid[0], res[2], { ifname: device });
                        this.device = this.wif.getIfname();
@@ -2890,7 +2885,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
                this.dev     = Object.assign({}, _state.netdevs[this.device]);
                this.network = network;
 
-               var conf;
+               let conf;
 
                uci.sections('network', 'device', function(s) {
                        if (s.name == device)
@@ -2900,12 +2895,12 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
                this.config  = Object.assign({}, conf);
        },
 
-       _devstate: function(/* ... */) {
-               var rv = this.dev;
+       _devstate(/* ... */) {
+               let rv = this.dev;
 
-               for (var i = 0; i < arguments.length; i++)
+               for (let a of arguments)
                        if (L.isObject(rv))
-                               rv = rv[arguments[i]];
+                               rv = rv[a];
                        else
                                return null;
 
@@ -2918,7 +2913,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * @returns {string}
         * Returns the name of the device, e.g. `eth0` or `wlan0`.
         */
-       getName: function() {
+       getName() {
                return (this.wif != null ? this.wif.getIfname() : this.device);
        },
 
@@ -2929,8 +2924,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns the MAC address of the device or `null` if not applicable,
         * e.g. for non-Ethernet tunnel devices.
         */
-       getMAC: function() {
-               var mac = this._devstate('macaddr');
+       getMAC() {
+               const mac = this._devstate('macaddr');
                return mac ? mac.toUpperCase() : null;
        },
 
@@ -2940,7 +2935,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * @returns {number}
         * Returns the MTU of the device.
         */
-       getMTU: function() {
+       getMTU() {
                return this._devstate('mtu');
        },
 
@@ -2950,8 +2945,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * @returns {string[]}
         * Returns an array of IPv4 address strings.
         */
-       getIPAddrs: function() {
-               var addrs = this._devstate('ipaddrs');
+       getIPAddrs() {
+               const addrs = this._devstate('ipaddrs');
                return (Array.isArray(addrs) ? addrs : []);
        },
 
@@ -2961,8 +2956,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * @returns {string[]}
         * Returns an array of IPv6 address strings.
         */
-       getIP6Addrs: function() {
-               var addrs = this._devstate('ip6addrs');
+       getIP6Addrs() {
+               const addrs = this._devstate('ip6addrs');
                return (Array.isArray(addrs) ? addrs : []);
        },
 
@@ -2980,7 +2975,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         *  - `switch` if it is a switch device (e.g.`eth1` connected to switch0)
         *  - `ethernet` for all other device types
         */
-       getType: function() {
+       getType() {
                if (this.device != null && this.device.charAt(0) == '@')
                        return 'alias';
                else if (this.dev.devtype == 'wlan' || this.wif != null || isWifiIfname(this.device))
@@ -3012,7 +3007,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns the device name for non-WiFi devices or a string containing
         * the operation mode and SSID for WiFi devices.
         */
-       getShortName: function() {
+       getShortName() {
                if (this.wif != null)
                        return this.wif.getShortName();
 
@@ -3026,7 +3021,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns a string containing the type description and device name
         * for non-WiFi devices or operation mode and SSID for WiFi ones.
         */
-       getI18n: function() {
+       getI18n() {
                if (this.wif != null) {
                        return '%s: %s "%s"'.format(
                                _('Wireless Network'),
@@ -3044,7 +3039,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns a string describing the type, e.g. "Wireless Adapter" or
         * "Bridge".
         */
-       getTypeI18n: function() {
+       getTypeI18n() {
                switch (this.getType()) {
                case 'alias':
                        return _('Alias Interface');
@@ -3084,15 +3079,15 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * (slave interfaces) of the bridge or `null` when this device isn't
         * a Linux bridge.
         */
-       getPorts: function() {
-               var br = _state.bridges[this.device],
-                   rv = [];
+       getPorts() {
+               const br = _state.bridges[this.device];
+               const rv = [];
 
                if (br == null || !Array.isArray(br.ifnames))
                        return null;
 
-               for (var i = 0; i < br.ifnames.length; i++)
-                       rv.push(Network.prototype.instantiateDevice(br.ifnames[i].name));
+               for (let ifn of br.ifnames)
+                       rv.push(Network.prototype.instantiateDevice(ifn.name));
 
                rv.sort(deviceSort);
 
@@ -3106,8 +3101,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns the ID of this network bridge or `null` if this network
         * device is not a Linux bridge.
         */
-       getBridgeID: function() {
-               var br = _state.bridges[this.device];
+       getBridgeID() {
+               const br = _state.bridges[this.device];
                return (br != null ? br.id : null);
        },
 
@@ -3118,8 +3113,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns `true` when this device is a Linux bridge and has `stp`
         * enabled, else `false`.
         */
-       getBridgeSTP: function() {
-               var br = _state.bridges[this.device];
+       getBridgeSTP() {
+               const br = _state.bridges[this.device];
                return (br != null ? !!br.stp : false);
        },
 
@@ -3130,8 +3125,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns `true` when the associated device is running or `false`
         * when it is down or absent.
         */
-       isUp: function() {
-               var up = this._devstate('flags', 'up');
+       isUp() {
+               let up = this._devstate('flags', 'up');
 
                if (up == null)
                        up = (this.getType() == 'alias');
@@ -3146,7 +3141,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns `true` when the network device is present and a Linux bridge,
         * else `false`.
         */
-       isBridge: function() {
+       isBridge() {
                return (this.getType() == 'bridge');
        },
 
@@ -3157,7 +3152,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns `true` when this network device is part of a bridge,
         * else `false`.
         */
-       isBridgePort: function() {
+       isBridgePort() {
                return (this._devstate('bridge') != null);
        },
 
@@ -3167,8 +3162,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * @returns {number}
         * Returns the amount of bytes transmitted by the network device.
         */
-       getTXBytes: function() {
-               var stat = this._devstate('stats');
+       getTXBytes() {
+               const stat = this._devstate('stats');
                return (stat != null ? stat.tx_bytes || 0 : 0);
        },
 
@@ -3178,8 +3173,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * @returns {number}
         * Returns the amount of bytes received by the network device.
         */
-       getRXBytes: function() {
-               var stat = this._devstate('stats');
+       getRXBytes() {
+               const stat = this._devstate('stats');
                return (stat != null ? stat.rx_bytes || 0 : 0);
        },
 
@@ -3189,8 +3184,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * @returns {number}
         * Returns the amount of packets transmitted by the network device.
         */
-       getTXPackets: function() {
-               var stat = this._devstate('stats');
+       getTXPackets() {
+               const stat = this._devstate('stats');
                return (stat != null ? stat.tx_packets || 0 : 0);
        },
 
@@ -3200,8 +3195,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * @returns {number}
         * Returns the amount of packets received by the network device.
         */
-       getRXPackets: function() {
-               var stat = this._devstate('stats');
+       getRXPackets() {
+               const stat = this._devstate('stats');
                return (stat != null ? stat.rx_packets || 0 : 0);
        },
 
@@ -3212,8 +3207,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns true if the device has a carrier, e.g. when a cable is
         * inserted into an Ethernet port of false if there is none.
         */
-       getCarrier: function() {
-               var link = this._devstate('link');
+       getCarrier() {
+               const link = this._devstate('link');
                return (link != null ? link.carrier || false : false);
        },
 
@@ -3226,8 +3221,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * If the device supports Ethernet speeds but has no carrier, -1 is
         * returned.
         */
-       getSpeed: function() {
-               var link = this._devstate('link');
+       getSpeed() {
+               const link = this._devstate('link');
                return (link != null ? link.speed || null : null);
        },
 
@@ -3239,9 +3234,9 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * either "full" or "half" if the device supports duplex modes or
         * null if the duplex mode is unknown or unsupported.
         */
-       getDuplex: function() {
-               var link = this._devstate('link'),
-                   duplex = link ? link.duplex : null;
+       getDuplex() {
+               const link = this._devstate('link');
+               const duplex = link ? link.duplex : null;
 
                return (duplex != 'unknown') ? duplex : null;
        },
@@ -3262,7 +3257,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * - priority: Current priority level
         * - priorityMax: Maximum priority level
         */
-       getPSE: function() {
+       getPSE() {
                const pse = this._devstate('pse');
                if (!pse)
                        return null;
@@ -3286,7 +3281,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * @returns {boolean}
         * Returns true if PSE hardware is available on this device.
         */
-       hasPSE: function() {
+       hasPSE() {
                return this._devstate('pse') != null;
        },
 
@@ -3298,7 +3293,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * interface this device is attached to or `null` if it is not
         * assigned to any logical interface.
         */
-       getNetwork: function() {
+       getNetwork() {
                return this.getNetworks()[0];
        },
 
@@ -3309,15 +3304,15 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * Returns an array of `Network.Protocol` instances representing the
         * logical interfaces this device is assigned to.
         */
-       getNetworks: function() {
+       getNetworks() {
                if (this.networks == null) {
                        this.networks = [];
 
-                       var networks = enumerateNetworks.apply(L.network);
+                       const networks = enumerateNetworks.apply(L.network);
 
-                       for (var i = 0; i < networks.length; i++)
-                               if (networks[i].containsDevice(this.device) || networks[i].getIfname() == this.device)
-                                       this.networks.push(networks[i]);
+                       for (let n of networks)
+                               if (n.containsDevice(this.device) || n.getIfname() == this.device)
+                                       this.networks.push(n);
 
                        this.networks.sort(networkSort);
                }
@@ -3333,7 +3328,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * network corresponding to this network device or `null` if this device
         * is not a wireless device.
         */
-       getWifiNetwork: function() {
+       getWifiNetwork() {
                return (this.wif != null ? this.wif : null);
        },
 
@@ -3349,7 +3344,7 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
         * `null` when this device has no parent, as it is the case for e.g.
         * ordinary Ethernet interfaces.
         */
-       getParent: function() {
+       getParent() {
                if (this.dev.parent)
                        return Network.prototype.instantiateDevice(this.dev.parent);
 
@@ -3371,8 +3366,8 @@ Device = baseclass.extend(/** @lends LuCI.network.Device.prototype */ {
  * well as methods for enumerating related wireless networks.
  */
 WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
-       __init__: function(name, radiostate) {
-               var uciWifiDevice = uci.get('wireless', name);
+       __init__(name, radiostate) {
+               const uciWifiDevice = uci.get('wireless', name);
 
                if (uciWifiDevice != null &&
                    uciWifiDevice['.type'] == 'wifi-device' &&
@@ -3388,12 +3383,12 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
        },
 
        /* private */
-       ubus: function(/* ... */) {
-               var v = this._ubusdata;
+       ubus(/* ... */) {
+               let v = this._ubusdata;
 
-               for (var i = 0; i < arguments.length; i++)
+               for (let a of arguments)
                        if (L.isObject(v))
-                               v = v[arguments[i]];
+                               v = v[a];
                        else
                                return null;
 
@@ -3410,7 +3405,7 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * Returns the UCI option value or `null` if the requested option is
         * not found.
         */
-       get: function(opt) {
+       get(opt) {
                return uci.get('wireless', this.sid, opt);
        },
 
@@ -3425,7 +3420,7 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * configuration.
         * @returns {null}
         */
-       set: function(opt, value) {
+       set(opt, value) {
                return uci.set('wireless', this.sid, opt, value);
        },
 
@@ -3437,7 +3432,7 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * runtime state or when the `disabled` option is set in the corresponding
         * UCI configuration.
         */
-       isDisabled: function() {
+       isDisabled() {
                return this.ubus('dev', 'disabled') || this.get('disabled') == '1';
        },
 
@@ -3449,7 +3444,7 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * radio configuration, which also serves as a unique logical identifier
         * for the wireless phy.
         */
-       getName: function() {
+       getName() {
                return this.sid;
        },
 
@@ -3470,8 +3465,8 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         *  - `ax` - IEEE 802.11ax mode, 2.4 or 5 GHz
         *  - 'be' - IEEE 802.11be mode, 2.4, 5 or 6 GHz
         */
-       getHWModes: function() {
-               var hwmodes = this.ubus('dev', 'iwinfo', 'hwmodes');
+       getHWModes() {
+               const hwmodes = this.ubus('dev', 'iwinfo', 'hwmodes');
                return Array.isArray(hwmodes) ? hwmodes : [ 'b', 'g' ];
        },
 
@@ -3500,8 +3495,8 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         *  - `EHT160` - applicable to IEEE 802.11be, 160 MHz wide channels
         *  - `EHT320` - applicable to IEEE 802.11be, 320 MHz wide channels
         */
-       getHTModes: function() {
-               var htmodes = this.ubus('dev', 'iwinfo', 'htmodes');
+       getHTModes() {
+               const htmodes = this.ubus('dev', 'iwinfo', 'htmodes');
                return (Array.isArray(htmodes) && htmodes.length) ? htmodes : null;
        },
 
@@ -3511,10 +3506,10 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * @returns {string}
         * Returns the description string.
         */
-       getI18n: function() {
-               var hw = this.ubus('dev', 'iwinfo', 'hardware'),
-                   type = L.isObject(hw) ? hw.name : null;
-               var modes = this.ubus('dev', 'iwinfo', 'hwmodes_text');
+       getI18n() {
+               const hw = this.ubus('dev', 'iwinfo', 'hardware');
+               let type = L.isObject(hw) ? hw.name : null;
+               const modes = this.ubus('dev', 'iwinfo', 'hwmodes_text');
 
                if (this.ubus('dev', 'iwinfo', 'type') == 'wl')
                        type = 'Broadcom';
@@ -3567,7 +3562,7 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * Returns a promise resolving to an array of scan result objects
         * describing the networks found in the vicinity.
         */
-       getScanList: function() {
+       getScanList() {
                return callIwinfoScan(this.sid);
        },
 
@@ -3578,7 +3573,7 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * @returns {boolean}
         * Returns `true` when the radio device is up, else `false`.
         */
-       isUp: function() {
+       isUp() {
                if (L.isObject(_state.radios[this.sid]))
                        return (_state.radios[this.sid].up == true);
 
@@ -3600,9 +3595,9 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * the given network could not be found or is not associated with
         * this radio device.
         */
-       getWifiNetwork: function(network) {
+       getWifiNetwork(network) {
                return Network.prototype.getWifiNetwork(network).then(L.bind(function(networkInstance) {
-                       var uciWifiIface = (networkInstance.sid ? uci.get('wireless', networkInstance.sid) : null);
+                       const uciWifiIface = (networkInstance.sid ? uci.get('wireless', networkInstance.sid) : null);
 
                        if (uciWifiIface == null || uciWifiIface['.type'] != 'wifi-iface' || uciWifiIface.device != this.sid)
                                return Promise.reject();
@@ -3619,13 +3614,13 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * instances representing the wireless networks associated with this
         * radio device.
         */
-       getWifiNetworks: function() {
+       getWifiNetworks() {
                return Network.prototype.getWifiNetworks().then(L.bind(function(networks) {
-                       var rv = [];
+                       const rv = [];
 
-                       for (var i = 0; i < networks.length; i++)
-                               if (networks[i].getWifiDeviceName() == this.getName())
-                                       rv.push(networks[i]);
+                       for (let n of networks)
+                               if (n.getWifiDeviceName() == this.getName())
+                                       rv.push(n);
 
                        return rv;
                }, this));
@@ -3643,7 +3638,7 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * the newly added wireless network or `null` if the given options
         * were invalid.
         */
-       addWifiNetwork: function(options) {
+       addWifiNetwork(options) {
                if (!L.isObject(options))
                        options = {};
 
@@ -3668,14 +3663,14 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
         * network could not be found or if the found network was not associated
         * with this wireless radio device.
         */
-       deleteWifiNetwork: function(network) {
-               var sid = null;
+       deleteWifiNetwork(network) {
+               let sid = null;
 
                if (network instanceof WifiNetwork) {
                        sid = network.sid;
                }
                else {
-                       var uciWifiIface = uci.get('wireless', network);
+                       const uciWifiIface = uci.get('wireless', network);
 
                        if (uciWifiIface == null || uciWifiIface['.type'] != 'wifi-iface')
                                sid = getWifiSidByIfname(network);
@@ -3702,7 +3697,7 @@ WifiDevice = baseclass.extend(/** @lends LuCI.network.WifiDevice.prototype */ {
  * such networks in parallel.
  */
 WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */ {
-       __init__: function(sid, radioname, radiostate, netid, netstate, hostapd) {
+       __init__(sid, radioname, radiostate, netid, netstate, hostapd) {
                this.sid    = sid;
                this.netid  = netid;
                this._ubusdata = {
@@ -3713,12 +3708,12 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
                };
        },
 
-       ubus: function(/* ... */) {
-               var v = this._ubusdata;
+       ubus(/* ... */) {
+               let v = this._ubusdata;
 
-               for (var i = 0; i < arguments.length; i++)
+               for (let a of arguments)
                        if (L.isObject(v))
-                               v = v[arguments[i]];
+                               v = v[a];
                        else
                                return null;
 
@@ -3735,7 +3730,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the UCI option value or `null` if the requested option is
         * not found.
         */
-       get: function(opt) {
+       get(opt) {
                return uci.get('wireless', this.sid, opt);
        },
 
@@ -3750,7 +3745,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * configuration.
         * @returns {null}
         */
-       set: function(opt, value) {
+       set(opt, value) {
                return uci.set('wireless', this.sid, opt, value);
        },
 
@@ -3762,7 +3757,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * runtime state or when the `disabled` option is set in the corresponding
         * UCI configuration.
         */
-       isDisabled: function() {
+       isDisabled() {
                return this.ubus('dev', 'disabled') || this.get('disabled') == '1';
        },
 
@@ -3777,7 +3772,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         *  - `mesh` - Mesh (IEEE 802.11s) mode
         *  - `monitor` - Monitor mode
         */
-       getMode: function() {
+       getMode() {
                return this.ubus('net', 'config', 'mode') || this.get('mode') || 'ap';
        },
 
@@ -3788,7 +3783,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the configured SSID value or `null` when this network is
         * in mesh mode.
         */
-       getSSID: function() {
+       getSSID() {
                if (this.getMode() == 'mesh')
                        return null;
 
@@ -3802,7 +3797,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the configured mesh ID value or `null` when this network
         * is not in mesh mode.
         */
-       getMeshID: function() {
+       getMeshID() {
                if (this.getMode() != 'mesh')
                        return null;
 
@@ -3815,7 +3810,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * @returns {null|string}
         * Returns the BSSID value or `null` if none has been specified.
         */
-       getBSSID: function() {
+       getBSSID() {
                return this.ubus('net', 'config', 'bssid') || this.get('bssid');
        },
 
@@ -3826,7 +3821,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * @returns {string[]}
         * Returns an array of logical interface names.
         */
-       getNetworkNames: function() {
+       getNetworkNames() {
                return L.toArray(this.ubus('net', 'config', 'network') || this.get('network'));
        },
 
@@ -3840,7 +3835,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * @returns {string}
         * Returns the LuCI specific network ID.
         */
-       getID: function() {
+       getID() {
                return this.netid;
        },
 
@@ -3850,7 +3845,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * @returns {string}
         * Returns the corresponding UCI section ID of the network.
         */
-       getName: function() {
+       getName() {
                return this.sid;
        },
 
@@ -3862,8 +3857,8 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * `ubus` runtime information or `null` if this network has no
         * associated network device, e.g. when not configured or up.
         */
-       getIfname: function() {
-               var ifname = this.ubus('net', 'ifname') || this.ubus('net', 'iwinfo', 'ifname');
+       getIfname() {
+               let ifname = this.ubus('net', 'ifname') || this.ubus('net', 'iwinfo', 'ifname');
 
                if (ifname == null || ifname.match(/^(wifi|radio)\d/))
                        ifname = this.netid;
@@ -3879,12 +3874,12 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * from `ubus` runtime information or empty array if this network
         * has no associated VLAN network devices.
         */
-       getVlanIfnames: function() {
-               var vlans = L.toArray(this.ubus('net', 'vlans')),
-                   ifnames = [];
+       getVlanIfnames() {
+               const vlans = L.toArray(this.ubus('net', 'vlans'));
+               const ifnames = [];
 
-               for (var i = 0; i < vlans.length; i++)
-                       ifnames.push(vlans[i]['ifname']);
+               for (let v of vlans)
+                       ifnames.push(v['ifname']);
 
                return ifnames;
        },
@@ -3896,7 +3891,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the name of the radio device this network is configured on
         * or `null` if it cannot be determined.
         */
-       getWifiDeviceName: function() {
+       getWifiDeviceName() {
                return this.ubus('radio') || this.get('device');
        },
 
@@ -3908,8 +3903,8 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * WiFi radio device or `null` if the related radio device could not be
         * found.
         */
-       getWifiDevice: function() {
-               var radioname = this.getWifiDeviceName();
+       getWifiDevice() {
+               const radioname = this.getWifiDeviceName();
 
                if (radioname == null)
                        return Promise.reject();
@@ -3929,8 +3924,8 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * @returns {boolean}
         * Returns `true` when the network is up, else `false`.
         */
-       isUp: function() {
-               var device = this.getDevice();
+       isUp() {
+               const device = this.getDevice();
 
                if (device == null)
                        return false;
@@ -3955,8 +3950,8 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         *  - `P2P Go`
         *  - `Unknown`
         */
-       getActiveMode: function() {
-               var mode = this.ubus('net', 'iwinfo', 'mode') || this.getMode();
+       getActiveMode() {
+               const mode = this.ubus('net', 'iwinfo', 'mode') || this.getMode();
 
                switch (mode) {
                case 'ap':      return 'Master';
@@ -3976,8 +3971,8 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the translated, human readable mode name as reported by
         *`ubus` runtime state.
         */
-       getActiveModeI18n: function() {
-               var mode = this.getActiveMode();
+       getActiveModeI18n() {
+               const mode = this.getActiveMode();
 
                switch (mode) {
                case 'Master':       return _('Access Point');
@@ -4001,7 +3996,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the current SSID or Mesh ID as reported by `ubus` runtime
         * information.
         */
-       getActiveSSID: function() {
+       getActiveSSID() {
                return this.ubus('net', 'iwinfo', 'ssid') || this.ubus('net', 'config', 'ssid') || this.get('ssid');
        },
 
@@ -4012,7 +4007,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the current BSSID or Mesh ID as reported by `ubus` runtime
         * information.
         */
-       getActiveBSSID: function() {
+       getActiveBSSID() {
                return this.ubus('net', 'iwinfo', 'bssid') || this.ubus('net', 'config', 'bssid') || this.get('bssid');
        },
 
@@ -4023,7 +4018,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns a string describing the current encryption or `-` if the
         * encryption state could not be found in `ubus` runtime information.
         */
-       getActiveEncryption: function() {
+       getActiveEncryption() {
                return formatWifiEncryption(this.ubus('net', 'iwinfo', 'encryption')) || '-';
        },
 
@@ -4225,9 +4220,9 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns a promise resolving to an array of wireless peers associated
         * with this network.
         */
-       getAssocList: function() {
-               var tasks = [];
-               var station;
+       getAssocList() {
+               const tasks = [];
+               let station;
 
                for (let vlan of this.getVlans())
                        tasks.push(callIwinfoAssoclist(vlan.getIfname()).then(
@@ -4252,9 +4247,9 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * @returns {Array<LuCI.network.WifiVlan>}
         * Returns an array of vlans for this network.
         */
-       getVlans: function() {
-               var vlans = [];
-               var vlans_ubus = this.ubus('net', 'vlans');
+       getVlans() {
+               const vlans = [];
+               const vlans_ubus = this.ubus('net', 'vlans');
 
                if (vlans_ubus)
                        for (let vlan of vlans_ubus)
@@ -4271,8 +4266,8 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * runtime information in GHz or `null` if the information is not
         * available.
         */
-       getFrequency: function() {
-               var freq = this.ubus('net', 'iwinfo', 'frequency');
+       getFrequency() {
+               const freq = this.ubus('net', 'iwinfo', 'frequency');
 
                if (freq != null && freq > 0)
                        return '%.03f'.format(freq / 1000);
@@ -4289,8 +4284,8 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * as reported by `ubus` runtime information or `null` if the information
         * is not available.
         */
-       getBitRate: function() {
-               var rate = this.ubus('net', 'iwinfo', 'bitrate');
+       getBitRate() {
+               const rate = this.ubus('net', 'iwinfo', 'bitrate');
 
                if (rate != null && rate > 0)
                        return (rate / 1000);
@@ -4305,7 +4300,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the wireless channel as reported by `ubus` runtime information
         * or `null` if it cannot be determined.
         */
-       getChannel: function() {
+       getChannel() {
                return this.ubus('net', 'iwinfo', 'channel') || this.ubus('dev', 'config', 'channel') || this.get('channel');
        },
 
@@ -4316,7 +4311,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the wireless signal in dBm as reported by `ubus` runtime
         * information or `null` if it cannot be determined.
         */
-       getSignal: function() {
+       getSignal() {
                return this.ubus('net', 'iwinfo', 'signal') || 0;
        },
 
@@ -4327,7 +4322,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the radio noise floor in dBm as reported by `ubus` runtime
         * information or `0` if it cannot be determined.
         */
-       getNoise: function() {
+       getNoise() {
                return this.ubus('net', 'iwinfo', 'noise') || 0;
        },
 
@@ -4338,7 +4333,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the wireless country code as reported by `ubus` runtime
         * information or `00` if it cannot be determined.
         */
-       getCountryCode: function() {
+       getCountryCode() {
                return this.ubus('net', 'iwinfo', 'country') || this.ubus('dev', 'config', 'country') || '00';
        },
 
@@ -4349,7 +4344,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the wireless network transmit power in dBm as reported by
         * `ubus` runtime information or `null` if it cannot be determined.
         */
-       getTXPower: function() {
+       getTXPower() {
                return this.ubus('net', 'iwinfo', 'txpower');
        },
 
@@ -4364,7 +4359,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * by `ubus` runtime information or `0` if there is no offset, or if it
         * cannot be determined.
         */
-       getTXPowerOffset: function() {
+       getTXPowerOffset() {
                return this.ubus('net', 'iwinfo', 'txpower_offset') || 0;
        },
 
@@ -4378,7 +4373,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns the calculated signal level, which is the difference between
         * noise and signal (SNR), divided by 5.
         */
-       getSignalLevel: function(signal, noise) {
+       getSignalLevel(signal, noise) {
                if (this.getActiveBSSID() == '00:00:00:00:00:00')
                        return -1;
 
@@ -4386,7 +4381,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
                noise  = noise  || this.getNoise();
 
                if (signal < 0 && noise < 0) {
-                       var snr = -1 * (noise - signal);
+                       const snr = -1 * (noise - signal);
                        return Math.floor(snr / 5);
                }
 
@@ -4401,9 +4396,9 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * calculated from the `quality` and `quality_max` indicators reported
         * by `ubus` runtime state.
         */
-       getSignalPercent: function() {
-               var qc = this.ubus('net', 'iwinfo', 'quality') || 0,
-                   qm = this.ubus('net', 'iwinfo', 'quality_max') || 0;
+       getSignalPercent() {
+               const qc = this.ubus('net', 'iwinfo', 'quality') || 0;
+               const qm = this.ubus('net', 'iwinfo', 'quality_max') || 0;
 
                if (qc > 0 && qm > 0)
                        return Math.floor((100 / qm) * qc);
@@ -4419,7 +4414,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * active operation mode, followed by either the SSID, BSSID or
         * internal network ID, depending on which information is available.
         */
-       getShortName: function() {
+       getShortName() {
                return '%s "%s"'.format(
                        this.getActiveModeI18n(),
                        this.getActiveSSID() || this.getActiveBSSID() || this.getID());
@@ -4434,7 +4429,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * the SSID, BSSID or internal network ID and the Linux network device
         * name, depending on which information is available.
         */
-       getI18n: function() {
+       getI18n() {
                return '%s: %s "%s" (%s)'.format(
                        _('Wireless Network'),
                        this.getActiveModeI18n(),
@@ -4450,7 +4445,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * interface or `null` if this network is not attached to any logical
         * interface.
         */
-       getNetwork: function() {
+       getNetwork() {
                return this.getNetworks()[0];
        },
 
@@ -4461,17 +4456,17 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns an array of `Network.Protocol` instances representing the
         * logical interfaces this wireless network is attached to.
         */
-       getNetworks: function() {
-               var networkNames = this.getNetworkNames(),
-                   networks = [];
+       getNetworks() {
+               const networkNames = this.getNetworkNames();
+               const networks = [];
 
-               for (var i = 0; i < networkNames.length; i++) {
-                       var uciInterface = uci.get('network', networkNames[i]);
+               for (let nn of networkNames) {
+                       const uciInterface = uci.get('network', nn);
 
                        if (uciInterface == null || uciInterface['.type'] != 'interface')
                                continue;
 
-                       networks.push(Network.prototype.instantiateNetwork(networkNames[i]));
+                       networks.push(Network.prototype.instantiateNetwork(nn));
                }
 
                networks.sort(networkSort);
@@ -4486,7 +4481,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns a `Network.Device` instance representing the Linux network
         * device associated with this wireless network.
         */
-       getDevice: function() {
+       getDevice() {
                return Network.prototype.instantiateDevice(this.getIfname());
        },
 
@@ -4497,7 +4492,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * Returns `true` when this WiFi network instance supports forcibly
         * de-authenticating clients, otherwise `false`.
         */
-       isClientDisconnectSupported: function() {
+       isClientDisconnectSupported() {
                return L.isObject(this.ubus('hostapd', 'del_client'));
        },
 
@@ -4526,7 +4521,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
         * The promise might reject with an error in case invalid arguments
         * are passed.
         */
-       disconnectClient: function(mac, deauth, reason, ban_time) {
+       disconnectClient(mac, deauth, reason, ban_time) {
                if (reason == null || reason == 0)
                        reason = 1;
 
@@ -4550,7 +4545,7 @@ WifiNetwork = baseclass.extend(/** @lends LuCI.network.WifiNetwork.prototype */
  * A `Network.WifiVlan` class instance represents a vlan on a WifiNetwork.
  */
 WifiVlan = baseclass.extend(/** @lends LuCI.network.WifiVlan.prototype */ {
-       __init__: function(vlan) {
+       __init__(vlan) {
                this.ifname = vlan.ifname;
                if (L.isObject(vlan.config)) {
                        this.vid = vlan.config.vid;
@@ -4567,7 +4562,7 @@ WifiVlan = baseclass.extend(/** @lends LuCI.network.WifiVlan.prototype */ {
         * @returns {string}
         * Returns the name.
         */
-       getName: function() {
+       getName() {
                return this.name;
        },
 
@@ -4577,7 +4572,7 @@ WifiVlan = baseclass.extend(/** @lends LuCI.network.WifiVlan.prototype */ {
         * @returns {number}
         * Returns the vlan id.
         */
-       getVlanId: function() {
+       getVlanId() {
                return this.vid;
        },
 
@@ -4587,7 +4582,7 @@ WifiVlan = baseclass.extend(/** @lends LuCI.network.WifiVlan.prototype */ {
         * @returns {string}
         * Returns the network.
         */
-       getNetwork: function() {
+       getNetwork() {
                return this.network;
        },
 
@@ -4597,7 +4592,7 @@ WifiVlan = baseclass.extend(/** @lends LuCI.network.WifiVlan.prototype */ {
         * @returns {string}
         * Returns the current network device name for this wifi vlan.
         */
-       getIfname: function() {
+       getIfname() {
                return this.ifname;
        },
 
@@ -4608,8 +4603,8 @@ WifiVlan = baseclass.extend(/** @lends LuCI.network.WifiVlan.prototype */ {
         * Returns a string containing the vlan id and the vlan name,
         * if it is different than the vlan id
         */
-       getI18n: function() {
-               var name =  this.name && this.name != this.vid ? ' (' + this.name + ')' : '';
+       getI18n() {
+               const name =  this.name && this.name != this.vid ? ' (' + this.name + ')' : '';
                return 'vlan %d%s'.format(this.vid, name);
        },
 });
index 085bea2996d88de79ccdb3de0b76ce099f3696aa..e7f810ecaecec5a68fb0a94d7402b5aad8ec4cd5 100644 (file)
@@ -67,9 +67,9 @@ function calculateBroadcast(s, use_cfgvalue) {
  * @returns {boolean}
  */
 function validateBroadcast(section_id, value) {
-       var opt = this.map.lookupOption('broadcast', section_id),
-           node = opt ? this.map.findElement('id', opt[0].cbid(section_id)) : null,
-           addr = node ? calculateBroadcast(this.section, false) : null;
+       const opt = this.map.lookupOption('broadcast', section_id);
+       const node = opt ? this.map.findElement('id', opt[0].cbid(section_id)) : null;
+       const addr = node ? calculateBroadcast(this.section, false) : null;
 
        if (node != null) {
                if (addr != null)
@@ -83,38 +83,37 @@ function validateBroadcast(section_id, value) {
 
 return network.registerProtocol('static', {
        CBIIPValue: form.Value.extend({
-               handleSwitch: function(section_id, option_index, ev) {
-                       var maskopt = this.map.lookupOption('netmask', section_id);
+               handleSwitch(section_id, option_index, ev) {
+                       const maskopt = this.map.lookupOption('netmask', section_id);
 
                        if (maskopt == null || !this.isValid(section_id))
                                return;
 
-                       var maskval = maskopt[0].formvalue(section_id),
-                           addrval = this.formvalue(section_id),
-                           prefix = maskval ? network.maskToPrefix(maskval) : 32;
+                       const maskval = maskopt[0].formvalue(section_id);
+                       const addrval = this.formvalue(section_id);
+                       const prefix = maskval ? network.maskToPrefix(maskval) : 32;
 
                        if (prefix == null)
                                return;
 
                        this.datatype = 'or(cidr4,ipmask4)';
 
-                       var parent = L.dom.parent(ev.target, '.cbi-value-field');
+                       let parent = L.dom.parent(ev.target, '.cbi-value-field');
                        L.dom.content(parent, form.DynamicList.prototype.renderWidget.apply(this, [
                                section_id,
                                option_index,
                                addrval ? '%s/%d'.format(addrval, prefix) : ''
                        ]));
 
-                       var masknode = this.map.findElement('id', maskopt[0].cbid(section_id));
+                       const masknode = this.map.findElement('id', maskopt[0].cbid(section_id));
                        if (masknode) {
                                parent = L.dom.parent(masknode, '.cbi-value');
                                parent.parentNode.removeChild(parent);
                        }
                },
 
-               renderWidget: function(section_id, option_index, cfgvalue) {
-                       var maskopt = this.map.lookupOption('netmask', section_id),
-                           widget = isCIDR(cfgvalue) ? 'DynamicList' : 'Value';
+               renderWidget(section_id, option_index, cfgvalue) {
+                       const widget = isCIDR(cfgvalue) ? 'DynamicList' : 'Value';
 
                        if (widget == 'DynamicList') {
                                this.datatype = 'or(cidr4,ipmask4)';
@@ -124,7 +123,7 @@ return network.registerProtocol('static', {
                                this.datatype = 'ip4addr("nomask")';
                        }
 
-                       var node = form[widget].prototype.renderWidget.apply(this, [ section_id, option_index, cfgvalue ]);
+                       const node = form[widget].prototype.renderWidget.apply(this, [ section_id, option_index, cfgvalue ]);
 
                        if (widget == 'Value')
                                L.dom.append(node, E('button', {
@@ -141,7 +140,7 @@ return network.registerProtocol('static', {
        }),
 
        CBINetmaskValue: form.Value.extend({
-               render: function(option_index, section_id, in_table) {
+               render(option_index, section_id, in_table) {
                        var addropt = this.section.children.filter(function(o) { return o.option == 'ipaddr' })[0],
                            addrval = addropt ? addropt.cfgvalue(section_id) : null;
 
@@ -162,7 +161,7 @@ return network.registerProtocol('static', {
        CBIGatewayValue: form.Value.extend({
                datatype: 'ip4addr("nomask")',
 
-               render: function(option_index, section_id, in_table) {
+               render(option_index, section_id, in_table) {
                        return network.getWANNetworks().then(L.bind(function(wans) {
                                if (wans.length == 1) {
                                        var gwaddr = wans[0].getGatewayAddr();
@@ -173,13 +172,13 @@ return network.registerProtocol('static', {
                        }, this));
                },
 
-               validate: function(section_id, value) {
-                       var addropt = this.section.children.filter(function(o) { return o.option == 'ipaddr' })[0],
-                           addrval = addropt ? L.toArray(addropt.cfgvalue(section_id)) : null;
+               validate(section_id, value) {
+                       const addropt = this.section.children.filter(function(o) { return o.option == 'ipaddr' })[0];
+                       const addrval = addropt ? L.toArray(addropt.cfgvalue(section_id)) : null;
 
                        if (addrval != null) {
-                               for (var i = 0; i < addrval.length; i++) {
-                                       var addr = addrval[i].split('/')[0];
+                               for (let a of addrval) {
+                                       const addr = a.split('/')[0];
                                        if (value == addr)
                                                return _('The gateway address must not be a local IP address');
                                }
@@ -192,18 +191,18 @@ return network.registerProtocol('static', {
        CBIBroadcastValue: form.Value.extend({
                datatype: 'ip4addr("nomask")',
 
-               render: function(option_index, section_id, in_table) {
+               render(option_index, section_id, in_table) {
                        this.placeholder = calculateBroadcast(this.section, true);
                        return form.Value.prototype.render.apply(this, [ option_index, section_id, in_table ]);
                }
        }),
 
-       getI18n: function() {
+       getI18n() {
                return _('Static address');
        },
 
-       renderFormOptions: function(s) {
-               var o;
+       renderFormOptions(s) {
+               let o;
 
                s.taboption('general', this.CBIIPValue, 'ipaddr', _('IPv4 address'));
                s.taboption('general', this.CBINetmaskValue, 'netmask', _('IPv4 netmask'));
index 1c4c384efe1a5ade8308e25b199328d1fa48d8e4..91699a48e6befc078dea5e6d513ff6184a724081 100644 (file)
@@ -173,7 +173,7 @@ var CBILogreadBox = function(logtag, name) {
                                'class': 'cbi-input-select',
                                'style': 'margin-bottom:10px',
                        },
-                       this.facilities.map(([_, val, label]) =>
+                       this.facilities.map(([ , val, label]) =>
                                (val == 'any') ? E('option', { value: val, selected: '' }, label) : E('option', { value: val }, label)
                        ));
 
@@ -189,7 +189,7 @@ var CBILogreadBox = function(logtag, name) {
                                'id': 'logSeveritySelect',
                                'class': 'cbi-input-select',
                        },
-                       this.severity.map(([_, val, label]) =>
+                       this.severity.map(([ , val, label]) =>
                                (val == 'any') ? E('option', { value: val, selected: '' }, label) : E('option', { value: val }, label)
                        ));
 
index dc82c3b8671cd218a7398f33835824da07e31fbc..5f7f4ac6206f65c3df392f12f1804f9568b9d697 100644 (file)
@@ -43,7 +43,7 @@ function getDevices(network) {
 var CBIZoneSelect = form.ListValue.extend({
        __name__: 'CBI.ZoneSelect',
 
-       load: function(section_id) {
+       load(section_id) {
                return Promise.all([ firewall.getZones(), network.getNetworks() ]).then(L.bind(function(zn) {
                        this.zones = zn[0];
                        this.networks = zn[1];
@@ -52,22 +52,22 @@ var CBIZoneSelect = form.ListValue.extend({
                }, this));
        },
 
-       filter: function(section_id, value) {
+       filter(section_id, value) {
                return true;
        },
 
-       lookupZone: function(name) {
+       lookupZone(name) {
                return this.zones.filter(function(zone) { return zone.getName() == name })[0];
        },
 
-       lookupNetwork: function(name) {
+       lookupNetwork(name) {
                return this.networks.filter(function(network) { return network.getName() == name })[0];
        },
 
-       renderWidget: function(section_id, option_index, cfgvalue) {
-               var values = L.toArray((cfgvalue != null) ? cfgvalue : this.default),
-                   isOutputOnly = false,
-                   choices = {};
+       renderWidget(section_id, option_index, cfgvalue) {
+               const values = L.toArray((cfgvalue != null) ? cfgvalue : this.default);
+               let isOutputOnly = false;
+               const choices = {};
                let datatype_str = 'ucifw4zonename';
                if (!L.hasSystemFeature('firewall4'))
                        datatype_str = `and(${datatype_str},maxlength(11))`;
@@ -77,10 +77,10 @@ var CBIZoneSelect = form.ListValue.extend({
                        datatype_str = `list(${datatype_str})`;
 
                if (this.option == 'dest') {
-                       for (var i = 0; i < this.section.children.length; i++) {
-                               var opt = this.section.children[i];
+                       for (let c of this.section.children) {
+                               const opt = c;
                                if (opt.option == 'src') {
-                                       var val = opt.cfgvalue(section_id) || opt.default;
+                                       const val = opt.cfgvalue(section_id) || opt.default;
                                        isOutputOnly = (val == null || val == '');
                                        break;
                                }
@@ -116,31 +116,30 @@ var CBIZoneSelect = form.ListValue.extend({
                        ]);
                }
 
-               for (var i = 0; i < this.zones.length; i++) {
-                       var zone = this.zones[i],
-                           name = zone.getName(),
-                           networks = zone.getNetworks(),
-                           ifaces = [];
+               for (let zone of this.zones) {
+                       const name = zone.getName();
+                       const networks = zone.getNetworks();
+                       const ifaces = [];
 
                        if (!this.filter(section_id, name))
                                continue;
 
-                       for (var j = 0; j < networks.length; j++) {
-                               var network = this.lookupNetwork(networks[j]);
+                       for (let n of networks) {
+                               const network = this.lookupNetwork(n);
 
                                if (!network)
                                        continue;
 
-                               var span = E('span', {
+                               const span = E('span', {
                                        'class': 'ifacebadge' + (network.isUp() ? ' ifacebadge-active' : '')
                                }, network.getName() + ': ');
 
-                               var devices = getDevices(network);
+                               const devices = getDevices(network);
 
-                               for (var k = 0; k < devices.length; k++) {
+                               for (let d of devices) {
                                        span.appendChild(E('img', {
-                                               'title': devices[k].getI18n(),
-                                               'src': L.resource('icons/%s%s.svg'.format(devices[k].getType(), devices[k].isUp() ? '' : '_disabled'))
+                                               'title': d.getI18n(),
+                                               'src': L.resource('icons/%s%s.svg'.format(d.getType(), d.isUp() ? '' : '_disabled'))
                                        }));
                                }
 
@@ -159,7 +158,7 @@ var CBIZoneSelect = form.ListValue.extend({
                        }, [ E('strong', name) ].concat(ifaces));
                }
 
-               var widget = new ui.Dropdown(values, choices, {
+               const widget = new ui.Dropdown(values, choices, {
                        id: this.cbid(section_id),
                        sort: true,
                        multiple: this.multiple,
@@ -179,19 +178,19 @@ var CBIZoneSelect = form.ListValue.extend({
                                '</li>'
                });
 
-               var elem = widget.render();
+               const elem = widget.render();
 
                if (this.option == 'src') {
                        elem.addEventListener('cbi-dropdown-change', L.bind(function(ev) {
-                               var opt = this.map.lookupOption('dest', section_id),
-                                   val = ev.detail.instance.getValue();
+                               const opt = this.map.lookupOption('dest', section_id);
+                               const val = ev.detail.instance.getValue();
 
                                if (opt == null)
                                        return;
 
-                               var cbid = opt[0].cbid(section_id),
-                                   label = document.querySelector('label[for="widget.%s"]'.format(cbid)),
-                                   node = document.getElementById(cbid);
+                               const cbid = opt[0].cbid(section_id);
+                               const label = document.querySelector('label[for="widget.%s"]'.format(cbid));
+                               const node = document.getElementById(cbid);
 
                                L.dom.content(label, val == '' ? _('Output zone') : _('Destination zone'));
 
@@ -199,8 +198,8 @@ var CBIZoneSelect = form.ListValue.extend({
                                        if (L.dom.callClassMethod(node, 'getValue') == '')
                                                L.dom.callClassMethod(node, 'setValue', '*');
 
-                                       var emptyval = node.querySelector('[data-value=""]'),
-                                           anyval = node.querySelector('[data-value="*"]');
+                                       const emptyval = node.querySelector('[data-value=""]');
+                                       const anyval = node.querySelector('[data-value="*"]');
 
                                        L.dom.content(anyval.querySelector('span'), E('strong', _('Any zone')));
 
@@ -234,7 +233,7 @@ var CBIZoneSelect = form.ListValue.extend({
                        }, this));
                }
                else if (isOutputOnly) {
-                       var emptyval = elem.querySelector('[data-value=""]');
+                       const emptyval = elem.querySelector('[data-value=""]');
                        emptyval.parentNode.removeChild(emptyval);
                }
 
@@ -245,7 +244,7 @@ var CBIZoneSelect = form.ListValue.extend({
 var CBIZoneForwards = form.DummyValue.extend({
        __name__: 'CBI.ZoneForwards',
 
-       load: function(section_id) {
+       load(section_id) {
                return Promise.all([
                        firewall.getDefaults(),
                        firewall.getZones(),
@@ -261,29 +260,29 @@ var CBIZoneForwards = form.DummyValue.extend({
                }, this));
        },
 
-       renderZone: function(zone) {
-               var name = zone.getName(),
-                   networks = zone.getNetworks(),
-                   devices = zone.getDevices(),
-                   subnets = zone.getSubnets(),
-                   ifaces = [];
+       renderZone(zone) {
+               const name = zone.getName();
+               const networks = zone.getNetworks();
+               const devices = zone.getDevices();
+               const subnets = zone.getSubnets();
+               const ifaces = [];
 
-               for (var j = 0; j < networks.length; j++) {
-                       var network = this.networks.filter(function(net) { return net.getName() == networks[j] })[0];
+               for (let n of networks) {
+                       const network = this.networks.filter(function(net) { return net.getName() == n })[0];
 
                        if (!network)
                                continue;
 
-                       var span = E('span', {
+                       const span = E('span', {
                                'class': 'ifacebadge' + (network.isUp() ? ' ifacebadge-active' : '')
                        }, network.getName() + ': ');
 
-                       var subdevs = getDevices(network);
+                       const subdevs = getDevices(network);
 
-                       for (var k = 0; k < subdevs.length && subdevs[k]; k++) {
+                       for (let s of subdevs) {
                                span.appendChild(E('img', {
-                                       'title': subdevs[k].getI18n(),
-                                       'src': L.resource('icons/%s%s.svg'.format(subdevs[k].getType(), subdevs[k].isUp() ? '' : '_disabled'))
+                                       'title': s.getI18n(),
+                                       'src': L.resource('icons/%s%s.svg'.format(s.getType(), s.isUp() ? '' : '_disabled'))
                                }));
                        }
 
@@ -293,18 +292,18 @@ var CBIZoneForwards = form.DummyValue.extend({
                        ifaces.push(span);
                }
 
-               for (var i = 0; i < devices.length; i++) {
-                       var device = this.devices.filter(function(dev) { return dev.getName() == devices[i] })[0],
-                           title = device ? device.getI18n() : _('Absent Interface'),
-                           type = device ? device.getType() : 'ethernet',
-                           up = device ? device.isUp() : false;
+               for (let d of devices) {
+                       const device = this.devices.filter(function(dev) { return dev.getName() == d })[0];
+                       const title = device ? device.getI18n() : _('Absent Interface');
+                       const type = device ? device.getType() : 'ethernet';
+                       const up = device ? device.isUp() : false;
 
                        ifaces.push(E('span', { 'class': 'ifacebadge' }, [
                                E('img', {
                                        'title': title,
                                        'src': L.resource('icons/%s%s.svg'.format(type, up ? '' : '_disabled'))
                                }),
-                               device ? device.getName() : devices[i]
+                               device ? device.getName() : d
                        ]));
                }
 
@@ -323,18 +322,18 @@ var CBIZoneForwards = form.DummyValue.extend({
                ]);
        },
 
-       renderWidget: function(section_id, option_index, cfgvalue) {
-               var value = (cfgvalue != null) ? cfgvalue : this.default,
-                   zone = this.zones.filter(function(z) { return z.getName() == value })[0];
+       renderWidget(section_id, option_index, cfgvalue) {
+               const value = (cfgvalue != null) ? cfgvalue : this.default;
+               const zone = this.zones.filter(function(z) { return z.getName() == value })[0];
 
                if (!zone)
                        return E([]);
 
-               var forwards = zone.getForwardingsBy('src'),
-                   dzones = [];
+               const forwards = zone.getForwardingsBy('src');
+               const dzones = [];
 
                for (var i = 0; i < forwards.length; i++) {
-                       var dzone = forwards[i].getDestinationZone();
+                       const dzone = forwards[i].getDestinationZone();
 
                        if (!dzone)
                                continue;
@@ -464,7 +463,7 @@ const CBIIPSelect = form.ListValue.extend({
 var CBINetworkSelect = form.ListValue.extend({
        __name__: 'CBI.NetworkSelect',
 
-       load: function(section_id) {
+       load(section_id) {
                return network.getNetworks().then(L.bind(function(networks) {
                        this.networks = networks;
 
@@ -472,18 +471,18 @@ var CBINetworkSelect = form.ListValue.extend({
                }, this));
        },
 
-       filter: function(section_id, value) {
+       filter(section_id, value) {
                return true;
        },
 
-       renderIfaceBadge: function(network) {
-               var span = E('span', { 'class': 'ifacebadge' }, network.getName() + ': '),
-                   devices = getDevices(network);
+       renderIfaceBadge(network) {
+               const span = E('span', { 'class': 'ifacebadge' }, network.getName() + ': ');
+               const devices = getDevices(network);
 
-               for (var j = 0; j < devices.length && devices[j]; j++) {
+               for (let d of devices) {
                        span.appendChild(E('img', {
-                               'title': devices[j].getI18n(),
-                               'src': L.resource('icons/%s%s.svg'.format(devices[j].getType(), devices[j].isUp() ? '' : '_disabled'))
+                               'title': d.getI18n(),
+                               'src': L.resource('icons/%s%s.svg'.format(d.getType(), d.isUp() ? '' : '_disabled'))
                        }));
                }
 
@@ -495,10 +494,10 @@ var CBINetworkSelect = form.ListValue.extend({
                return span;
        },
 
-       renderWidget: function(section_id, option_index, cfgvalue) {
-               var values = L.toArray((cfgvalue != null) ? cfgvalue : this.default),
-                   choices = {},
-                   checked = {};
+       renderWidget(section_id, option_index, cfgvalue) {
+               let values = L.toArray((cfgvalue != null) ? cfgvalue : this.default);
+               const choices = {};
+               const checked = {};
 
                for (var i = 0; i < values.length; i++)
                        checked[values[i]] = true;
@@ -508,9 +507,8 @@ var CBINetworkSelect = form.ListValue.extend({
                if (!this.multiple && (this.rmempty || this.optional))
                        choices[''] = E('em', _('unspecified'));
 
-               for (var i = 0; i < this.networks.length; i++) {
-                       var network = this.networks[i],
-                           name = network.getName();
+               for (let network of this.networks) {
+                       const name = network.getName();
 
                        if (name == this.exclude || !this.filter(section_id, name))
                                continue;
@@ -527,7 +525,7 @@ var CBINetworkSelect = form.ListValue.extend({
                        choices[name] = this.renderIfaceBadge(network);
                }
 
-               var widget = new ui.Dropdown(this.multiple ? values : values[0], choices, {
+               const widget = new ui.Dropdown(this.multiple ? values : values[0], choices, {
                        id: this.cbid(section_id),
                        sort: true,
                        multiple: this.multiple,
@@ -550,14 +548,13 @@ var CBINetworkSelect = form.ListValue.extend({
                return widget.render();
        },
 
-       textvalue: function(section_id) {
-               var cfgvalue = this.cfgvalue(section_id),
-                   values = L.toArray((cfgvalue != null) ? cfgvalue : this.default),
-                   rv = E([]);
+       textvalue(section_id) {
+               const cfgvalue = this.cfgvalue(section_id);
+               const values = L.toArray((cfgvalue != null) ? cfgvalue : this.default);
+               const rv = E([]);
 
-               for (var i = 0; i < (this.networks || []).length; i++) {
-                       var network = this.networks[i],
-                           name = network.getName();
+               for (let network of this.networks) {
+                       const name = network.getName();
 
                        if (values.indexOf(name) == -1)
                                continue;
@@ -578,7 +575,7 @@ var CBINetworkSelect = form.ListValue.extend({
 var CBIDeviceSelect = form.ListValue.extend({
        __name__: 'CBI.DeviceSelect',
 
-       load: function(section_id) {
+       load(section_id) {
                return Promise.all([
                        network.getDevices(),
                        this.noaliases ? null : network.getNetworks()
@@ -590,11 +587,11 @@ var CBIDeviceSelect = form.ListValue.extend({
                }, this));
        },
 
-       filter: function(section_id, value) {
+       filter(section_id, value) {
                return true;
        },
 
-       renderWidget: function(section_id, option_index, cfgvalue) {
+       renderWidget(section_id, option_index, cfgvalue) {
                var values = L.toArray((cfgvalue != null) ? cfgvalue : this.default),
                    choices = {},
                    checked = {},
@@ -608,10 +605,9 @@ var CBIDeviceSelect = form.ListValue.extend({
                if (!this.multiple && (this.rmempty || this.optional))
                        choices[''] = E('em', _('unspecified'));
 
-               for (var i = 0; i < this.devices.length; i++) {
-                       var device = this.devices[i],
-                           name = device.getName(),
-                           type = device.getType();
+               for (let device of this.devices) {
+                       const name = device.getName();
+                       const type = device.getType();
 
                        if (name == 'lo' || name == this.exclude || !this.filter(section_id, name))
                                continue;
@@ -625,7 +621,7 @@ var CBIDeviceSelect = form.ListValue.extend({
                        if (this.noinactive && device.isUp() == false)
                                continue;
 
-                       var item = E([
+                       const item = E([
                                E('img', {
                                        'title': device.getI18n(),
                                        'src': L.resource('icons/%s%s.svg'.format(type, device.isUp() ? '' : '_disabled'))
@@ -634,7 +630,7 @@ var CBIDeviceSelect = form.ListValue.extend({
                                E('span', { 'class': 'hide-close'}, [ device.getI18n() ])
                        ]);
 
-                       var networks = device.getNetworks();
+                       const networks = device.getNetworks();
 
                        if (networks.length > 0)
                                L.dom.append(item.lastChild, [ ' (', networks.map(function(n) { return n.getName() }).join(', '), ')' ]);
@@ -647,10 +643,9 @@ var CBIDeviceSelect = form.ListValue.extend({
                }
 
                if (this.networks != null) {
-                       for (var i = 0; i < this.networks.length; i++) {
-                               var net = this.networks[i],
-                                   device = network.instantiateDevice('@%s'.format(net.getName()), net),
-                                   name = device.getName();
+                       for (let net of this.networks) {
+                               const device = network.instantiateDevice('@%s'.format(net.getName()), net);
+                               const name = device.getName();
 
                                if (name == '@loopback' || name == this.exclude || !this.filter(section_id, name))
                                        continue;
@@ -658,7 +653,7 @@ var CBIDeviceSelect = form.ListValue.extend({
                                if (this.noinactive && net.isUp() == false)
                                        continue;
 
-                               var item = E([
+                               const item = E([
                                        E('img', {
                                                'title': device.getI18n(),
                                                'src': L.resource('icons/alias%s.svg'.format(device.isUp() ? '' : '_disabled'))
@@ -690,27 +685,27 @@ var CBIDeviceSelect = form.ListValue.extend({
                }
 
                if (!this.nocreate) {
-                       var keys = Object.keys(checked).sort(L.naturalCompare);
+                       const keys = Object.keys(checked).sort(L.naturalCompare);
 
-                       for (var i = 0; i < keys.length; i++) {
-                               if (choices.hasOwnProperty(keys[i]))
+                       for (let k of keys) {
+                               if (choices.hasOwnProperty(k))
                                        continue;
 
-                               choices[keys[i]] = E([
+                               choices[k] = E([
                                        E('img', {
                                                'title': _('Absent Interface'),
                                                'src': L.resource('icons/ethernet_disabled.svg')
                                        }),
-                                       E('span', { 'class': 'hide-open' }, [ keys[i] ]),
-                                       E('span', { 'class': 'hide-close'}, [ '%s: "%h"'.format(_('Absent Interface'), keys[i]) ])
+                                       E('span', { 'class': 'hide-open' }, [ k ]),
+                                       E('span', { 'class': 'hide-close'}, [ '%s: "%h"'.format(_('Absent Interface'), k) ])
                                ]);
 
-                               values.push(keys[i]);
-                               order.push(keys[i]);
+                               values.push(k);
+                               order.push(k);
                        }
                }
 
-               var widget = new ui.Dropdown(this.multiple ? values : values[0], choices, {
+               const widget = new ui.Dropdown(this.multiple ? values : values[0], choices, {
                        id: this.cbid(section_id),
                        sort: order,
                        multiple: this.multiple,
@@ -736,7 +731,7 @@ var CBIDeviceSelect = form.ListValue.extend({
 var CBIUserSelect = form.ListValue.extend({
        __name__: 'CBI.UserSelect',
 
-       load: function(section_id) {
+       load(section_id) {
                return getUsers().then(L.bind(function(users) {
                        delete this.keylist;
                        delete this.vallist;
@@ -748,7 +743,7 @@ var CBIUserSelect = form.ListValue.extend({
                }, this));
        },
 
-       filter: function(section_id, value) {
+       filter(section_id, value) {
                return true;
        },
 });
@@ -756,7 +751,7 @@ var CBIUserSelect = form.ListValue.extend({
 var CBIGroupSelect = form.ListValue.extend({
        __name__: 'CBI.GroupSelect',
 
-       load: function(section_id) {
+       load(section_id) {
                return getGroups().then(L.bind(function(groups) {
                        for (var i = 0; i < groups.length; i++) {
                                this.value(groups[i]);
@@ -766,7 +761,7 @@ var CBIGroupSelect = form.ListValue.extend({
                }, this));
        },
 
-       filter: function(section_id, value) {
+       filter(section_id, value) {
                return true;
        },
 });
index 021174e43ea43b2041536d273bef47c02385f6dd..d9673910e5b079788e3f250f72f5b7d801f0f2c1 100644 (file)
@@ -905,7 +905,6 @@ return baseclass.extend(/** @lends LuCI.uci.prototype */ {
         * have been reloaded by the save operation.
         */
        save() {
-               const v = this.state.values;
                const n = this.state.creates;
                const c = this.state.changes;
                const d = this.state.deletes;
index 85cc102ec50d9096ce9e6733a20e8a70d2770b07..15732a7e75cc43d486a53d797c7cf090d0175b03 100644 (file)
@@ -20,11 +20,11 @@ var callFileList = rpc.declare({
 
 network.registerPatternVirtual(/^3g-.+$/);
 
-function write_keepalive(section_id, value) {
-       var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
-           i_opt = this.map.lookupOption('_keepalive_interval', section_id),
-           f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
-           i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);
+function write_keepalive(section_id) {
+       const f_opt = this.map.lookupOption('_keepalive_failure', section_id);
+       const i_opt = this.map.lookupOption('_keepalive_interval', section_id);
+       let f = parseInt(f_opt?.[0]?.formvalue(section_id), 10);
+       let i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);
 
        if (isNaN(i))
                i = 1;
@@ -68,18 +68,18 @@ return network.registerProtocol('3g', {
        },
 
        renderFormOptions: function(s) {
-               var o;
+               let o;
 
                o = s.taboption('general', form.Value, '_modem_device', _('Modem device'));
                o.ucioption = 'device';
                o.rmempty = false;
                o.load = function(section_id) {
                        return callFileList('/dev/').then(L.bind(function(devices) {
-                               for (var i = 0; i < devices.length; i++)
+                               for (let i = 0; i < devices.length; i++)
                                        this.value(devices[i]);
                                return callFileList('/dev/tts/');
                        }, this)).then(L.bind(function(devices) {
-                               for (var i = 0; i < devices.length; i++)
+                               for (let i = 0; i < devices.length; i++)
                                        this.value(devices[i]);
                                return form.Value.prototype.load.apply(this, [section_id]);
                        }, this));
@@ -133,9 +133,9 @@ return network.registerProtocol('3g', {
                o.write       = write_keepalive;
                o.remove      = write_keepalive;
                o.cfgvalue = function(section_id) {
-                       var v = uci.get('network', section_id, 'keepalive');
+                       let v = uci.get('network', section_id, 'keepalive');
                        if (typeof(v) == 'string' && v != '') {
-                               var m = v.match(/^(\d+)[ ,]\d+$/);
+                               const m = v.match(/^(\d+)[ ,]\d+$/);
                                return m ? m[1] : v;
                        }
                };
@@ -146,9 +146,9 @@ return network.registerProtocol('3g', {
                o.write       = write_keepalive;
                o.remove      = write_keepalive;
                o.cfgvalue = function(section_id) {
-                       var v = uci.get('network', section_id, 'keepalive');
+                       let v = uci.get('network', section_id, 'keepalive');
                        if (typeof(v) == 'string' && v != '') {
-                               var m = v.match(/^\d+[ ,](\d+)$/);
+                               const m = v.match(/^\d+[ ,](\d+)$/);
                                return m ? m[1] : v;
                        }
                };
index 86ff009029dda816946a6e237d43e6f057b33e6f..01b4498e0ee80a98a7f97dabae3afd75da89926b 100644 (file)
@@ -59,36 +59,35 @@ function validateCert(priv, section_id, value) {
 }
 
 return network.registerProtocol('openconnect', {
-       getI18n: function() {
+       getI18n() {
                return _('OpenConnect');
        },
 
-       getIfname: function() {
+       getIfname() {
                return this._ubus('l3_device') || 'vpn-%s'.format(this.sid);
        },
 
-       getPackageName: function() {
+       getPackageName() {
                return 'openconnect';
        },
 
-       isFloating: function() {
+       isFloating() {
                return true;
        },
 
-       isVirtual: function() {
+       isVirtual() {
                return true;
        },
 
-       getDevices: function() {
+       getDevices() {
                return null;
        },
 
-       containsDevice: function(ifname) {
+       containsDevice(ifname) {
                return (network.getIfnameOf(ifname) == this.getIfname());
        },
 
-       renderFormOptions: function(s) {
-               const dev = this.getDevice().getName();
+       renderFormOptions(s) {
                let certLoadPromise = null;
                let o;
 
@@ -104,7 +103,7 @@ return network.registerProtocol('openconnect', {
                o = s.taboption('general', form.Value, 'uri', _('VPN Server'));
                o.placeholder = 'https://example.com:443/usergroup';
                o.validate = function(section_id, value) {
-                       const m = String(value).match(/^(?:(\w+):\/\/|)(?:\[([0-9a-f:.]{2,45})\]|([^\/:]+))(?::([0-9]{1,5}))?(?:\/.*)?$/i);
+                       const m = String(value).match(/^(?:(\w+):\/\/|)(?:\[([0-9a-f:.]{2,45})\]|([^/:]+))(?::([0-9]{1,5}))?(?:\/.*)?$/i);
 
                        if (!m)
                                return _('Invalid server URL');
index 48718afc269edbde19bc435f604082178b7fc004..8aa233cac868e2c86c609bd1334877bf3bf806c6 100644 (file)
@@ -4,14 +4,14 @@
 'require network';
 'require tools.widgets as widgets';
 
-var callGetCertificateFiles = rpc.declare({
+const callGetCertificateFiles = rpc.declare({
        object: 'luci.openfortivpn',
        method: 'getCertificates',
        params: [ 'interface' ],
        expect: { '': {} }
 });
 
-var callSetCertificateFiles = rpc.declare({
+const callSetCertificateFiles = rpc.declare({
        object: 'luci.openfortivpn',
        method: 'setCertificates',
        params: [ 'interface', 'user_cert', 'user_key', 'ca_file' ],
@@ -38,9 +38,9 @@ function sanitizeCert(s) {
 }
 
 function validateCert(priv, section_id, value) {
-       var lines = value.trim().split(/[\r\n]/),
-           start = false,
-           i;
+       const lines = value.trim().split(/[\r\n]/);
+       let start = false;
+       let i;
 
        if (value === null || value === '')
                return true;
@@ -48,7 +48,7 @@ function validateCert(priv, section_id, value) {
        for (i = 0; i < lines.length; i++) {
                if (lines[i].match(/^-{5}BEGIN ((|RSA |DSA )PRIVATE KEY|(|TRUSTED |X509 )CERTIFICATE)-{5}$/))
                        start = true;
-               else if (start && !lines[i].match(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/))
+               else if (start && !lines[i].match(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/))
                        break;
        }
 
@@ -59,36 +59,36 @@ function validateCert(priv, section_id, value) {
 }
 
 return network.registerProtocol('openfortivpn', {
-       getI18n: function() {
+       getI18n() {
                return _('OpenFortivpn');
        },
 
-       getIfname: function() {
+       getIfname() {
                return this._ubus('l3_device') || 'vpn-%s'.format(this.sid);
        },
 
-       getPackageName: function() {
+       getPackageName() {
                return 'openfortivpn';
        },
 
-       isFloating: function() {
+       isFloating() {
                return true;
        },
 
-       isVirtual: function() {
+       isVirtual() {
                return true;
        },
 
-       getDevices: function() {
+       getDevices() {
                return null;
        },
 
-       containsDevice: function(ifname) {
+       containsDevice(ifname) {
                return (network.getIfnameOf(ifname) == this.getIfname());
        },
 
-       renderFormOptions: function(s) {
-               var o;
+       renderFormOptions(s) {
+               let o, certLoadPromise;
 
                o = s.taboption('general', form.Value, 'peeraddr', _('VPN Server'));
                o.datatype = 'host(0)';
@@ -108,7 +108,7 @@ return network.registerProtocol('openfortivpn', {
                o.monospace = true;
                o.validate = L.bind(validateCert, o, false);
                o.load = function(section_id) {
-                       var certLoadPromise = certLoadPromise || callGetCertificateFiles(section_id);
+                       certLoadPromise = certLoadPromise || callGetCertificateFiles(section_id);
                        return certLoadPromise.then(function(certs) { return certs.user_cert });
                };
                o.write = function(section_id, value) {
@@ -121,7 +121,7 @@ return network.registerProtocol('openfortivpn', {
                o.monospace = true;
                o.validate = L.bind(validateCert, o, true);
                o.load = function(section_id) {
-                       var certLoadPromise = certLoadPromise || callGetCertificateFiles(section_id);
+                       certLoadPromise = certLoadPromise || callGetCertificateFiles(section_id);
                        return certLoadPromise.then(function(certs) { return certs.user_key });
                };
                o.write = function(section_id, value) {
@@ -134,7 +134,7 @@ return network.registerProtocol('openfortivpn', {
                o.monospace = true;
                o.validate = L.bind(validateCert, o, false);
                o.load = function(section_id) {
-                       var certLoadPromise = certLoadPromise || callGetCertificateFiles(section_id);
+                       certLoadPromise = certLoadPromise || callGetCertificateFiles(section_id);
                        return certLoadPromise.then(function(certs) { return certs.ca_file });
                };
                o.write = function(section_id, value) {
index 174142f18be6dd50cad344e4b391bb29eb8491ec..4924cf07025ba05f264c6d6346a014bfc3182ab8 100644 (file)
@@ -7,17 +7,17 @@
 network.registerPatternVirtual(/^relay-.+$/);
 
 var RelayDevicePrototype = {
-       __init__: function(ifname, network) {
+       __init__(ifname, network) {
                this.ifname  = ifname;
                this.network = network;
        },
 
-       _aggregateDevices: function(fn, first) {
-               var devices = this.network ? this.network.getDevices() : [],
-                   rv = 0;
+       _aggregateDevices(fn, first) {
+               const devices = this.network ? this.network.getDevices() : [];
+               let rv = 0;
 
-               for (var i = 0; i < devices.length; i++) {
-                       var v = devices[i][fn].apply(devices[i]);
+               for (let d of devices) {
+                       var v = d[fn].apply(d);
 
                        if (v != null) {
                                if (first)
@@ -30,88 +30,88 @@ var RelayDevicePrototype = {
                return first ? null : [ rv, devices.length ];
        },
 
-       getPorts: function() { return this.network ? this.network.getDevices() : [] },
+       getPorts() { return this.network ? this.network.getDevices() : [] },
 
-       getType: function() { return 'tunnel' },
-       getTypeI18n: function() { return _('Relay Bridge') },
+       getType() { return 'tunnel' },
+       getTypeI18n() { return _('Relay Bridge') },
 
-       getShortName: function() {
+       getShortName() {
                return '%s "%h"'.format(_('Relay'), this.ifname);
        },
 
-       isUp: function() {
+       isUp() {
                var res = this._aggregateDevices('isUp');
                return (res[1] > 0 && res[0] == res[1]);
        },
 
-       getTXBytes: function() { return this._aggregateDevices('getTXBytes')[0] },
-       getRXBytes: function() { return this._aggregateDevices('getRXBytes')[0] },
-       getTXPackets: function() { return this._aggregateDevices('getTXPackets')[0] },
-       getRXPackets: function() { return this._aggregateDevices('getRXPackets')[0] },
+       getTXBytes() { return this._aggregateDevices('getTXBytes')[0] },
+       getRXBytes() { return this._aggregateDevices('getRXBytes')[0] },
+       getTXPackets() { return this._aggregateDevices('getTXPackets')[0] },
+       getRXPackets() { return this._aggregateDevices('getRXPackets')[0] },
 
-       getMAC: function() { return this._aggregateDevices('getMAC', true) },
+       getMAC() { return this._aggregateDevices('getMAC', true) },
 
-       getIPAddrs: function() {
+       getIPAddrs() {
                var ipaddr = this.network ? L.toArray(uci.get('network', this.network.getName(), 'ipaddr'))[0] : null;
                return (ipaddr != null ? [ ipaddr ] : []);
        },
 
-       getIP6Addrs: function() { return [] }
+       getIP6Addrs() { return [] }
 };
 
 return network.registerProtocol('relay', {
-       getI18n: function() {
+       getI18n() {
                return _('Relay bridge');
        },
 
-       getIfname: function() {
+       getIfname() {
                return 'relay-%s'.format(this.sid);
        },
 
-       getPackageName: function() {
+       getPackageName() {
                return 'relayd';
        },
 
-       isFloating: function() {
+       isFloating() {
                return true;
        },
 
-       isVirtual: function() {
+       isVirtual() {
                return true;
        },
 
-       containsDevice: function(ifname) {
+       containsDevice(ifname) {
                return (network.getIfnameOf(ifname) == this.getIfname());
        },
 
-       isUp: function() {
+       isUp() {
                var dev = this.getDevice();
                return (dev ? dev.isUp() : false);
        },
 
-       getDevice: function() {
+       getDevice() {
                return network.instantiateDevice(this.sid, this, RelayDevicePrototype);
        },
 
-       getDevices: function() {
+       getDevices() {
                if (this.devices)
                        return this.devices;
 
-               var networkNames = L.toArray(uci.get('network', this.sid, 'network')),
-                   deviceNames = L.toArray(uci.get('network', this.sid, 'ifname')),
-                   devices = {},
-                   rv = [];
+               const networkNames = L.toArray(uci.get('network', this.sid, 'network'));
+               let deviceNames = L.toArray(uci.get('network', this.sid, 'ifname'));
+               const devices = {};
+               const rv = [];
 
-               for (var i = 0; i < networkNames.length; i++) {
-                       var net = network.instantiateNetwork(networkNames[i]),
+               for (let nn of networkNames) {
+                       var net = network.instantiateNetwork(nn),
                            dev = net ? net.getDevice() : null;
 
                        if (dev)
                                devices[dev.getName()] = dev;
                }
 
-               for (var i = 0; i < deviceNames.length; i++) {
-                       var dev = network.getDevice(deviceNames[i]);
+               for (let dn of deviceNames) {
+                       const dev = network.getDevice(dn);
 
                        if (dev)
                                devices[dev.getName()] = dev;
@@ -120,20 +120,20 @@ return network.registerProtocol('relay', {
                deviceNames = Object.keys(devices);
                deviceNames.sort();
 
-               for (var i = 0; i < deviceNames.length; i++)
-                       rv.push(devices[deviceNames[i]]);
+               for (let dn of deviceNames)
+                       rv.push(devices[dn]);
 
                this.devices = rv;
 
                return rv;
        },
 
-       getUptime: function() {
-               var networkNames = L.toArray(uci.get('network', this.sid, 'network')),
-                   uptime = 0;
+       getUptime() {
+               const networkNames = L.toArray(uci.get('network', this.sid, 'network'));
+               let uptime = 0;
 
-               for (var i = 0; i < networkNames.length; i++) {
-                       var net = network.instantiateNetwork(networkNames[i]);
+               for (let nn of networkNames) {
+                       const net = network.instantiateNetwork(nn);
                        if (net)
                                uptime = Math.max(uptime, net.getUptime());
                }
@@ -141,11 +141,11 @@ return network.registerProtocol('relay', {
                return uptime;
        },
 
-       getErrors: function() {
+       getErrors() {
                return null;
        },
 
-       renderFormOptions: function(s) {
+       renderFormOptions(s) {
                var o;
 
                o = s.taboption('general', form.Value, 'ipaddr', _('Local IPv4 address'), _('Address to access local relay bridge'));
index ce25a4f57e2f644430092fae84687711fa42f030..d4d6ed7c22676976a726bd45f5bb93027bb8c34b 100644 (file)
@@ -34,7 +34,7 @@ function validateBase64(section_id, value) {
        if (value.length == 0)
                return true;
 
-       if (value.length != 44 || !value.match(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/))
+       if (value.length != 44 || !value.match(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/))
                return _('Invalid Base64 key string');
 
        if (value[43] != "=" )
@@ -45,26 +45,17 @@ function validateBase64(section_id, value) {
 
 var stubValidator = {
        factory: validation,
-       apply: function(type, value, args) {
+       apply(type, value, args) {
                if (value != null)
                        this.value = value;
 
                return validation.types[type].apply(this, args);
        },
-       assert: function(condition) {
+       assert(condition) {
                return !!condition;
        }
 };
 
-function generateDescription(name, texts) {
-       return E('li', { 'style': 'color: inherit;' }, [
-               E('span', name),
-               E('ul', texts.map(function (text) {
-                       return E('li', { 'style': 'color: inherit;' }, text);
-               }))
-       ]);
-}
-
 function buildSVGQRCode(data, code) {
        // pixel size larger than 4 clips right and bottom edges of complex configs
        const options = {
@@ -78,7 +69,7 @@ function buildSVGQRCode(data, code) {
 }
 
 var cbiKeyPairGenerate = form.DummyValue.extend({
-       cfgvalue: function(section_id, value) {
+       cfgvalue(section_id, value) {
                return E('button', {
                        'class': 'btn',
                        'click': ui.createHandlerFn(this, function(section_id, ev) {
@@ -101,36 +92,36 @@ function handleWindowDragDropIgnore(ev) {
 }
 
 return network.registerProtocol('wireguard', {
-       getI18n: function() {
+       getI18n() {
                return _('WireGuard VPN');
        },
 
-       getIfname: function() {
+       getIfname() {
                return this._ubus('l3_device') || this.sid;
        },
 
-       getPackageName: function() {
+       getPackageName() {
                return 'wireguard-tools';
        },
 
-       isFloating: function() {
+       isFloating() {
                return true;
        },
 
-       isVirtual: function() {
+       isVirtual() {
                return true;
        },
 
-       getDevices: function() {
+       getDevices() {
                return null;
        },
 
-       containsDevice: function(ifname) {
+       containsDevice(ifname) {
                return (network.getIfnameOf(ifname) == this.getIfname());
        },
 
-       renderFormOptions: function(s) {
-               var o, ss, ss2;
+       renderFormOptions(s) {
+               var o, ss;
 
                // -- general ---------------------------------------------------------------------
 
@@ -139,8 +130,6 @@ return network.registerProtocol('wireguard', {
                o.validate = validateBase64;
                o.rmempty = false;
 
-               var serverName = this.getIfname();
-
                o = s.taboption('general', form.Value, 'public_key', _('Public Key'), _('Base64-encoded public key of this interface for sharing.'));
                o.rmempty = false;
                o.write = function() {/* write nothing */};
@@ -268,16 +257,16 @@ return network.registerProtocol('wireguard', {
                        if (config.interface_address) {
                                config.interface_address = config.interface_address.split(/[, ]+/);
 
-                               for (var i = 0; i < config.interface_address.length; i++)
-                                       if (!stubValidator.apply('ipaddr', config.interface_address[i]))
+                               for (let cfia of config.interface_address)
+                                       if (!stubValidator.apply('ipaddr', cfia))
                                                return _('Address setting is invalid');
                        }
 
                        if (config.interface_dns) {
                                config.interface_dns = config.interface_dns.split(/[, ]+/);
 
-                               for (var i = 0; i < config.interface_dns.length; i++)
-                                       if (!stubValidator.apply('ipaddr', config.interface_dns[i], ['nomask']))
+                               for (let cfid of config.interface_dns)
+                                       if (!stubValidator.apply('ipaddr', cfid, ['nomask']))
                                                return _('DNS setting is invalid');
                        }
 
@@ -287,9 +276,7 @@ return network.registerProtocol('wireguard', {
                        if (!stubValidator.apply('port', config.interface_listenport || '0'))
                                return _('ListenPort setting is invalid');
 
-                       for (var i = 0; i < config.peers.length; i++) {
-                               var pconf = config.peers[i];
-
+                       for (let pconf of config.peers) {
                                if (pconf.peer_publickey != null && validateBase64(null, pconf.peer_publickey) !== true)
                                        return _('PublicKey setting is invalid');
 
@@ -327,10 +314,10 @@ return network.registerProtocol('wireguard', {
                };
 
                ss.handleApplyConfig = function(mode, nodes, comment, ev) {
-                       var input = nodes.querySelector('textarea').value,
-                           error = nodes.querySelector('.alert-message'),
-                           cancel = nodes.nextElementSibling.querySelector('.btn'),
-                           config = this.parseConfig(input);
+                       const input = nodes.querySelector('textarea').value;
+                       const error = nodes.querySelector('.alert-message');
+                       const cancel = nodes.nextElementSibling.querySelector('.btn');
+                       const config = this.parseConfig(input);
 
                        if (typeof(config) == 'string') {
                                error.firstChild.data = _('Cannot parse configuration: %s').format(config);
@@ -339,7 +326,7 @@ return network.registerProtocol('wireguard', {
                        }
 
                        if (mode == 'full') {
-                               var prv = s.formvalue(s.section, 'private_key');
+                               const prv = s.formvalue(s.section, 'private_key');
 
                                if (prv && prv != config.interface_privatekey && !confirm(_('Overwrite the current settings with the imported configuration?')))
                                        return;
@@ -353,9 +340,8 @@ return network.registerProtocol('wireguard', {
                                        if (config.interface_dns)
                                                s.getOption('dns').getUIElement(s.section).setValue(config.interface_dns);
 
-                                       for (var i = 0; i < config.peers.length; i++) {
-                                               var pconf = config.peers[i];
-                                               var sid = uci.add('network', 'wireguard_' + s.section);
+                                       for (let pconf of config.peers) {
+                                               const sid = uci.add('network', 'wireguard_' + s.section);
 
                                                uci.sections('network', 'wireguard_' + s.section, function(peer) {
                                                        if (peer.public_key == pconf.peer_publickey)
@@ -381,8 +367,8 @@ return network.registerProtocol('wireguard', {
                        }
                        else {
                                return getPublicAndPrivateKeyFromPrivate(config.interface_privatekey).then(function(keypair) {
-                                       var sid = uci.add('network', 'wireguard_' + s.section);
-                                       var pub = s.formvalue(s.section, 'public_key');
+                                       const sid = uci.add('network', 'wireguard_' + s.section);
+                                       const pub = s.formvalue(s.section, 'public_key');
 
                                        uci.sections('network', 'wireguard_' + s.section, function(peer) {
                                                if (peer.public_key == keypair.pub)
@@ -393,9 +379,7 @@ return network.registerProtocol('wireguard', {
                                        uci.set('network', sid, 'public_key', keypair.pub);
                                        uci.set('network', sid, 'private_key', keypair.priv);
 
-                                       for (var i = 0; i < config.peers.length; i++) {
-                                               var pconf = config.peers[i];
-
+                                       for (let pconf of config.peers) {
                                                if (pconf.peer_publickey == pub) {
                                                        uci.set('network', sid, 'preshared_key', pconf.peer_presharedkey);
                                                        uci.set('network', sid, 'allowed_ips', pconf.peer_allowedips);
@@ -412,11 +396,10 @@ return network.registerProtocol('wireguard', {
                };
 
                ss.handleConfigImport = function(mode) {
-                       var mapNode = ss.getActiveModalMap(),
-                           headNode = mapNode.parentNode.querySelector('h4'),
-                           parent = this.map;
+                       const mapNode = ss.getActiveModalMap();
+                       const headNode = mapNode.parentNode.querySelector('h4');
 
-                       var nodes = E('div', {
+                       const nodes = E('div', {
                                'dragover': this.handleDragConfig,
                                'drop': this.handleDropConfig.bind(this, mode)
                        }, [
@@ -440,7 +423,7 @@ return network.registerProtocol('wireguard', {
                                }, [''])
                        ]);
 
-                       var cancelFn = function() {
+                       const cancelFn = function() {
                                nodes.parentNode.removeChild(nodes.nextSibling);
                                nodes.parentNode.removeChild(nodes);
                                mapNode.classList.remove('hidden');
@@ -450,7 +433,7 @@ return network.registerProtocol('wireguard', {
                                window.removeEventListener('drop', handleWindowDragDropIgnore);
                        };
 
-                       var a = nodes.querySelector('a.full-import');
+                       const a = nodes.querySelector('a.full-import');
 
                        if (a) {
                                a.addEventListener('click', ui.createHandlerFn(this, function(mode) {
@@ -485,7 +468,7 @@ return network.registerProtocol('wireguard', {
                };
 
                ss.renderSectionAdd = function(/* ... */) {
-                       var nodes = this.super('renderSectionAdd', arguments);
+                       const nodes = this.super('renderSectionAdd', arguments);
 
                        nodes.appendChild(E('button', {
                                'class': 'btn',
@@ -510,14 +493,14 @@ return network.registerProtocol('wireguard', {
                o.optional = true;
                o.width = '30%';
                o.textvalue = function(section_id) {
-                       var dis = ss.getOption('disabled'),
-                           pub = ss.getOption('public_key'),
-                           prv = ss.getOption('private_key'),
-                           psk = ss.getOption('preshared_key'),
-                           name = this.cfgvalue(section_id),
-                           key = pub.cfgvalue(section_id);
-
-                       var desc = [
+                       const dis = ss.getOption('disabled');
+                       const pub = ss.getOption('public_key');
+                       const prv = ss.getOption('private_key');
+                       const psk = ss.getOption('preshared_key');
+                       const name = this.cfgvalue(section_id);
+                       const key = pub.cfgvalue(section_id);
+
+                       const desc = [
                                E('p', [
                                        name ? E('span', [ name ]) : E('em', [ _('Untitled peer') ])
                                ])
@@ -566,8 +549,8 @@ return network.registerProtocol('wireguard', {
                };
 
                function handleKeyChange(ev, section_id, value) {
-                       var prv = this.section.getUIElement(section_id, 'private_key'),
-                           btn = this.map.findElement('.btn.qr-code');
+                       const prv = this.section.getUIElement(section_id, 'private_key');
+                       const btn = this.map.findElement('.btn.qr-code');
 
                        btn.disabled = (!prv.isValid() || !prv.getValue());
                }
@@ -611,8 +594,8 @@ return network.registerProtocol('wireguard', {
                o = ss.option(form.DynamicList, 'allowed_ips', _('Allowed IPs'), _("Optional. IP addresses and prefixes that this peer is allowed to use inside the tunnel. Usually the peer's tunnel IP addresses and the networks the peer routes through the tunnel."));
                o.datatype = 'ipaddr';
                o.textvalue = function(section_id) {
-                       var ips = L.toArray(this.cfgvalue(section_id)),
-                           list = [];
+                       const ips = L.toArray(this.cfgvalue(section_id));
+                       const list = [];
 
                        for (var i = 0; i < ips.length; i++) {
                                if (i > 7) {
@@ -650,8 +633,8 @@ return network.registerProtocol('wireguard', {
                o.placeholder = 'vpn.example.com';
                o.datatype = 'host';
                o.textvalue = function(section_id) {
-                       var host = this.cfgvalue(section_id),
-                           port = this.section.cfgvalue(section_id, 'endpoint_port');
+                       const host = this.cfgvalue(section_id);
+                       const port = this.section.cfgvalue(section_id, 'endpoint_port');
 
                        return (host && port)
                                ? '%h:%d'.format(host, port)
@@ -680,12 +663,12 @@ return network.registerProtocol('wireguard', {
                o.modalonly = true;
 
                o.createPeerConfig = function(section_id, endpoint, ips, eips, dns) {
-                       var pub = s.formvalue(s.section, 'public_key'),
-                           port = s.formvalue(s.section, 'listen_port') || '51820',
-                           prv = this.section.formvalue(section_id, 'private_key'),
-                           psk = this.section.formvalue(section_id, 'preshared_key'),
-                           eport = this.section.formvalue(section_id, 'endpoint_port'),
-                           keep = this.section.formvalue(section_id, 'persistent_keepalive');
+                       const pub = s.formvalue(s.section, 'public_key');
+                       const port = s.formvalue(s.section, 'listen_port') || '51820';
+                       const prv = this.section.formvalue(section_id, 'private_key');
+                       const psk = this.section.formvalue(section_id, 'preshared_key');
+                       const eport = this.section.formvalue(section_id, 'endpoint_port');
+                       const keep = this.section.formvalue(section_id, 'persistent_keepalive');
 
                        // If endpoint is IPv6 we must escape it with []
                        if (endpoint.indexOf(':') > 0) {
@@ -709,11 +692,11 @@ return network.registerProtocol('wireguard', {
                };
 
                o.handleGenerateQR = function(section_id, ev) {
-                       var mapNode = ss.getActiveModalMap(),
-                           headNode = mapNode.parentNode.querySelector('h4'),
-                           configGenerator = this.createPeerConfig.bind(this, section_id),
-                           parent = this.map,
-                               eips = this.section.formvalue(section_id, 'allowed_ips');
+                       const mapNode = ss.getActiveModalMap();
+                       const headNode = mapNode.parentNode.querySelector('h4');
+                       const configGenerator = this.createPeerConfig.bind(this, section_id);
+                       const parent = this.map;
+                       const eips = this.section.formvalue(section_id, 'allowed_ips');
 
                        return Promise.all([
                                network.getWANNetworks(),
@@ -722,8 +705,8 @@ return network.registerProtocol('wireguard', {
                                L.resolveDefault(uci.load('ddns')),
                                L.resolveDefault(uci.load('system')),
                                parent.save(null, true)
-                       ]).then(function(data) {
-                               var hostnames = [];
+                       ]).then(function([wNets, w6Nets, lnet]) {
+                               const hostnames = [];
 
                                uci.sections('ddns', 'service', function(s) {
                                        if (typeof(s?.lookup_host) == 'string' && s?.enabled == '1')
@@ -735,25 +718,24 @@ return network.registerProtocol('wireguard', {
                                                hostnames.push(s.hostname);
                                });
 
-                               for (var i = 0; i < data[0].length; i++)
-                                       hostnames.push.apply(hostnames, data[0][i].getIPAddrs().map(function(ip) { return ip.split('/')[0] }));
+                               for (let wNet of wNets)
+                                       hostnames.push.apply(hostnames, wNet.getIPAddrs().map(function(ip) { return ip.split('/')[0] }));
 
-                               for (var i = 0; i < data[1].length; i++)
-                                       hostnames.push.apply(hostnames, data[1][i].getIP6Addrs().map(function(ip) { return ip.split('/')[0] }));
+                               for (let w6Net of w6Nets)
+                                       hostnames.push.apply(hostnames, w6Net.getIP6Addrs().map(function(ip) { return ip.split('/')[0] }));
 
-                               var ips = [ '0.0.0.0/0', '::/0' ];
+                               const ips = [ '0.0.0.0/0', '::/0' ];
 
-                               var dns = [];
+                               const dns = [];
 
-                               var lan = data[2];
-                               if (lan) {
-                                       var lanIp = lan.getIPAddr();
+                               if (lnet) {
+                                       const lanIp = lnet.getIPAddr();
                                        if (lanIp) {
                                                dns.unshift(lanIp)
                                        }
                                }
 
-                               var qrm, qrs, qro;
+                               let qrm, qrs, qro;
 
                                qrm = new form.JSONMap({ config: { endpoint: hostnames[0], allowed_ips: ips, addresses: eips, dns_servers: dns } }, null, _('The generated configuration can be imported into a WireGuard client application to set up a connection towards this device.'));
                                qrm.parent = parent;
@@ -761,12 +743,12 @@ return network.registerProtocol('wireguard', {
                                qrs = qrm.section(form.NamedSection, 'config');
 
                                function handleConfigChange(ev, section_id, value) {
-                                       var code = this.map.findElement('.qr-code'),
-                                           conf = this.map.findElement('.client-config'),
-                                           endpoint = this.section.getUIElement(section_id, 'endpoint'),
-                                           ips = this.section.getUIElement(section_id, 'allowed_ips');
-                                           eips = this.section.getUIElement(section_id, 'addresses');
-                                           dns = this.section.getUIElement(section_id, 'dns_servers');
+                                       const code = this.map.findElement('.qr-code');
+                                       const conf = this.map.findElement('.client-config');
+                                       const endpoint = this.section.getUIElement(section_id, 'endpoint');
+                                       const ips = this.section.getUIElement(section_id, 'allowed_ips');
+                                       const eips = this.section.getUIElement(section_id, 'addresses');
+                                       const dns = this.section.getUIElement(section_id, 'dns_servers');
 
                                        if (this.isValid(section_id)) {
                                                conf.firstChild.data = configGenerator(endpoint.getValue(), ips.getValue(), eips.getValue(), dns.getValue());
@@ -800,9 +782,9 @@ return network.registerProtocol('wireguard', {
 
                                qro = qrs.option(form.DummyValue, 'output');
                                qro.renderWidget = function() {
-                                       var peer_config = configGenerator(hostnames[0], ips, eips, dns);
+                                       const peer_config = configGenerator(hostnames[0], ips, eips, dns);
 
-                                       var node = E('div', {
+                                       const node = E('div', {
                                                'style': 'display:flex;flex-wrap:wrap;align-items:center;gap:.5em;width:100%'
                                        }, [
                                                E('div', {
@@ -814,9 +796,9 @@ return network.registerProtocol('wireguard', {
                                                E('pre', {
                                                        'class': 'client-config',
                                                        'style': 'flex:1;white-space:pre;overflow:auto',
-                                                       'click': function(ev) {
-                                                               var sel = window.getSelection(),
-                                                                   range = document.createRange();
+                                                       'click'(ev) {
+                                                               const sel = window.getSelection();
+                                                               const range = document.createRange();
 
                                                                range.selectNodeContents(ev.currentTarget);
 
@@ -849,7 +831,7 @@ return network.registerProtocol('wireguard', {
                                                }, [
                                                        E('button', {
                                                                'class': 'btn',
-                                                               'click': function() {
+                                                               'click'() {
                                                                        // Remove QR code button (row)
                                                                        nodes.parentNode.removeChild(nodes.nextSibling);
                                                                        // Remove QR code form
@@ -891,7 +873,7 @@ return network.registerProtocol('wireguard', {
                };
        },
 
-       deleteConfiguration: function() {
+       deleteConfiguration() {
                uci.sections('network', 'wireguard_%s'.format(this.sid), function(s) {
                        uci.remove('network', s['.name']);
                });
git clone https://git.99rst.org/PROJECT