From: Paul Donald Date: Wed, 1 May 2024 14:18:26 +0000 (+0200) Subject: luci-app-firewall: SNAT display fixes X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=fa2aeb7d2ff84c0dc022c7432b6123cb950dbd61;p=project%2Fluci.git luci-app-firewall: SNAT display fixes The implied logic in the functions to build display text is a bit of a minefield. Now, if family=4+6 is selected, display 4+6. This part is a follow-up to: 4ca87f6576272d4a4659e995bef00cf34d5746e9 Previously it would display only IPv6. Now, if family=auto i.e. '' is selected then display 4 only. fw4 internally treats no family as IPv4 only, meaning that IPv6 was not SNATed. (This treatment is 'incorrect' but because it has always been this way, this behaviour is retained for backwards compatibility, and user expectations.) Previous logic was incorrect (bug) and would display: Forwarded IPv4 and IPv6 misleading the user. Signed-off-by: Paul Donald --- 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 015b8b7681..8c05e1f2de 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 || !dip || !rwip)) || (!family && (sip.indexOf(':') != -1 || dip.indexOf(':') != -1 || rwip.indexOf(':') != -1))), + ipv4: (family == 'ipv4' || family == 'any' || (!family && sip.indexOf(':') == -1 && dip.indexOf(':') == -1 && rwip.indexOf(':') == -1)), + ipv6: (family == 'ipv6' || family == 'any' || (!family && (sip.indexOf(':') != -1 || dip.indexOf(':') != -1 || rwip.indexOf(':') != -1))), proto: proto, mark: f });