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: 4ca87f6576

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 <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald 2024-05-01 16:18:26 +02:00
parent e5f6b64813
commit fa2aeb7d2f
1 changed files with 2 additions and 2 deletions

View File

@ -32,8 +32,8 @@ function rule_proto_txt(s) {
} : null;
return fwtool.fmt(_('Forwarded %{ipv6?%{ipv4?<var>IPv4</var> and <var>IPv6</var>:<var>IPv6</var>}:<var>IPv4</var>}%{proto?, protocol %{proto#%{next?, }<var>%{item.name}</var>}}%{mark?, mark <var%{mark.inv? data-tooltip="Match fwmarks except %{mark.num}%{mark.mask? with mask %{mark.mask}}.":%{mark.mask? data-tooltip="Mask fwmark value with %{mark.mask} before compare."}}>%{mark.val}</var>}'), {
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
});