Merge pull request #6047 from systemcrash/luci-mod-network-relay

luci-mod-network: 'relay' tab added
This commit is contained in:
Florian Eckert 2022-10-28 11:02:47 +02:00 committed by GitHub
commit 1d157d3a50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -231,7 +231,8 @@ return view.extend({
return Promise.all([
callHostHints(),
callDUIDHints(),
getDHCPPools()
getDHCPPools(),
network.getDevices()
]);
},
@ -240,6 +241,7 @@ return view.extend({
hosts = hosts_duids_pools[0],
duids = hosts_duids_pools[1],
pools = hosts_duids_pools[2],
ndevs = hosts_duids_pools[3],
m, s, o, ss, so;
m = new form.Map('dhcp', _('DHCP and DNS'),
@ -250,6 +252,7 @@ return view.extend({
s.addremove = false;
s.tab('general', _('General Settings'));
s.tab('relay', _('Relay'));
s.tab('files', _('Resolv and Hosts Files'));
s.tab('pxe_tftp', _('PXE/TFTP Settings'));
s.tab('advanced', _('Advanced Settings'));
@ -345,6 +348,66 @@ return view.extend({
o.optional = true;
o.placeholder = 'loopback';
o = s.taboption('relay', form.SectionValue, '__relays__', form.TableSection, 'relay', null,
_('Relay DHCP requests elsewhere. OK: v4<->v4, v6<->v6. Not OK: v4<->v6, v6<->v4.')
+ '<br />' + _('Note: you may also need a DHCP Proxy (currently unavailable) when specifying a non-standard Relay To port(<code>addr#port</code>).')
+ '<br />' + _('You may add multiple unique Relay To on the same Listen addr.'));
ss = o.subsection;
ss.addremove = true;
ss.anonymous = true;
ss.sortable = true;
ss.rowcolors = true;
ss.nodescriptions = true;
so = ss.option(form.Value, 'id', _('ID'));
so.rmempty = false;
so.optional = true;
so = ss.option(widgets.NetworkSelect, 'interface', _('Interface'));
so.optional = true;
so.rmempty = false;
so.placeholder = 'lan';
so = ss.option(form.Value, 'local_addr', _('Listen address'));
so.rmempty = false;
so.datatype = 'ipaddr';
for (var family = 4; family <= 6; family += 2) {
for (var i = 0; i < ndevs.length; i++) {
var addrs = (family == 6) ? ndevs[i].getIP6Addrs() : ndevs[i].getIPAddrs();
for (var j = 0; j < addrs.length; j++)
so.value(addrs[j].split('/')[0]);
}
}
so = ss.option(form.Value, 'server_addr', _('Relay To address'));
so.rmempty = false;
so.optional = false;
so.placeholder = '192.168.10.1#535';
so.validate = function(section, value) {
var m = this.section.formvalue(section, 'local_addr'),
n = this.section.formvalue(section, 'server_addr'),
p;
if (n != null && n != '')
p = n.split('#');
if (p.length > 1 && !/^[0-9]+$/.test(p[1]))
return _('Expected port number.');
else
n = p[0];
if ((m == null || m == '') && (n == null || n == ''))
return _('Both Listen addr and Relay To must be specified.');
if ((validation.parseIPv6(m) && validation.parseIPv6(n)) ||
validation.parseIPv4(m) && validation.parseIPv4(n))
return true;
else
return _('Listen and Relay To IP family must be homogeneous.')
};
s.taboption('files', form.Flag, 'readethers',
_('Use <code>/etc/ethers</code>'),
_('Read <code>/etc/ethers</code> to configure the DHCP server.'));