mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-12 10:31:51 +00:00
Update luci-mod-network to upstream and add multipath and latency support
This commit is contained in:
parent
490133cea7
commit
94f2c90ad4
8 changed files with 1859 additions and 382 deletions
|
@ -1,10 +1,10 @@
|
|||
#
|
||||
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
|
||||
# Copyright (C) 2020 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
|
||||
# Copyright (C) 2020-2021 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
# From https://github.com/openwrt/luci/commit/f5c04e1a2e173f536597f220db0380cc08869e8e
|
||||
# From https://github.com/openwrt/luci/commit/b88157e69a060ade618e48b30947729310935d61
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
|
|
913
luci-mod-network/htdocs/luci-static/resources/tools/network.js
Normal file
913
luci-mod-network/htdocs/luci-static/resources/tools/network.js
Normal file
|
@ -0,0 +1,913 @@
|
|||
'use strict';
|
||||
'require ui';
|
||||
'require dom';
|
||||
'require uci';
|
||||
'require form';
|
||||
'require network';
|
||||
'require baseclass';
|
||||
'require validation';
|
||||
'require tools.widgets as widgets';
|
||||
|
||||
function validateAddr(section_id, value) {
|
||||
if (value == '')
|
||||
return true;
|
||||
|
||||
var ipv6 = /6$/.test(this.section.formvalue(section_id, 'mode')),
|
||||
addr = ipv6 ? validation.parseIPv6(value) : validation.parseIPv4(value);
|
||||
|
||||
return addr ? true : (ipv6 ? _('Expecting a valid IPv6 address') : _('Expecting a valid IPv4 address'));
|
||||
}
|
||||
|
||||
function validateQoSMap(section_id, value) {
|
||||
if (value == '')
|
||||
return true;
|
||||
|
||||
var m = value.match(/^(\d+):(\d+)$/);
|
||||
|
||||
if (!m || +m[1] > 0xFFFFFFFF || +m[2] > 0xFFFFFFFF)
|
||||
return _('Expecting two priority values separated by a colon');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function deviceSectionExists(section_id, devname) {
|
||||
var exists = false;
|
||||
|
||||
uci.sections('network', 'device', function(ss) {
|
||||
exists = exists || (
|
||||
ss['.name'] != section_id &&
|
||||
ss.name == devname
|
||||
);
|
||||
});
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
function isBridgePort(dev) {
|
||||
if (!dev)
|
||||
return false;
|
||||
|
||||
if (dev.isBridgePort())
|
||||
return true;
|
||||
|
||||
var isPort = false;
|
||||
|
||||
uci.sections('network', null, function(s) {
|
||||
if (s['.type'] != 'interface' && s['.type'] != 'device')
|
||||
return;
|
||||
|
||||
if (s.type == 'bridge' && L.toArray(s.ifname).indexOf(dev.getName()) > -1)
|
||||
isPort = true;
|
||||
});
|
||||
|
||||
return isPort;
|
||||
}
|
||||
|
||||
function updateDevBadge(node, dev) {
|
||||
var type = dev.getType(),
|
||||
up = dev.getCarrier();
|
||||
|
||||
dom.content(node, [
|
||||
E('img', {
|
||||
'class': 'middle',
|
||||
'src': L.resource('icons/%s%s.png').format(type, up ? '' : '_disabled')
|
||||
}),
|
||||
'\x0a', dev.getName()
|
||||
]);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function renderDevBadge(dev) {
|
||||
return updateDevBadge(E('span', {
|
||||
'class': 'ifacebadge port-status-device',
|
||||
'style': 'font-weight:normal',
|
||||
'data-device': dev.getName()
|
||||
}), dev);
|
||||
}
|
||||
|
||||
function updatePortStatus(node, dev) {
|
||||
var carrier = dev.getCarrier(),
|
||||
duplex = dev.getDuplex(),
|
||||
speed = dev.getSpeed(),
|
||||
desc, title;
|
||||
|
||||
if (carrier && speed > 0 && duplex != null) {
|
||||
desc = '%d%s'.format(speed, duplex == 'full' ? 'FD' : 'HD');
|
||||
title = '%s, %d MBit/s, %s'.format(_('Connected'), speed, duplex == 'full' ? _('full-duplex') : _('half-duplex'));
|
||||
}
|
||||
else if (carrier) {
|
||||
desc = _('Connected');
|
||||
}
|
||||
else {
|
||||
desc = _('no link');
|
||||
}
|
||||
|
||||
dom.content(node, [
|
||||
E('img', {
|
||||
'class': 'middle',
|
||||
'src': L.resource('icons/port_%s.png').format(carrier ? 'up' : 'down')
|
||||
}),
|
||||
'\x0a', desc
|
||||
]);
|
||||
|
||||
if (title)
|
||||
node.setAttribute('data-tooltip', title);
|
||||
else
|
||||
node.removeAttribute('data-tooltip');
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function renderPortStatus(dev) {
|
||||
return updatePortStatus(E('span', {
|
||||
'class': 'ifacebadge port-status-link',
|
||||
'data-device': dev.getName()
|
||||
}), dev);
|
||||
}
|
||||
|
||||
function updatePlaceholders(opt, section_id) {
|
||||
var dev = network.instantiateDevice(opt.getUIElement(section_id).getValue());
|
||||
|
||||
for (var i = 0, co; (co = opt.section.children[i]) != null; i++) {
|
||||
if (co !== opt) {
|
||||
switch (co.option) {
|
||||
case 'mtu':
|
||||
case 'mtu6':
|
||||
co.getUIElement(section_id).setPlaceholder(dev.getMTU());
|
||||
break;
|
||||
|
||||
case 'macaddr':
|
||||
co.getUIElement(section_id).setPlaceholder(dev.getMAC());
|
||||
break;
|
||||
|
||||
case 'txqueuelen':
|
||||
co.getUIElement(section_id).setPlaceholder(dev._devstate('qlen'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var cbiTagValue = form.Value.extend({
|
||||
renderWidget: function(section_id, option_index, cfgvalue) {
|
||||
var widget = new ui.Dropdown(cfgvalue || ['-'], {
|
||||
'-': E([], [
|
||||
E('span', { 'class': 'hide-open', 'style': 'font-family:monospace' }, [ '—' ]),
|
||||
E('span', { 'class': 'hide-close' }, [ _('Do not participate', 'VLAN port state') ])
|
||||
]),
|
||||
'u': E([], [
|
||||
E('span', { 'class': 'hide-open', 'style': 'font-family:monospace' }, [ 'u' ]),
|
||||
E('span', { 'class': 'hide-close' }, [ _('Egress untagged', 'VLAN port state') ])
|
||||
]),
|
||||
't': E([], [
|
||||
E('span', { 'class': 'hide-open', 'style': 'font-family:monospace' }, [ 't' ]),
|
||||
E('span', { 'class': 'hide-close' }, [ _('Egress tagged', 'VLAN port state') ])
|
||||
]),
|
||||
'*': E([], [
|
||||
E('span', { 'class': 'hide-open', 'style': 'font-family:monospace' }, [ '*' ]),
|
||||
E('span', { 'class': 'hide-close' }, [ _('Primary VLAN ID', 'VLAN port state') ])
|
||||
])
|
||||
}, {
|
||||
id: this.cbid(section_id),
|
||||
sort: [ '-', 'u', 't', '*' ],
|
||||
optional: false,
|
||||
multiple: true
|
||||
});
|
||||
|
||||
var field = this;
|
||||
|
||||
widget.toggleItem = function(sb, li, force_state) {
|
||||
var lis = li.parentNode.querySelectorAll('li'),
|
||||
toggle = ui.Dropdown.prototype.toggleItem;
|
||||
|
||||
toggle.apply(this, [sb, li, force_state]);
|
||||
|
||||
if (force_state != null)
|
||||
return;
|
||||
|
||||
switch (li.getAttribute('data-value'))
|
||||
{
|
||||
case '-':
|
||||
if (li.hasAttribute('selected')) {
|
||||
for (var i = 0; i < lis.length; i++) {
|
||||
switch (lis[i].getAttribute('data-value')) {
|
||||
case '-':
|
||||
break;
|
||||
|
||||
case '*':
|
||||
toggle.apply(this, [sb, lis[i], false]);
|
||||
lis[i].setAttribute('unselectable', '');
|
||||
break;
|
||||
|
||||
default:
|
||||
toggle.apply(this, [sb, lis[i], false]);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 't':
|
||||
case 'u':
|
||||
if (li.hasAttribute('selected')) {
|
||||
for (var i = 0; i < lis.length; i++) {
|
||||
switch (lis[i].getAttribute('data-value')) {
|
||||
case li.getAttribute('data-value'):
|
||||
break;
|
||||
|
||||
case '*':
|
||||
lis[i].removeAttribute('unselectable');
|
||||
break;
|
||||
|
||||
default:
|
||||
toggle.apply(this, [sb, lis[i], false]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
toggle.apply(this, [sb, li, true]);
|
||||
}
|
||||
break;
|
||||
|
||||
case '*':
|
||||
if (li.hasAttribute('selected')) {
|
||||
var section_ids = field.section.cfgsections();
|
||||
|
||||
for (var i = 0; i < section_ids.length; i++) {
|
||||
var other_widget = field.getUIElement(section_ids[i]),
|
||||
other_value = L.toArray(other_widget.getValue());
|
||||
|
||||
if (other_widget === this)
|
||||
continue;
|
||||
|
||||
var new_value = other_value.filter(function(v) { return v != '*' });
|
||||
|
||||
if (new_value.length == other_value.length)
|
||||
continue;
|
||||
|
||||
other_widget.setValue(new_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var node = widget.render();
|
||||
|
||||
node.style.minWidth = '4em';
|
||||
|
||||
if (cfgvalue == '-')
|
||||
node.querySelector('li[data-value="*"]').setAttribute('unselectable', '');
|
||||
|
||||
return E('div', { 'style': 'display:inline-block' }, node);
|
||||
},
|
||||
|
||||
cfgvalue: function(section_id) {
|
||||
var ports = L.toArray(uci.get('network', section_id, 'ports'));
|
||||
|
||||
for (var i = 0; i < ports.length; i++) {
|
||||
var s = ports[i].split(/:/);
|
||||
|
||||
if (s[0] != this.port)
|
||||
continue;
|
||||
|
||||
var t = /t/.test(s[1] || '') ? 't' : 'u';
|
||||
|
||||
return /\*/.test(s[1] || '') ? [t, '*'] : [t];
|
||||
}
|
||||
|
||||
return ['-'];
|
||||
},
|
||||
|
||||
write: function(section_id, value) {
|
||||
var ports = [];
|
||||
|
||||
for (var i = 0; i < this.section.children.length; i++) {
|
||||
var opt = this.section.children[i];
|
||||
|
||||
if (opt.port) {
|
||||
var val = L.toArray(opt.formvalue(section_id)).join('');
|
||||
|
||||
switch (val) {
|
||||
case '-':
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
ports.push(opt.port);
|
||||
break;
|
||||
|
||||
default:
|
||||
ports.push('%s:%s'.format(opt.port, val));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uci.set('network', section_id, 'ports', ports);
|
||||
},
|
||||
|
||||
remove: function() {}
|
||||
});
|
||||
|
||||
return baseclass.extend({
|
||||
replaceOption: function(s, tabName, optionClass, optionName, optionTitle, optionDescription) {
|
||||
var o = s.getOption(optionName);
|
||||
|
||||
if (o) {
|
||||
if (o.tab) {
|
||||
s.tabs[o.tab].children = s.tabs[o.tab].children.filter(function(opt) {
|
||||
return opt.option != optionName;
|
||||
});
|
||||
}
|
||||
|
||||
s.children = s.children.filter(function(opt) {
|
||||
return opt.option != optionName;
|
||||
});
|
||||
}
|
||||
|
||||
return s.taboption(tabName, optionClass, optionName, optionTitle, optionDescription);
|
||||
},
|
||||
|
||||
addDeviceOptions: function(s, dev, isNew) {
|
||||
var parent_dev = dev ? dev.getParent() : null,
|
||||
o, ss;
|
||||
|
||||
s.tab('devgeneral', _('General device options'));
|
||||
s.tab('devadvanced', _('Advanced device options'));
|
||||
s.tab('brport', _('Bridge port specific options'));
|
||||
s.tab('bridgevlan', _('Bridge VLAN filtering'));
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.ListValue, 'type', _('Device type'));
|
||||
o.readonly = !isNew;
|
||||
o.value('', _('Network device'));
|
||||
o.value('bridge', _('Bridge device'));
|
||||
o.value('8021q', _('VLAN (802.1q)'));
|
||||
o.value('8021ad', _('VLAN (802.1ad)'));
|
||||
o.value('macvlan', _('MAC VLAN'));
|
||||
o.value('veth', _('Virtual Ethernet'));
|
||||
o.validate = function(section_id, value) {
|
||||
if (value == 'bridge' || value == 'veth')
|
||||
updatePlaceholders(this.section.getOption('name_complex'), section_id);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', widgets.DeviceSelect, 'name_simple', _('Existing device'));
|
||||
o.readonly = !isNew;
|
||||
o.rmempty = false;
|
||||
o.noaliases = true;
|
||||
o.default = (dev ? dev.getName() : '');
|
||||
o.ucioption = 'name';
|
||||
o.filter = function(section_id, value) {
|
||||
var dev = network.instantiateDevice(value);
|
||||
return !deviceSectionExists(section_id, value) && (dev.getType() != 'wifi' || dev.isUp());
|
||||
};
|
||||
o.validate = function(section_id, value) {
|
||||
updatePlaceholders(this, section_id);
|
||||
|
||||
return deviceSectionExists(section_id, value)
|
||||
? _('A configuration for the device "%s" already exists').format(value) : true;
|
||||
};
|
||||
o.onchange = function(ev, section_id, values) {
|
||||
updatePlaceholders(this, section_id);
|
||||
};
|
||||
o.depends('type', '');
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', widgets.DeviceSelect, 'ifname_single', _('Base device'));
|
||||
o.readonly = !isNew;
|
||||
o.rmempty = false;
|
||||
o.noaliases = true;
|
||||
o.default = (dev ? dev.getName() : '').match(/^.+\.\d+$/) ? dev.getName().replace(/\.\d+$/, '') : '';
|
||||
o.ucioption = 'ifname';
|
||||
o.filter = function(section_id, value) {
|
||||
var dev = network.instantiateDevice(value);
|
||||
return (dev.getType() != 'wifi' || dev.isUp());
|
||||
};
|
||||
o.validate = function(section_id, value) {
|
||||
updatePlaceholders(this, section_id);
|
||||
|
||||
if (isNew) {
|
||||
var type = this.section.formvalue(section_id, 'type'),
|
||||
name = this.section.getUIElement(section_id, 'name_complex');
|
||||
|
||||
if (type == 'macvlan' && value && name && !name.isChanged()) {
|
||||
var i = 0;
|
||||
|
||||
while (deviceSectionExists(section_id, '%smac%d'.format(value, i)))
|
||||
i++;
|
||||
|
||||
name.setValue('%smac%d'.format(value, i));
|
||||
name.triggerValidation();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
o.onchange = function(ev, section_id, values) {
|
||||
updatePlaceholders(this, section_id);
|
||||
};
|
||||
o.depends('type', '8021q');
|
||||
o.depends('type', '8021ad');
|
||||
o.depends('type', 'macvlan');
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Value, 'vid', _('VLAN ID'));
|
||||
o.readonly = !isNew;
|
||||
o.datatype = 'range(1, 4094)';
|
||||
o.rmempty = false;
|
||||
o.default = (dev ? dev.getName() : '').match(/^.+\.\d+$/) ? dev.getName().replace(/^.+\./, '') : '';
|
||||
o.validate = function(section_id, value) {
|
||||
var base = this.section.formvalue(section_id, 'ifname_single'),
|
||||
vid = this.section.formvalue(section_id, 'vid'),
|
||||
name = this.section.getUIElement(section_id, 'name_complex');
|
||||
|
||||
if (base && vid && name && !name.isChanged()) {
|
||||
name.setValue('%s.%d'.format(base, vid));
|
||||
name.triggerValidation();
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
o.depends('type', '8021q');
|
||||
o.depends('type', '8021ad');
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.ListValue, 'mode', _('Mode'));
|
||||
o.value('vepa', _('VEPA (Virtual Ethernet Port Aggregator)', 'MACVLAN mode'));
|
||||
o.value('private', _('Private (Prevent communication between MAC VLANs)', 'MACVLAN mode'));
|
||||
o.value('bridge', _('Bridge (Support direct communication between MAC VLANs)', 'MACVLAN mode'));
|
||||
o.value('passthru', _('Pass-through (Mirror physical device to single MAC VLAN)', 'MACVLAN mode'));
|
||||
o.depends('type', 'macvlan');
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Value, 'name_complex', _('Device name'));
|
||||
o.rmempty = false;
|
||||
o.datatype = 'maxlength(15)';
|
||||
o.readonly = !isNew;
|
||||
o.ucioption = 'name';
|
||||
o.validate = function(section_id, value) {
|
||||
var dev = network.instantiateDevice(value);
|
||||
|
||||
if (deviceSectionExists(section_id, value) || (isNew && (dev.dev || {}).idx))
|
||||
return _('The device name "%s" is already taken').format(value);
|
||||
|
||||
return true;
|
||||
};
|
||||
o.depends({ type: '', '!reverse': true });
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.DynamicList, 'ingress_qos_mapping', _('Ingress QoS mapping'), _('Defines a mapping of VLAN header priority to the Linux internal packet priority on incoming frames'));
|
||||
o.rmempty = true;
|
||||
o.validate = validateQoSMap;
|
||||
o.depends('type', '8021q');
|
||||
o.depends('type', '8021ad');
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.DynamicList, 'egress_qos_mapping', _('Egress QoS mapping'), _('Defines a mapping of Linux internal packet priority to VLAN header priority but for outgoing frames'));
|
||||
o.rmempty = true;
|
||||
o.validate = validateQoSMap;
|
||||
o.depends('type', '8021q');
|
||||
o.depends('type', '8021ad');
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', widgets.DeviceSelect, 'ifname_multi', _('Bridge ports'));
|
||||
o.size = 10;
|
||||
o.rmempty = true;
|
||||
o.multiple = true;
|
||||
o.noaliases = true;
|
||||
o.nobridges = true;
|
||||
o.ucioption = 'ports';
|
||||
o.default = L.toArray(dev ? dev.getPorts() : null).filter(function(p) { return p.getType() != 'wifi' }).map(function(p) { return p.getName() });
|
||||
o.filter = function(section_id, device_name) {
|
||||
var bridge_name = uci.get('network', section_id, 'name'),
|
||||
choice_dev = network.instantiateDevice(device_name),
|
||||
parent_dev = choice_dev.getParent();
|
||||
|
||||
/* only show wifi networks which are already present in "option ifname" */
|
||||
if (choice_dev.getType() == 'wifi') {
|
||||
var ifnames = L.toArray(uci.get('network', section_id, 'ports'));
|
||||
|
||||
for (var i = 0; i < ifnames.length; i++)
|
||||
if (ifnames[i] == device_name)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return (!parent_dev || parent_dev.getName() != bridge_name);
|
||||
};
|
||||
o.description = _('Specifies the wired ports to attach to this bridge. In order to attach wireless networks, choose the associated interface as network in the wireless settings.')
|
||||
o.onchange = function(ev, section_id, values) {
|
||||
ss.updatePorts(values);
|
||||
|
||||
return ss.parse().then(function() {
|
||||
ss.redraw();
|
||||
});
|
||||
};
|
||||
o.depends('type', 'bridge');
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Flag, 'bridge_empty', _('Bring up empty bridge'), _('Bring up the bridge interface even if no ports are attached'));
|
||||
o.default = o.disabled;
|
||||
o.depends('type', 'bridge');
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'priority', _('Priority'));
|
||||
o.placeholder = '32767';
|
||||
o.datatype = 'range(0, 65535)';
|
||||
o.depends('type', 'bridge');
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'ageing_time', _('Ageing time'), _('Timeout in seconds for learned MAC addresses in the forwarding database'));
|
||||
o.placeholder = '30';
|
||||
o.datatype = 'uinteger';
|
||||
o.depends('type', 'bridge');
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Flag, 'stp', _('Enable <abbr title="Spanning Tree Protocol">STP</abbr>'), _('Enables the Spanning Tree Protocol on this bridge'));
|
||||
o.default = o.disabled;
|
||||
o.depends('type', 'bridge');
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'hello_time', _('Hello interval'), _('Interval in seconds for STP hello packets'));
|
||||
o.placeholder = '2';
|
||||
o.datatype = 'range(1, 10)';
|
||||
o.depends({ type: 'bridge', stp: '1' });
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'forward_delay', _('Forward delay'), _('Time in seconds to spend in listening and learning states'));
|
||||
o.placeholder = '15';
|
||||
o.datatype = 'range(2, 30)';
|
||||
o.depends({ type: 'bridge', stp: '1' });
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'max_age', _('Maximum age'), _('Timeout in seconds until topology updates on link loss'));
|
||||
o.placeholder = '20';
|
||||
o.datatype = 'range(6, 40)';
|
||||
o.depends({ type: 'bridge', stp: '1' });
|
||||
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Flag, 'igmp_snooping', _('Enable <abbr title="Internet Group Management Protocol">IGMP</abbr> snooping'), _('Enables IGMP snooping on this bridge'));
|
||||
o.default = o.disabled;
|
||||
o.depends('type', 'bridge');
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'hash_max', _('Maximum snooping table size'));
|
||||
o.placeholder = '512';
|
||||
o.datatype = 'uinteger';
|
||||
o.depends({ type: 'bridge', igmp_snooping: '1' });
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Flag, 'multicast_querier', _('Enable multicast querier'));
|
||||
o.defaults = { '1': [{'igmp_snooping': '1'}], '0': [{'igmp_snooping': '0'}] };
|
||||
o.depends('type', 'bridge');
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'robustness', _('Robustness'), _('The robustness value allows tuning for the expected packet loss on the network. If a network is expected to be lossy, the robustness value may be increased. IGMP is robust to (Robustness-1) packet losses'));
|
||||
o.placeholder = '2';
|
||||
o.datatype = 'min(1)';
|
||||
o.depends({ type: 'bridge', multicast_querier: '1' });
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'query_interval', _('Query interval'), _('Interval in centiseconds between multicast general queries. By varying the value, an administrator may tune the number of IGMP messages on the subnet; larger values cause IGMP Queries to be sent less often'));
|
||||
o.placeholder = '12500';
|
||||
o.datatype = 'uinteger';
|
||||
o.depends({ type: 'bridge', multicast_querier: '1' });
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'query_response_interval', _('Query response interval'), _('The max response time in centiseconds inserted into the periodic general queries. By varying the value, an administrator may tune the burstiness of IGMP messages on the subnet; larger values make the traffic less bursty, as host responses are spread out over a larger interval'));
|
||||
o.placeholder = '1000';
|
||||
o.datatype = 'uinteger';
|
||||
o.validate = function(section_id, value) {
|
||||
var qiopt = L.toArray(this.map.lookupOption('query_interval', section_id))[0],
|
||||
qival = qiopt ? (qiopt.formvalue(section_id) || qiopt.placeholder) : '';
|
||||
|
||||
if (value != '' && qival != '' && +value >= +qival)
|
||||
return _('The query response interval must be lower than the query interval value');
|
||||
|
||||
return true;
|
||||
};
|
||||
o.depends({ type: 'bridge', multicast_querier: '1' });
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'last_member_interval', _('Last member interval'), _('The max response time in centiseconds inserted into group-specific queries sent in response to leave group messages. It is also the amount of time between group-specific query messages. This value may be tuned to modify the "leave latency" of the network. A reduced value results in reduced time to detect the loss of the last member of a group'));
|
||||
o.placeholder = '100';
|
||||
o.datatype = 'uinteger';
|
||||
o.depends({ type: 'bridge', multicast_querier: '1' });
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Value, 'mtu', _('MTU'));
|
||||
o.datatype = 'range(576, 9200)';
|
||||
o.validate = function(section_id, value) {
|
||||
var parent_mtu = (dev && dev.getType() == 'vlan') ? (parent_dev ? parent_dev.getMTU() : null) : null;
|
||||
|
||||
if (parent_mtu !== null && +value > parent_mtu)
|
||||
return _('The MTU must not exceed the parent device MTU of %d bytes').format(parent_mtu);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Value, 'macaddr', _('MAC address'));
|
||||
o.datatype = 'macaddr';
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Value, 'peer_name', _('Peer device name'));
|
||||
o.rmempty = true;
|
||||
o.datatype = 'maxlength(15)';
|
||||
o.depends('type', 'veth');
|
||||
o.load = function(section_id) {
|
||||
var sections = uci.sections('network', 'device'),
|
||||
idx = 0;
|
||||
|
||||
for (var i = 0; i < sections.length; i++)
|
||||
if (sections[i]['.name'] == section_id)
|
||||
break;
|
||||
else if (sections[i].type == 'veth')
|
||||
idx++;
|
||||
|
||||
this.placeholder = 'veth%d'.format(idx);
|
||||
|
||||
return form.Value.prototype.load.apply(this, arguments);
|
||||
};
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Value, 'peer_macaddr', _('Peer MAC address'));
|
||||
o.rmempty = true;
|
||||
o.datatype = 'macaddr';
|
||||
o.depends('type', 'veth');
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Value, 'txqueuelen', _('TX queue length'));
|
||||
o.placeholder = dev ? dev._devstate('qlen') : '';
|
||||
o.datatype = 'uinteger';
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Flag, 'promisc', _('Enable promiscuous mode'));
|
||||
o.default = o.disabled;
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.ListValue, 'rpfilter', _('Reverse path filter'));
|
||||
o.default = '';
|
||||
o.value('', _('disabled'));
|
||||
o.value('loose', _('Loose filtering'));
|
||||
o.value('strict', _('Strict filtering'));
|
||||
o.cfgvalue = function(section_id) {
|
||||
var val = form.ListValue.prototype.cfgvalue.apply(this, [section_id]);
|
||||
|
||||
switch (val || '') {
|
||||
case 'loose':
|
||||
case '1':
|
||||
return 'loose';
|
||||
|
||||
case 'strict':
|
||||
case '2':
|
||||
return 'strict';
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Flag, 'acceptlocal', _('Accept local'), _('Accept packets with local source addresses'));
|
||||
o.default = o.disabled;
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Flag, 'sendredirects', _('Send ICMP redirects'));
|
||||
o.default = o.enabled;
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'neighreachabletime', _('Neighbour cache validity'), _('Time in milliseconds'));
|
||||
o.placeholder = '30000';
|
||||
o.datatype = 'uinteger';
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'neighgcstaletime', _('Stale neighbour cache timeout'), _('Timeout in seconds'));
|
||||
o.placeholder = '60';
|
||||
o.datatype = 'uinteger';
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Value, 'neighlocktime', _('Minimum ARP validity time'), _('Minimum required time in seconds before an ARP entry may be replaced. Prevents ARP cache thrashing.'));
|
||||
o.placeholder = '0';
|
||||
o.datatype = 'uinteger';
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Flag, 'ipv6', _('Enable IPv6'));
|
||||
o.migrate = false;
|
||||
o.default = o.enabled;
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Value, 'mtu6', _('IPv6 MTU'));
|
||||
o.datatype = 'max(9200)';
|
||||
o.depends('ipv6', '1');
|
||||
|
||||
o = this.replaceOption(s, 'devgeneral', form.Value, 'dadtransmits', _('DAD transmits'), _('Amount of Duplicate Address Detection probes to send'));
|
||||
o.placeholder = '1';
|
||||
o.datatype = 'uinteger';
|
||||
o.depends('ipv6', '1');
|
||||
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.Flag, 'multicast', _('Enable multicast support'));
|
||||
o.default = o.enabled;
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.ListValue, 'igmpversion', _('Force IGMP version'));
|
||||
o.value('', _('No enforcement'));
|
||||
o.value('1', _('Enforce IGMPv1'));
|
||||
o.value('2', _('Enforce IGMPv2'));
|
||||
o.value('3', _('Enforce IGMPv3'));
|
||||
o.depends('multicast', '1');
|
||||
|
||||
o = this.replaceOption(s, 'devadvanced', form.ListValue, 'mldversion', _('Force MLD version'));
|
||||
o.value('', _('No enforcement'));
|
||||
o.value('1', _('Enforce MLD version 1'));
|
||||
o.value('2', _('Enforce MLD version 2'));
|
||||
o.depends('multicast', '1');
|
||||
|
||||
if (isBridgePort(dev)) {
|
||||
o = this.replaceOption(s, 'brport', form.Flag, 'learning', _('Enable MAC address learning'));
|
||||
o.default = o.enabled;
|
||||
|
||||
o = this.replaceOption(s, 'brport', form.Flag, 'unicast_flood', _('Enable unicast flooding'));
|
||||
o.default = o.enabled;
|
||||
|
||||
o = this.replaceOption(s, 'brport', form.Flag, 'isolated', _('Port isolation'), _('Only allow communication with non-isolated bridge ports when enabled'));
|
||||
o.default = o.disabled;
|
||||
|
||||
o = this.replaceOption(s, 'brport', form.ListValue, 'multicast_router', _('Multicast routing'));
|
||||
o.value('', _('Never'));
|
||||
o.value('1', _('Learn'));
|
||||
o.value('2', _('Always'));
|
||||
o.depends('multicast', '1');
|
||||
|
||||
o = this.replaceOption(s, 'brport', form.Flag, 'multicast_to_unicast', _('Multicast to unicast'), _('Forward multicast packets as unicast packets on this device.'));
|
||||
o.default = o.disabled;
|
||||
o.depends('multicast', '1');
|
||||
|
||||
o = this.replaceOption(s, 'brport', form.Flag, 'multicast_fast_leave', _('Enable multicast fast leave'));
|
||||
o.default = o.disabled;
|
||||
o.depends('multicast', '1');
|
||||
}
|
||||
|
||||
o = this.replaceOption(s, 'bridgevlan', form.Flag, 'vlan_filtering', _('Enable VLAN filtering'));
|
||||
o.depends('type', 'bridge');
|
||||
o.updateDefaultValue = function(section_id) {
|
||||
var device = uci.get('network', s.section, 'name'),
|
||||
uielem = this.getUIElement(section_id),
|
||||
has_vlans = false;
|
||||
|
||||
uci.sections('network', 'bridge-vlan', function(bvs) {
|
||||
has_vlans = has_vlans || (bvs.device == device);
|
||||
});
|
||||
|
||||
this.default = has_vlans ? this.enabled : this.disabled;
|
||||
|
||||
if (uielem && !uielem.isChanged())
|
||||
uielem.setValue(this.default);
|
||||
};
|
||||
|
||||
o = this.replaceOption(s, 'bridgevlan', form.SectionValue, 'bridge-vlan', form.TableSection, 'bridge-vlan');
|
||||
o.depends('type', 'bridge');
|
||||
|
||||
ss = o.subsection;
|
||||
ss.addremove = true;
|
||||
ss.anonymous = true;
|
||||
|
||||
ss.renderHeaderRows = function(/* ... */) {
|
||||
var node = form.TableSection.prototype.renderHeaderRows.apply(this, arguments);
|
||||
|
||||
node.querySelectorAll('.th').forEach(function(th) {
|
||||
th.classList.add('left');
|
||||
th.classList.add('middle');
|
||||
});
|
||||
|
||||
return node;
|
||||
};
|
||||
|
||||
ss.filter = function(section_id) {
|
||||
var devname = uci.get('network', s.section, 'name');
|
||||
return (uci.get('network', section_id, 'device') == devname);
|
||||
};
|
||||
|
||||
ss.render = function(/* ... */) {
|
||||
return form.TableSection.prototype.render.apply(this, arguments).then(L.bind(function(node) {
|
||||
node.style.overflow = 'auto hidden';
|
||||
node.style.paddingTop = '1em';
|
||||
|
||||
if (this.node)
|
||||
this.node.parentNode.replaceChild(node, this.node);
|
||||
|
||||
this.node = node;
|
||||
|
||||
return node;
|
||||
}, this));
|
||||
};
|
||||
|
||||
ss.redraw = function() {
|
||||
return this.load().then(L.bind(this.render, this));
|
||||
};
|
||||
|
||||
ss.updatePorts = function(ports) {
|
||||
var devices = ports.map(function(port) {
|
||||
return network.instantiateDevice(port)
|
||||
}).filter(function(dev) {
|
||||
return dev.getType() != 'wifi' || dev.isUp();
|
||||
});
|
||||
|
||||
this.children = this.children.filter(function(opt) { return !opt.option.match(/^port_/) });
|
||||
|
||||
for (var i = 0; i < devices.length; i++) {
|
||||
o = ss.option(cbiTagValue, 'port_%s'.format(sfh(devices[i].getName())), renderDevBadge(devices[i]), renderPortStatus(devices[i]));
|
||||
o.port = devices[i].getName();
|
||||
}
|
||||
|
||||
var section_ids = this.cfgsections(),
|
||||
device_names = devices.reduce(function(names, dev) { names[dev.getName()] = true; return names }, {});
|
||||
|
||||
for (var i = 0; i < section_ids.length; i++) {
|
||||
var old_spec = L.toArray(uci.get('network', section_ids[i], 'ports')),
|
||||
new_spec = old_spec.filter(function(spec) { return device_names[spec.replace(/:[ut*]+$/, '')] });
|
||||
|
||||
if (old_spec.length != new_spec.length)
|
||||
uci.set('network', section_ids[i], 'ports', new_spec.length ? new_spec : null);
|
||||
}
|
||||
};
|
||||
|
||||
ss.handleAdd = function(ev) {
|
||||
return s.parse().then(L.bind(function() {
|
||||
var device = uci.get('network', s.section, 'name'),
|
||||
section_ids = this.cfgsections(),
|
||||
section_id = null,
|
||||
max_vlan_id = 0;
|
||||
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < section_ids.length; i++) {
|
||||
var vid = +uci.get('network', section_ids[i], 'vlan');
|
||||
|
||||
if (vid > max_vlan_id)
|
||||
max_vlan_id = vid;
|
||||
}
|
||||
|
||||
section_id = uci.add('network', 'bridge-vlan');
|
||||
uci.set('network', section_id, 'device', device);
|
||||
uci.set('network', section_id, 'vlan', max_vlan_id + 1);
|
||||
|
||||
s.children.forEach(function(opt) {
|
||||
switch (opt.option) {
|
||||
case 'type':
|
||||
case 'name_complex':
|
||||
var input = opt.map.findElement('id', 'widget.%s'.format(opt.cbid(s.section)));
|
||||
if (input)
|
||||
input.disabled = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
s.getOption('vlan_filtering').updateDefaultValue(s.section);
|
||||
|
||||
s.map.addedVLANs = s.map.addedVLANs || [];
|
||||
s.map.addedVLANs.push(section_id);
|
||||
|
||||
return this.redraw();
|
||||
}, this));
|
||||
};
|
||||
|
||||
o = ss.option(form.Value, 'vlan', _('VLAN ID'));
|
||||
o.datatype = 'range(1, 4094)';
|
||||
|
||||
o.renderWidget = function(/* ... */) {
|
||||
var node = form.Value.prototype.renderWidget.apply(this, arguments);
|
||||
|
||||
node.style.width = '5em';
|
||||
|
||||
return node;
|
||||
};
|
||||
|
||||
o.validate = function(section_id, value) {
|
||||
var section_ids = this.section.cfgsections();
|
||||
|
||||
for (var i = 0; i < section_ids.length; i++) {
|
||||
if (section_ids[i] == section_id)
|
||||
continue;
|
||||
|
||||
if (uci.get('network', section_ids[i], 'vlan') == value)
|
||||
return _('The VLAN ID must be unique');
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
o = ss.option(form.Flag, 'local', _('Local'));
|
||||
o.default = o.enabled;
|
||||
|
||||
var ports = [];
|
||||
|
||||
var seen_ports = {};
|
||||
|
||||
L.toArray(uci.get('network', s.section, 'ports')).forEach(function(port) {
|
||||
seen_ports[port] = true;
|
||||
});
|
||||
|
||||
uci.sections('network', 'bridge-vlan', function(bvs) {
|
||||
if (uci.get('network', s.section, 'name') != bvs.device)
|
||||
return;
|
||||
|
||||
L.toArray(bvs.ports).forEach(function(portspec) {
|
||||
var m = portspec.match(/^([^:]+)(?::[ut*]+)?$/);
|
||||
|
||||
if (m)
|
||||
seen_ports[m[1]] = true;
|
||||
});
|
||||
});
|
||||
|
||||
for (var port_name in seen_ports)
|
||||
ports.push(port_name);
|
||||
|
||||
ports.sort(function(a, b) {
|
||||
var m1 = a.match(/^(.+?)([0-9]*)$/),
|
||||
m2 = b.match(/^(.+?)([0-9]*)$/);
|
||||
|
||||
if (m1[1] < m2[1])
|
||||
return -1;
|
||||
else if (m1[1] > m2[1])
|
||||
return 1;
|
||||
else
|
||||
return +(m1[2] || 0) - +(m2[2] || 0);
|
||||
});
|
||||
|
||||
ss.updatePorts(ports);
|
||||
},
|
||||
|
||||
updateDevBadge: updateDevBadge,
|
||||
updatePortStatus: updatePortStatus
|
||||
});
|
|
@ -34,8 +34,8 @@ CBILeaseStatus = form.DummyValue.extend({
|
|||
E('table', { 'id': 'lease_status_table', 'class': 'table' }, [
|
||||
E('tr', { 'class': 'tr table-titles' }, [
|
||||
E('th', { 'class': 'th' }, _('Hostname')),
|
||||
E('th', { 'class': 'th' }, _('IPv4-Address')),
|
||||
E('th', { 'class': 'th' }, _('MAC-Address')),
|
||||
E('th', { 'class': 'th' }, _('IPv4 address')),
|
||||
E('th', { 'class': 'th' }, _('MAC address')),
|
||||
E('th', { 'class': 'th' }, _('Lease time remaining'))
|
||||
]),
|
||||
E('tr', { 'class': 'tr placeholder' }, [
|
||||
|
@ -53,7 +53,7 @@ CBILease6Status = form.DummyValue.extend({
|
|||
E('table', { 'id': 'lease6_status_table', 'class': 'table' }, [
|
||||
E('tr', { 'class': 'tr table-titles' }, [
|
||||
E('th', { 'class': 'th' }, _('Host')),
|
||||
E('th', { 'class': 'th' }, _('IPv6-Address')),
|
||||
E('th', { 'class': 'th' }, _('IPv6 address')),
|
||||
E('th', { 'class': 'th' }, _('DUID')),
|
||||
E('th', { 'class': 'th' }, _('Lease time remaining'))
|
||||
]),
|
||||
|
@ -279,7 +279,8 @@ return view.extend({
|
|||
|
||||
o.optional = true;
|
||||
o.placeholder = '/example.org/10.1.2.3';
|
||||
// o.validate = validateServerSpec;
|
||||
o.validate = validateServerSpec;
|
||||
|
||||
|
||||
o = s.taboption('general', form.DynamicList, 'address', _('Addresses'),
|
||||
_('List of domains to force to an IP address.'));
|
||||
|
@ -287,6 +288,7 @@ return view.extend({
|
|||
o.optional = true;
|
||||
o.placeholder = '/router.local/192.168.0.1';
|
||||
|
||||
|
||||
o = s.taboption('general', form.Flag, 'rebind_protection',
|
||||
_('Rebind protection'),
|
||||
_('Discard upstream RFC1918 responses'));
|
||||
|
@ -407,7 +409,7 @@ return view.extend({
|
|||
|
||||
o = s.taboption('leases', form.SectionValue, '__leases__', form.GridSection, 'host', null,
|
||||
_('Static leases are used to assign fixed IP addresses and symbolic hostnames to DHCP clients. They are also required for non-dynamic interface configurations where only hosts with a corresponding lease are served.') + '<br />' +
|
||||
_('Use the <em>Add</em> Button to add a new lease entry. The <em>MAC-Address</em> identifies the host, the <em>IPv4-Address</em> specifies the fixed address to use, and the <em>Hostname</em> is assigned as a symbolic name to the requesting host. The optional <em>Lease time</em> can be used to set non-standard host-specific lease time, e.g. 12h, 3d or infinite.'));
|
||||
_('Use the <em>Add</em> Button to add a new lease entry. The <em>MAC address</em> identifies the host, the <em>IPv4 address</em> specifies the fixed address to use, and the <em>Hostname</em> is assigned as a symbolic name to the requesting host. The optional <em>Lease time</em> can be used to set non-standard host-specific lease time, e.g. 12h, 3d or infinite.'));
|
||||
|
||||
ss = o.subsection;
|
||||
|
||||
|
@ -448,7 +450,11 @@ return view.extend({
|
|||
|
||||
node.addEventListener('cbi-dropdown-change', L.bind(function(ipopt, section_id, ev) {
|
||||
var mac = ev.detail.value.value;
|
||||
if (mac == null || mac == '' || !hosts[mac] || !hosts[mac].ipv4)
|
||||
if (mac == null || mac == '' || !hosts[mac])
|
||||
return;
|
||||
|
||||
var iphint = L.toArray(hosts[mac].ipaddrs || hosts[mac].ipv4)[0];
|
||||
if (iphint == null)
|
||||
return;
|
||||
|
||||
var ip = ipopt.formvalue(section_id);
|
||||
|
@ -457,16 +463,35 @@ return view.extend({
|
|||
|
||||
var node = ipopt.map.findElement('id', ipopt.cbid(section_id));
|
||||
if (node)
|
||||
dom.callClassMethod(node, 'setValue', hosts[mac].ipv4);
|
||||
dom.callClassMethod(node, 'setValue', iphint);
|
||||
}, this, ipopt, section_id));
|
||||
|
||||
return node;
|
||||
};
|
||||
Object.keys(hosts).forEach(function(mac) {
|
||||
var hint = hosts[mac].name || hosts[mac].ipv4;
|
||||
var hint = hosts[mac].name || L.toArray(hosts[mac].ipaddrs || hosts[mac].ipv4)[0];
|
||||
so.value(mac, hint ? '%s (%s)'.format(mac, hint) : mac);
|
||||
});
|
||||
|
||||
so.write = function(section, value) {
|
||||
var ip = this.map.lookupOption('ip', section)[0].formvalue(section);
|
||||
var hosts = uci.sections('dhcp', 'host');
|
||||
var section_removed = false;
|
||||
|
||||
for (var i = 0; i < hosts.length; i++) {
|
||||
if (ip == hosts[i].ip) {
|
||||
uci.set('dhcp', hosts[i]['.name'], 'mac', [hosts[i].mac, value].join(' '));
|
||||
uci.remove('dhcp', section);
|
||||
section_removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!section_removed) {
|
||||
uci.set('dhcp', section, 'mac', value);
|
||||
}
|
||||
}
|
||||
|
||||
so = ss.option(form.Value, 'ip', _('<abbr title="Internet Protocol Version 4">IPv4</abbr>-Address'));
|
||||
so.datatype = 'or(ip4addr,"ignore")';
|
||||
so.validate = function(section, value) {
|
||||
|
@ -480,19 +505,21 @@ return view.extend({
|
|||
|
||||
return true;
|
||||
};
|
||||
|
||||
var ipaddrs = {};
|
||||
|
||||
Object.keys(hosts).forEach(function(mac) {
|
||||
if (hosts[mac].ipv4) {
|
||||
var hint = hosts[mac].name;
|
||||
so.value(hosts[mac].ipv4, hint ? '%s (%s)'.format(hosts[mac].ipv4, hint) : hosts[mac].ipv4);
|
||||
}
|
||||
var addrs = L.toArray(hosts[mac].ipaddrs || hosts[mac].ipv4);
|
||||
|
||||
for (var i = 0; i < addrs.length; i++)
|
||||
ipaddrs[addrs[i]] = hosts[mac].name;
|
||||
});
|
||||
|
||||
so = ss.option(form.Value, 'gw', _('Gateway'));
|
||||
so.datatype = 'or(ip4addr,"ignore")';
|
||||
so.rmempty = true;
|
||||
L.sortedKeys(ipaddrs, null, 'addr').forEach(function(ipv4) {
|
||||
so.value(ipv4, ipaddrs[ipv4] ? '%s (%s)'.format(ipv4, ipaddrs[ipv4]) : ipv4);
|
||||
});
|
||||
|
||||
so = ss.option(form.Value, 'leasetime', _('Lease time'), _('The lease time is in minutes (mini 2m), hours (eg 1h) or "infinite"'));
|
||||
so.placeholder = '12h';
|
||||
so = ss.option(form.Value, 'leasetime', _('Lease time'));
|
||||
so.rmempty = true;
|
||||
|
||||
so = ss.option(form.Value, 'duid', _('<abbr title="The DHCP Unique Identifier">DUID</abbr>'));
|
||||
|
@ -547,7 +574,7 @@ return view.extend({
|
|||
exp = '%t'.format(lease.expires);
|
||||
|
||||
var hint = lease.macaddr ? hosts[lease.macaddr] : null,
|
||||
name = hint ? (hint.name || hint.ipv4 || hint.ipv6) : null,
|
||||
name = hint ? (hint.name || L.toArray(hint.ipaddrs || hint.ipv4)[0] || L.toArray(hint.ip6addrs || hint.ipv6)[0]) : null,
|
||||
host = null;
|
||||
|
||||
if (name && lease.hostname && lease.hostname != name && lease.ip6addr != name)
|
||||
|
|
|
@ -31,11 +31,18 @@ return view.extend({
|
|||
o = s.option(form.Value, 'ip', _('IP address'));
|
||||
o.datatype = 'ipaddr';
|
||||
o.rmempty = true;
|
||||
L.sortedKeys(hosts, 'ipv4', 'addr').forEach(function(mac) {
|
||||
o.value(hosts[mac].ipv4, '%s (%s)'.format(
|
||||
hosts[mac].ipv4,
|
||||
hosts[mac].name || mac
|
||||
));
|
||||
|
||||
var ipaddrs = {};
|
||||
|
||||
Object.keys(hosts).forEach(function(mac) {
|
||||
var addrs = L.toArray(hosts[mac].ipaddrs || hosts[mac].ipv4);
|
||||
|
||||
for (var i = 0; i < addrs.length; i++)
|
||||
ipaddrs[addrs[i]] = hosts[mac].name || mac;
|
||||
});
|
||||
|
||||
L.sortedKeys(ipaddrs, null, 'addr').forEach(function(ipv4) {
|
||||
o.value(ipv4, '%s (%s)'.format(ipv4, ipaddrs[ipv4]));
|
||||
});
|
||||
|
||||
return m.render();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -20,6 +20,7 @@ return view.extend({
|
|||
s.anonymous = true;
|
||||
s.addremove = true;
|
||||
s.sortable = true;
|
||||
s.nodescriptions = true;
|
||||
|
||||
s.tab('general', _('General Settings'));
|
||||
s.tab('advanced', _('Advanced Settings'));
|
||||
|
@ -28,6 +29,10 @@ return view.extend({
|
|||
o.rmempty = false;
|
||||
o.nocreate = true;
|
||||
|
||||
o = s.taboption('general', form.Flag, 'disabled', _('Disable'), _('Disable this route'));
|
||||
o.rmempty = true;
|
||||
o.default = o.disabled;
|
||||
|
||||
o = s.taboption('general', form.Value, 'target', _('Target'), (i == 4) ? _('Host-<abbr title="Internet Protocol Address">IP</abbr> or Network') : _('<abbr title="Internet Protocol Version 6">IPv6</abbr>-Address or Network (CIDR)'));
|
||||
o.datatype = (i == 4) ? 'ip4addr' : 'ip6addr';
|
||||
o.rmempty = false;
|
||||
|
|
|
@ -199,7 +199,9 @@ function format_wifirate(rate) {
|
|||
var s = '%.1f\xa0%s, %d\xa0%s'.format(rate.rate / 1000, _('Mbit/s'), rate.mhz, _('MHz')),
|
||||
ht = rate.ht, vht = rate.vht,
|
||||
mhz = rate.mhz, nss = rate.nss,
|
||||
mcs = rate.mcs, sgi = rate.short_gi;
|
||||
mcs = rate.mcs, sgi = rate.short_gi,
|
||||
he = rate.he, he_gi = rate.he_gi,
|
||||
he_dcm = rate.he_dcm;
|
||||
|
||||
if (ht || vht) {
|
||||
if (vht) s += ', VHT-MCS\xa0%d'.format(mcs);
|
||||
|
@ -208,6 +210,13 @@ function format_wifirate(rate) {
|
|||
if (sgi) s += ', ' + _('Short GI').replace(/ /g, '\xa0');
|
||||
}
|
||||
|
||||
if (he) {
|
||||
s += ', HE-MCS\xa0%d'.format(mcs);
|
||||
if (nss) s += ', HE-NSS\xa0%d'.format(nss);
|
||||
if (he_gi) s += ', HE-GI\xa0%d'.format(he_gi);
|
||||
if (he_dcm) s += ', HE-DCM\xa0%d'.format(he_dcm);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -303,16 +312,32 @@ var CBIWifiFrequencyValue = form.Value.extend({
|
|||
this.callFrequencyList(section_id)
|
||||
]).then(L.bind(function(data) {
|
||||
this.channels = {
|
||||
'11g': L.hasSystemFeature('hostapd', 'acs') ? [ 'auto', 'auto', true ] : [],
|
||||
'11a': L.hasSystemFeature('hostapd', 'acs') ? [ 'auto', 'auto', true ] : []
|
||||
'2g': L.hasSystemFeature('hostapd', 'acs') ? [ 'auto', 'auto', true ] : [],
|
||||
'5g': L.hasSystemFeature('hostapd', 'acs') ? [ 'auto', 'auto', true ] : [],
|
||||
'6g': [],
|
||||
'60g': []
|
||||
};
|
||||
|
||||
for (var i = 0; i < data[1].length; i++)
|
||||
this.channels[(data[1][i].mhz > 2484) ? '11a' : '11g'].push(
|
||||
for (var i = 0; i < data[1].length; i++) {
|
||||
var band;
|
||||
|
||||
if (data[1][i].mhz >= 2412 && data[1][i].mhz <= 2484)
|
||||
band = '2g';
|
||||
else if (data[1][i].mhz >= 5160 && data[1][i].mhz <= 5885)
|
||||
band = '5g';
|
||||
else if (data[1][i].mhz >= 5925 && data[1][i].mhz <= 7125)
|
||||
band = '6g';
|
||||
else if (data[1][i].mhz >= 58329 && data[1][i].mhz <= 69120)
|
||||
band = '60g';
|
||||
else
|
||||
continue;
|
||||
|
||||
this.channels[band].push(
|
||||
data[1][i].channel,
|
||||
'%d (%d Mhz)'.format(data[1][i].channel, data[1][i].mhz),
|
||||
!data[1][i].restricted
|
||||
);
|
||||
}
|
||||
|
||||
var hwmodelist = L.toArray(data[0] ? data[0].getHWModes() : null)
|
||||
.reduce(function(o, v) { o[v] = true; return o }, {});
|
||||
|
@ -320,7 +345,8 @@ var CBIWifiFrequencyValue = form.Value.extend({
|
|||
this.modes = [
|
||||
'', 'Legacy', true,
|
||||
'n', 'N', hwmodelist.n,
|
||||
'ac', 'AC', hwmodelist.ac
|
||||
'ac', 'AC', hwmodelist.ac,
|
||||
'ax', 'AX', hwmodelist.ax
|
||||
];
|
||||
|
||||
var htmodelist = L.toArray(data[0] ? data[0].getHTModes() : null)
|
||||
|
@ -337,20 +363,30 @@ var CBIWifiFrequencyValue = form.Value.extend({
|
|||
'VHT40', '40 MHz', htmodelist.VHT40,
|
||||
'VHT80', '80 MHz', htmodelist.VHT80,
|
||||
'VHT160', '160 MHz', htmodelist.VHT160
|
||||
],
|
||||
'ax': [
|
||||
'HE20', '20 MHz', htmodelist.HE20,
|
||||
'HE40', '40 MHz', htmodelist.HE40,
|
||||
'HE80', '80 MHz', htmodelist.HE80,
|
||||
'HE160', '160 MHz', htmodelist.HE160
|
||||
]
|
||||
};
|
||||
|
||||
this.bands = {
|
||||
'': [
|
||||
'11g', '2.4 GHz', this.channels['11g'].length > 3,
|
||||
'11a', '5 GHz', this.channels['11a'].length > 3
|
||||
'2g', '2.4 GHz', this.channels['2g'].length > 3,
|
||||
'5g', '5 GHz', this.channels['5g'].length > 3
|
||||
],
|
||||
'n': [
|
||||
'11g', '2.4 GHz', this.channels['11g'].length > 3,
|
||||
'11a', '5 GHz', this.channels['11a'].length > 3
|
||||
'2g', '2.4 GHz', this.channels['2g'].length > 3,
|
||||
'5g', '5 GHz', this.channels['5g'].length > 3
|
||||
],
|
||||
'ac': [
|
||||
'11a', '5 GHz', true
|
||||
'5g', '5 GHz', true
|
||||
],
|
||||
'ax': [
|
||||
'2g', '2.4 GHz', this.channels['2g'].length > 3,
|
||||
'5g', '5 GHz', this.channels['5g'].length > 3
|
||||
]
|
||||
};
|
||||
}, this));
|
||||
|
@ -392,6 +428,8 @@ var CBIWifiFrequencyValue = form.Value.extend({
|
|||
|
||||
this.setValues(band, this.bands[mode.value]);
|
||||
this.toggleWifiChannel(elem);
|
||||
|
||||
this.map.checkDepends();
|
||||
},
|
||||
|
||||
toggleWifiChannel: function(elem) {
|
||||
|
@ -408,11 +446,14 @@ var CBIWifiFrequencyValue = form.Value.extend({
|
|||
bwdt = elem.querySelector('.htmode'),
|
||||
htval = uci.get('wireless', section_id, 'htmode'),
|
||||
hwval = uci.get('wireless', section_id, 'hwmode'),
|
||||
chval = uci.get('wireless', section_id, 'channel');
|
||||
chval = uci.get('wireless', section_id, 'channel'),
|
||||
bandval = uci.get('wireless', section_id, 'band');
|
||||
|
||||
this.setValues(mode, this.modes);
|
||||
|
||||
if (/VHT20|VHT40|VHT80|VHT160/.test(htval))
|
||||
if (/HE20|HE40|HE80|HE160/.test(htval))
|
||||
mode.value = 'ax';
|
||||
else if (/VHT20|VHT40|VHT80|VHT160/.test(htval))
|
||||
mode.value = 'ac';
|
||||
else if (/HT20|HT40/.test(htval))
|
||||
mode.value = 'n';
|
||||
|
@ -421,15 +462,24 @@ var CBIWifiFrequencyValue = form.Value.extend({
|
|||
|
||||
this.toggleWifiMode(elem);
|
||||
|
||||
if (hwval != null) {
|
||||
this.useBandOption = false;
|
||||
|
||||
if (/a/.test(hwval))
|
||||
band.value = '11a';
|
||||
band.value = '5g';
|
||||
else
|
||||
band.value = '11g';
|
||||
band.value = '2g';
|
||||
}
|
||||
else {
|
||||
this.useBandOption = true;
|
||||
|
||||
band.value = bandval;
|
||||
}
|
||||
|
||||
this.toggleWifiBand(elem);
|
||||
|
||||
bwdt.value = htval;
|
||||
chan.value = chval;
|
||||
chan.value = chval || chan.options[0].value;
|
||||
|
||||
return elem;
|
||||
},
|
||||
|
@ -461,6 +511,7 @@ var CBIWifiFrequencyValue = form.Value.extend({
|
|||
E('select', {
|
||||
'class': 'channel',
|
||||
'style': 'width:auto',
|
||||
'change': L.bind(this.map.checkDepends, this.map),
|
||||
'disabled': (this.disabled != null) ? this.disabled : this.map.readonly
|
||||
})
|
||||
]),
|
||||
|
@ -469,6 +520,7 @@ var CBIWifiFrequencyValue = form.Value.extend({
|
|||
E('select', {
|
||||
'class': 'htmode',
|
||||
'style': 'width:auto',
|
||||
'change': L.bind(this.map.checkDepends, this.map),
|
||||
'disabled': (this.disabled != null) ? this.disabled : this.map.readonly
|
||||
})
|
||||
]),
|
||||
|
@ -481,7 +533,7 @@ var CBIWifiFrequencyValue = form.Value.extend({
|
|||
cfgvalue: function(section_id) {
|
||||
return [
|
||||
uci.get('wireless', section_id, 'htmode'),
|
||||
uci.get('wireless', section_id, 'hwmode'),
|
||||
uci.get('wireless', section_id, 'hwmode') || uci.get('wireless', section_id, 'band'),
|
||||
uci.get('wireless', section_id, 'channel')
|
||||
];
|
||||
},
|
||||
|
@ -498,7 +550,12 @@ var CBIWifiFrequencyValue = form.Value.extend({
|
|||
|
||||
write: function(section_id, value) {
|
||||
uci.set('wireless', section_id, 'htmode', value[0] || null);
|
||||
uci.set('wireless', section_id, 'hwmode', value[1]);
|
||||
|
||||
if (this.useBandOption)
|
||||
uci.set('wireless', section_id, 'band', value[1]);
|
||||
else
|
||||
uci.set('wireless', section_id, 'hwmode', (value[1] == '2g') ? '11g' : '11a');
|
||||
|
||||
uci.set('wireless', section_id, 'channel', value[2]);
|
||||
}
|
||||
});
|
||||
|
@ -883,6 +940,9 @@ return view.extend({
|
|||
o.ucisection = s.section;
|
||||
|
||||
if (hwtype == 'mac80211') {
|
||||
o = ss.taboption('general', form.Flag, 'legacy_rates', _('Allow legacy 802.11b rates'), _('Legacy or badly behaving devices may require legacy 802.11b rates to interoperate. Airtime efficiency may be significantly reduced where these are used. It is recommended to not allow 802.11b rates where possible.'));
|
||||
o.depends({'_freq': '11g', '!contains': true});
|
||||
|
||||
o = ss.taboption('general', CBIWifiTxPowerValue, 'txpower', _('Maximum transmit power'), _('Specifies the maximum transmit power the wireless radio may use. Depending on regulatory requirements and wireless usage, the actual transmit power may be reduced by the driver.'));
|
||||
o.wifiNetwork = radioNet;
|
||||
|
||||
|
@ -895,9 +955,6 @@ return view.extend({
|
|||
o.value('2', _('High'));
|
||||
o.value('3', _('Very High'));
|
||||
|
||||
o = ss.taboption('advanced', form.Flag, 'legacy_rates', _('Allow legacy 802.11b rates'));
|
||||
o.default = o.enabled;
|
||||
|
||||
o = ss.taboption('advanced', form.Value, 'distance', _('Distance Optimization'), _('Distance to farthest network member in meters.'));
|
||||
o.datatype = 'or(range(0,114750),"auto")';
|
||||
o.placeholder = 'auto';
|
||||
|
@ -983,8 +1040,17 @@ return view.extend({
|
|||
return net || network.addNetwork(name, { proto: 'none' });
|
||||
}, this, values[i])).then(L.bind(function(dev, net) {
|
||||
if (net) {
|
||||
if (!net.isEmpty())
|
||||
if (!net.isEmpty()) {
|
||||
var target_dev = net.getDevice();
|
||||
|
||||
/* Resolve parent interface of vlan */
|
||||
while (target_dev && target_dev.getType() == 'vlan')
|
||||
target_dev = target_dev.getParent();
|
||||
|
||||
if (!target_dev || target_dev.getType() != 'bridge')
|
||||
net.set('type', 'bridge');
|
||||
}
|
||||
|
||||
net.addDevice(dev);
|
||||
}
|
||||
}, this, dev)));
|
||||
|
@ -1014,7 +1080,7 @@ return view.extend({
|
|||
bssid.depends('mode', 'sta');
|
||||
bssid.depends('mode', 'sta-wds');
|
||||
|
||||
o = ss.taboption('macfilter', form.ListValue, 'macfilter', _('MAC-Address Filter'));
|
||||
o = ss.taboption('macfilter', form.ListValue, 'macfilter', _('MAC Address Filter'));
|
||||
o.depends('mode', 'ap');
|
||||
o.depends('mode', 'ap-wds');
|
||||
o.value('', _('disable'));
|
||||
|
@ -1069,11 +1135,11 @@ return view.extend({
|
|||
return mode;
|
||||
};
|
||||
|
||||
o = ss.taboption('general', form.Flag, 'hidden', _('Hide <abbr title="Extended Service Set Identifier">ESSID</abbr>'));
|
||||
o = ss.taboption('general', form.Flag, 'hidden', _('Hide <abbr title="Extended Service Set Identifier">ESSID</abbr>'), _('Where the ESSID is hidden, clients may fail to roam and airtime efficiency may be significantly reduced.'));
|
||||
o.depends('mode', 'ap');
|
||||
o.depends('mode', 'ap-wds');
|
||||
|
||||
o = ss.taboption('general', form.Flag, 'wmm', _('WMM Mode'));
|
||||
o = ss.taboption('general', form.Flag, 'wmm', _('WMM Mode'), _('Where Wi-Fi Multimedia (WMM) Mode QoS is disabled, clients may be limited to 802.11a/802.11g rates.'));
|
||||
o.depends('mode', 'ap');
|
||||
o.depends('mode', 'ap-wds');
|
||||
o.default = o.enabled;
|
||||
|
@ -1609,8 +1675,7 @@ return view.extend({
|
|||
|
||||
if (hwtype == 'mac80211') {
|
||||
// ieee802.11w options
|
||||
if (L.hasSystemFeature('hostapd', '11w')) {
|
||||
o = ss.taboption('encryption', form.ListValue, 'ieee80211w', _('802.11w Management Frame Protection'), _("Requires the 'full' version of wpad/hostapd and support from the wifi driver <br />(as of Jan 2019: ath9k, ath10k, mwlwifi and mt76)"));
|
||||
o = ss.taboption('encryption', form.ListValue, 'ieee80211w', _('802.11w Management Frame Protection'), _("Note: Some wireless drivers do not fully support 802.11w. E.g. mwlwifi may have problems"));
|
||||
o.value('', _('Disabled'));
|
||||
o.value('1', _('Optional'));
|
||||
o.value('2', _('Required'));
|
||||
|
@ -1635,7 +1700,6 @@ return view.extend({
|
|||
o.datatype = 'uinteger';
|
||||
o.placeholder = '201';
|
||||
o.rmempty = true;
|
||||
};
|
||||
|
||||
o = ss.taboption('encryption', form.Flag, 'wpa_disable_eapol_key_retries', _('Enable key reinstallation (KRACK) countermeasures'), _('Complicates key reinstallation attacks on the client side by disabling retransmission of EAPOL-Key frames that are used to install keys. This workaround might cause interoperability issues and reduced robustness of key negotiation especially in environments with heavy traffic load.'));
|
||||
add_dependency_permutations(o, { mode: ['ap', 'ap-wds'], encryption: ['psk2', 'psk-mixed', 'sae', 'sae-mixed', 'wpa2', 'wpa3', 'wpa3-mixed'] });
|
||||
|
@ -2082,7 +2146,7 @@ return view.extend({
|
|||
var table = E('table', { 'class': 'table assoclist', 'id': 'wifi_assoclist_table' }, [
|
||||
E('tr', { 'class': 'tr table-titles' }, [
|
||||
E('th', { 'class': 'th nowrap' }, _('Network')),
|
||||
E('th', { 'class': 'th hide-xs' }, _('MAC-Address')),
|
||||
E('th', { 'class': 'th hide-xs' }, _('MAC address')),
|
||||
E('th', { 'class': 'th' }, _('Host')),
|
||||
E('th', { 'class': 'th' }, _('Signal / Noise')),
|
||||
E('th', { 'class': 'th' }, _('RX Rate / TX Rate'))
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
"read": {
|
||||
"cgi-io": [ "exec" ],
|
||||
"file": {
|
||||
"/usr/libexec/luci-peeraddr": [ "exec" ]
|
||||
"/etc/iproute2/rt_tables": [ "read" ],
|
||||
"/proc/sys/net/ipv6/conf/*/mtu": [ "read" ],
|
||||
"/proc/sys/net/ipv6/conf/*/hop_limit": [ "read" ],
|
||||
"/usr/libexec/luci-peeraddr": [ "exec" ],
|
||||
"/usr/lib/opkg/info/netifd.control": [ "read" ]
|
||||
},
|
||||
"ubus": {
|
||||
"file": [ "exec" ],
|
||||
|
|
Loading…
Reference in a new issue