1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Update luci-mod-network to upstream and add multipath and latency support

This commit is contained in:
Ycarus (Yannick Chabanois) 2021-06-25 19:45:23 +02:00
parent 490133cea7
commit 94f2c90ad4
8 changed files with 1859 additions and 382 deletions

View file

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