From e4b43ba89ab660956aab26fb8f11af490c5554c0 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 20 Oct 2023 00:25:39 +0200 Subject: [PATCH] luci-mod-network: rework DHCP relay settings - Drop completely bogus 'ID' option, it's not handled by anything - Clarify relay from / relay to / accept from options Fixes: #6639 Fixes: a627744bb5 ("luci-mod-network: 'relay' tab added") Signed-off-by: Jo-Philipp Wich (cherry picked from commit 88326b809ba9388a1b11b1c4226ccb07e5911261) --- .../resources/view/network/dhcp.js | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index 795b98f4c8..307fca4e86 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -234,7 +234,7 @@ return view.extend({ callHostHints(), callDUIDHints(), getDHCPPools(), - network.getDevices() + network.getNetworks() ]); }, @@ -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'), @@ -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'; @@ -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 /etc/ethers'), _('Read /etc/ethers to configure the DHCP server.')); -- 2.30.2