From 9c55500fe8efa309d55f34c21d5ae2bf69fabf06 Mon Sep 17 00:00:00 2001 From: Chen Minqiang Date: Wed, 19 Oct 2022 18:01:15 +0800 Subject: luci-app-firewall: allow ipv6 setup Allow setup ipv6 for Port Forwards and NAT Rules if firewall4 is used. Add 'Restrict to address family' option for NAT Rules, if family is any/empty , assume it is ipv4. this allow setup NAT6 rules in web ui Signed-off-by: Chen Minqiang --- .../htdocs/luci-static/resources/tools/firewall.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js') diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js b/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js index 03e505e89d..ec0ee369ea 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js @@ -477,18 +477,20 @@ return baseclass.extend({ addLocalIPOption: function(s, tab, name, label, description, devices) { var o = s.taboption(tab, form.Value, name, label, description); + var fw4 = L.hasSystemFeature('firewall4'); o.modalonly = true; - o.datatype = 'ip4addr("nomask")'; + o.datatype = !fw4?'ip4addr("nomask")':'ipaddr("nomask")'; o.placeholder = _('any'); L.sortedKeys(devices, 'name').forEach(function(dev) { var ip4addrs = devices[dev].ipaddrs; + var ip6addrs = devices[dev].ip6addrs; - if (!L.isObject(devices[dev].flags) || !Array.isArray(ip4addrs) || devices[dev].flags.loopback) + if (!L.isObject(devices[dev].flags) || devices[dev].flags.loopback) return; - for (var i = 0; i < ip4addrs.length; i++) { + for (var i = 0; Array.isArray(ip4addrs) && i < ip4addrs.length; i++) { if (!L.isObject(ip4addrs[i]) || !ip4addrs[i].address) continue; @@ -496,6 +498,14 @@ return baseclass.extend({ ip4addrs[i].address, ' (', E('strong', {}, [dev]), ')' ])); } + for (var i = 0; fw4 && Array.isArray(ip6addrs) && i < ip6addrs.length; i++) { + if (!L.isObject(ip6addrs[i]) || !ip6addrs[i].address) + continue; + + o.value(ip6addrs[i].address, E([], [ + ip6addrs[i].address, ' (', E('strong', {}, [dev]), ')' + ])); + } }); return o; -- cgit v1.2.3