diff options
author | Daniil Baturin <daniil@baturin.org> | 2017-10-25 01:55:22 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-25 01:55:22 +0700 |
commit | af219d4ac8208cfa676f5822ae45acf8660df30a (patch) | |
tree | 35ad5cabaa72d6d12e1fcf35ecb27e63b9d0734b | |
parent | d078bba33249cc4099b92825eb8d9e7d4373ce67 (diff) | |
parent | 1d07954e0c8949f6d48f6c2aa3b04f1a017092f7 (diff) | |
download | vyatta-nat-af219d4ac8208cfa676f5822ae45acf8660df30a.tar.gz vyatta-nat-af219d4ac8208cfa676f5822ae45acf8660df30a.zip |
T431: Merge pull request #5 from quonb/current
Fix protocol negation in NAT (like it is done in Vyatta::IpTables::Rule)
-rw-r--r-- | lib/Vyatta/DstNatRule.pm | 6 | ||||
-rw-r--r-- | lib/Vyatta/SrcNatRule.pm | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/Vyatta/DstNatRule.pm b/lib/Vyatta/DstNatRule.pm index e2aa483..bd54306 100644 --- a/lib/Vyatta/DstNatRule.pm +++ b/lib/Vyatta/DstNatRule.pm @@ -158,8 +158,10 @@ sub rule_str { if (defined($self->{_proto})) { my $str = $self->{_proto}; my $negate =""; - $negate = "!" if (m/^\!(.*)$/); - $str =~ s/^\!(.*)$/ $1/; + if ($str =~ /^\!(.*)$/) { + $str = $1; + $negate = "!"; + } if ($str eq 'tcp_udp') { $tcp_and_udp = 1; $rule_str .= " -p tcp "; # we'll add the '-p udp' to 2nd rule later diff --git a/lib/Vyatta/SrcNatRule.pm b/lib/Vyatta/SrcNatRule.pm index 89623a4..52227a5 100644 --- a/lib/Vyatta/SrcNatRule.pm +++ b/lib/Vyatta/SrcNatRule.pm @@ -176,9 +176,11 @@ sub rule_str { if (defined($self->{_proto})) { my $str = $self->{_proto}; - my $negate =""; - $negate = "!" if (m/^\!(.*)$/); - $str =~ s/^\!(.*)$/ $1/; + my $negate = ""; + if ($str =~ /^\!(.*)$/) { + $str = $1; + $negate = "!"; + } if ($str eq 'tcp_udp') { $tcp_and_udp = 1; $rule_str .= " -p tcp "; # we'll add the '-p udp' to 2nd rule later |