diff options
Diffstat (limited to 'lib/Vyatta/IpTables/Rule.pm')
-rw-r--r-- | lib/Vyatta/IpTables/Rule.pm | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/Vyatta/IpTables/Rule.pm b/lib/Vyatta/IpTables/Rule.pm index 6105ae7..e6b6ca7 100644 --- a/lib/Vyatta/IpTables/Rule.pm +++ b/lib/Vyatta/IpTables/Rule.pm @@ -332,14 +332,18 @@ sub rule { # set the protocol if (defined($self->{_protocol})) { - my $str = $self->{_protocol}; - $str =~ s/^\!(.*)$/! $1/; - if ($str eq 'tcp_udp') { - $tcp_and_udp = 1; - $rule .= " -p tcp "; # we'll add the '-p udp' to 2nd rule later - } else { - $rule .= " -p $str "; - } + my $str = $self->{_protocol}; + my $negate = ''; + if ($str =~ /^\!(.*)$/) { + $str = $1; + $negate = '! '; + } + if ($str eq 'tcp_udp') { + $tcp_and_udp = 1; + $rule .= " $negate -p tcp "; # we'll add the '-p udp' to 2nd rule later + } else { + $rule .= " $negate -p $str "; + } } my $state_str = uc (get_state_str($self)); |