diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-07-03 20:40:29 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-07-03 20:40:29 +0200 |
commit | 9d15a4e70c10a43911c7f9d48240a01c23eb81b6 (patch) | |
tree | a45f2bf0eb0cd2e503c478c070f4813945f5caab /modules/luci-mod-network/htdocs/luci-static/resources/view | |
parent | 00e41c3c4977f75e6ca43429dd4c8c2f5cb22419 (diff) |
luci-mod-network: fixes to DHCP lease validation
- validate current form value IP instead of stored uci one
- ensure to not pass non-string values to the validator
- remove leftover debug code
- simplify obtaining formvalues
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-network/htdocs/luci-static/resources/view')
-rw-r--r-- | modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js | 14 |
1 files changed, 5 insertions, 9 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 a9a5ec85ee..d8083a1e0e 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 @@ -67,12 +67,12 @@ CBILease6Status = form.DummyValue.extend({ }); function calculateNetwork(addr, mask) { - addr = validation.parseIPv4(addr); + addr = validation.parseIPv4(String(addr)); if (!isNaN(mask)) mask = validation.parseIPv4(network.prefixToMask(+mask)); else - mask = validation.parseIPv4(mask); + mask = validation.parseIPv4(String(mask)); if (addr == null || mask == null) return null; @@ -199,7 +199,7 @@ function validateMACAddr(pools, sid, s) { this_macs = L.toArray(s).map(function(m) { return m.toUpperCase() }); for (var i = 0; i < pools.length; i++) { - var this_net_mask = calculateNetwork(uci.get('dhcp', sid, 'ip'), pools[i].netmask); + var this_net_mask = calculateNetwork(this.section.formvalue(sid, 'ip'), pools[i].netmask); if (!this_net_mask) continue; @@ -241,8 +241,6 @@ return view.extend({ pools = hosts_duids_pools[2], m, s, o, ss, so; - console.debug(pools); - m = new form.Map('dhcp', _('DHCP and DNS'), _('Dnsmasq is a combined <abbr title="Dynamic Host Configuration Protocol">DHCP</abbr>-Server and <abbr title="Domain Name System">DNS</abbr>-Forwarder for <abbr title="Network Address Translation">NAT</abbr> firewalls')); s = m.section(form.TypedSection, 'dnsmasq', _('Server Settings')); @@ -568,10 +566,8 @@ return view.extend({ 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) { - var mac = this.map.lookupOption('mac', section), - name = this.map.lookupOption('name', section), - m = mac ? mac[0].formvalue(section) : null, - n = name ? name[0].formvalue(section) : null; + var m = this.section.formvalue(section, 'mac'), + n = this.section.formvalue(section, 'name'); if ((m == null || m == '') && (n == null || n == '')) return _('One of hostname or mac address must be specified!'); |