diff options
author | Paul Donald <newtwen@gmail.com> | 2024-01-25 00:42:38 +0100 |
---|---|---|
committer | Paul Donald <newtwen@gmail.com> | 2024-01-25 01:09:11 +0100 |
commit | 754b36d05ac26e1ddc68d8726e01faa38f9fe948 (patch) | |
tree | d2d772d3481b726fe35c4351286f18ea8241247b | |
parent | 9889d3f73524c5ef814ab37e5c9fac81f213046d (diff) |
luci-mod-network: repair DHCP relay validation logic
change && to || so as not to backtrace if only one was empty/null.
Signed-off-by: Paul Donald <newtwen@gmail.com>
-rw-r--r-- | modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js | 24 |
1 files changed, 14 insertions, 10 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 c78738b9cc..2c141d3078 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 @@ -484,23 +484,27 @@ return view.extend({ var m = this.section.formvalue(section, 'local_addr'), n = this.section.formvalue(section, 'server_addr'), p; - if (n != null && n != '') - p = n.split('#'); + + if (!m || !n) { + return _('Both "Relay from" and "Relay to address" must be specified.'); + } + else { + 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 "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 _('Address families of "Relay from" and "Relay to address" must match.') + if ((validation.parseIPv6(m) && validation.parseIPv6(n)) || + validation.parseIPv4(m) && validation.parseIPv4(n)) + return true; + else + return _('Address families of "Relay from" and "Relay to address" must match.') + } + return true; }; + so = ss.option(widgets.NetworkSelect, 'interface', _('Only accept replies via')); so.optional = true; so.rmempty = false; |