From: Dirk Brenken Date: Wed, 5 Apr 2023 09:30:29 +0000 (+0200) Subject: luci-app-firewall: fix the IPv6 forwards/snats view X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=148759a5c51ea30bca2c66a4035cf0f6b966e6cb;p=project%2Fluci.git luci-app-firewall: fix the IPv6 forwards/snats view * corrects the view as IPv4 and IPv6 for rules where the family is 'any' and the IP not set (this fixes #9c55500), e.g. a forward rule like that: config redirect 'adblock_lan53' option name 'Adblock DNS (lan, 53)' option src 'lan' option proto 'tcp udp' option src_dport '53' option dest_port '53' option target 'DNAT' option family 'any' Signed-off-by: Dirk Brenken --- diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js index d7f70de517..ee8d36e0c6 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js @@ -10,7 +10,7 @@ function rule_proto_txt(s, ctHelpers) { var family = (uci.get('firewall', s, 'family') || '').toLowerCase().replace(/^(?:any|\*)$/, ''); - var dip = uci.get('firewall', s, 'dest_ip') || '' + var dip = uci.get('firewall', s, 'dest_ip') || ''; var proto = L.toArray(uci.get('firewall', s, 'proto')).filter(function(p) { return (p != '*' && p != 'any' && p != 'all'); }).map(function(p) { @@ -38,8 +38,8 @@ function rule_proto_txt(s, ctHelpers) { } : null; return fwtool.fmt(_('Incoming %{ipv6?%{ipv4?IPv4 and IPv6:IPv6}:IPv4}%{proto?, protocol %{proto#%{next?, }%{item.types?%{item.name}ICMP with types %{item.types#%{next?, }%{item}}:%{item.name}}}}%{mark?, mark %{mark.val}}%{helper?, helper %{helper.inv?%{helper.val}:%{helper.val}}}'), { - ipv4: ((!family && (dip.indexOf(':') == -1)) || family == 'ipv4'), - ipv6: ((!family && (dip.indexOf(':') != -1)) || family == 'ipv6'), + ipv4: ((!family && dip.indexOf(':') == -1) || family == 'ipv4'), + ipv6: ((!family && dip.indexOf(':') != -1) || (!family && !dip) || family == 'ipv6'), proto: proto, helper: h, mark: f diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js index 9c3d5e7a31..759c23e0d9 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js @@ -32,8 +32,8 @@ function rule_proto_txt(s) { } : null; return fwtool.fmt(_('Forwarded %{ipv6?%{ipv4?IPv4 and IPv6:IPv6}:IPv4}%{proto?, protocol %{proto#%{next?, }%{item.name}}}%{mark?, mark %{mark.val}}'), { - ipv4: (family == 'ipv4' || (!family && (sip.indexOf(':') == -1 && dip.indexOf(':') == -1 && rwip.indexOf(':') == -1))), - ipv6: (family == 'ipv6' || (!family && (sip.indexOf(':') != -1 || dip.indexOf(':') != -1 || rwip.indexOf(':') != -1))), + ipv4: (family == 'ipv4' || (!family && sip.indexOf(':') == -1 && dip.indexOf(':') == -1 && rwip.indexOf(':') == -1)), + ipv6: (family == 'ipv6' || (!family && (!sip || !dip || !rwip)) || (!family && (sip.indexOf(':') != -1 || dip.indexOf(':') != -1 || rwip.indexOf(':') != -1))), proto: proto, mark: f });