Skip to content

Commit

Permalink
luci-mod-network: rework DHCP relay settings
Browse files Browse the repository at this point in the history
 - Drop completely bogus 'ID' option, it's not handled by anything
 - Clarify relay from / relay to / accept from options

Fixes: #6639
Fixes: a627744 ("luci-mod-network: 'relay' tab added")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
  • Loading branch information
jow- committed Oct 19, 2023
1 parent 6039925 commit 88326b8
Showing 1 changed file with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ return view.extend({
callHostHints(),
callDUIDHints(),
getDHCPPools(),
network.getDevices()
network.getNetworks()
]);
},

Expand All @@ -243,7 +243,7 @@ return view.extend({
hosts = hosts_duids_pools[0],
duids = hosts_duids_pools[1],
pools = hosts_duids_pools[2],
ndevs = hosts_duids_pools[3],
networks = hosts_duids_pools[3],
m, s, o, ss, so;

m = new form.Map('dhcp', _('DHCP and DNS'),
Expand Down Expand Up @@ -364,28 +364,27 @@ return view.extend({
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 = ss.option(form.Value, 'local_addr', _('Relay from'));
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]);
for (var i = 0; i < networks.length; i++) {
if (networks[i].getName() != 'loopback') {
var addrs = (family == 6) ? networks[i].getIP6Addrs() : networks[i].getIPAddrs();
for (var j = 0; j < addrs.length; j++) {
var addr = addrs[j].split('/')[0];
so.value(addr, E([], [
addr, ' (',
widgets.NetworkSelect.prototype.renderIfaceBadge(networks[i]),
')'
]));
}
}
}
}

so = ss.option(form.Value, 'server_addr', _('Relay To address'));
so = ss.option(form.Value, 'server_addr', _('Relay to address'));
so.rmempty = false;
so.optional = false;
so.placeholder = '192.168.10.1#535';
Expand All @@ -402,15 +401,20 @@ return view.extend({
n = p[0];

if ((m == null || m == '') && (n == null || n == ''))
return _('Both Listen addr and Relay To must be specified.');
return _('Both "Relay from" and "Relay to address" 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.')
return _('Address families of "Relay from" and "Relay to address" must match.')
};

so = ss.option(widgets.NetworkSelect, 'interface', _('Only accept replies via'));
so.optional = true;
so.rmempty = false;
so.placeholder = 'lan';

s.taboption('files', form.Flag, 'readethers',
_('Use <code>/etc/ethers</code>'),
_('Read <code>/etc/ethers</code> to configure the DHCP server.'));
Expand Down

0 comments on commit 88326b8

Please sign in to comment.