diff options
author | Chen Minqiang <ptpt52@gmail.com> | 2022-10-19 18:01:15 +0800 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2023-03-15 23:37:46 +0100 |
commit | 9c55500fe8efa309d55f34c21d5ae2bf69fabf06 (patch) | |
tree | 7ab9ba0442cc457ca49bca024e0853a20900966e /applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js | |
parent | c0d4c0172529e060926e8fa00714bd9e8b567cb4 (diff) |
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 <ptpt52@gmail.com>
Diffstat (limited to 'applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js')
-rw-r--r-- | applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js | 16 |
1 files changed, 13 insertions, 3 deletions
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; |