In IPv6 mode, check for the correct kind of IP for NAT https://sourceforge.net/p/webadmin/bugs/5451/

This commit is contained in:
Jamie Cameron
2021-02-02 22:56:37 -08:00
parent f4de0f4a9a
commit f0a9543e20
3 changed files with 18 additions and 4 deletions

View File

@@ -59,5 +59,12 @@ foreach my $w (split(/\s+/, $_[0])) {
return 1;
}
# check_ipvx_ipaddress(ipv4)
# Validates an IPv4 address
sub check_ipvx_ipaddress
{
return &check_ipaddress(@_);
}
1;

View File

@@ -57,5 +57,12 @@ foreach my $w (split(/,/, $_[0])) {
return 1;
}
# check_ipvx_ipaddress(ipv6)
# Validates an IPv6 address
sub check_ipvx_ipaddress
{
return &check_ip6address(@_);
}
1;

View File

@@ -96,9 +96,9 @@ else {
}
if ($table->{'name'} eq 'nat' && $rule->{'chain'} ne 'POSTROUTING') {
if ($rule->{'j'}->[1] eq 'DNAT' && !$in{'dnatdef'}) {
!$in{'dipfrom'} || &check_ipaddress($in{'dipfrom'}) ||
!$in{'dipfrom'} || &check_ipvx_address($in{'dipfrom'})||
&error($text{'save_edipfrom'});
!$in{'dipto'} || &check_ipaddress($in{'dipto'}) ||
!$in{'dipto'} || &check_ipvx_address($in{'dipto'}) ||
&error($text{'save_edipto'});
local $v = $in{'dipfrom'};
$v .= "-".$in{'dipto'} if ($in{'dipto'});
@@ -124,9 +124,9 @@ else {
$rule->{'chain'} ne 'OUTPUT') {
if ($rule->{'j'}->[1] eq 'SNAT' && !$in{'snatdef'}) {
(!$in{'sipfrom'} && !$in{'sipto'}) ||
&check_ipaddress($in{'sipfrom'}) ||
&check_ipvx_address($in{'sipfrom'}) ||
&error($text{'save_esipfrom'});
!$in{'sipto'} || &check_ipaddress($in{'sipto'}) ||
!$in{'sipto'} || &check_ipvx_address($in{'sipto'}) ||
&error($text{'save_esipto'});
local $v = $in{'sipfrom'};
$v .= "-".$in{'sipto'} if ($in{'sipto'});