From 23bc6f1ab50eb59ea66abbd335ad5c302d32c8bf Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sun, 16 Dec 2018 09:38:44 -0800 Subject: [PATCH] Allow leading 's' & 'd' to be omitted when specifying two rates Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Chains.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Chains.pm b/Shorewall/Perl/Shorewall/Chains.pm index 198c39523..b597d697f 100644 --- a/Shorewall/Perl/Shorewall/Chains.pm +++ b/Shorewall/Perl/Shorewall/Chains.pm @@ -5350,8 +5350,17 @@ sub do_ratelimit( $$ ) { my @rates = split_list3 $rates, 'rate'; if ( @rates == 2 ) { - $rates[0] = 's:' . $rates[0] unless $rates[0] =~ /^s(?:\/\d+)?:/; - $rates[1] = 'd:' . $rates[1] unless $rates[1] =~ /^d(?:\/\d+)?:/; + if ( $rates[0] =~ m|^/\d+:| ) { + $rates[0] = 's' . $rates[0]; + } else { + $rates[0] = 's:' . $rates[0] unless $rates[0] =~ m|^s(?:/\d+)?:|; + } + + if ( $rates[1] =~ m|^/\d+:| ) { + $rates[1] = 'd' . $rates[1]; + } else { + $rates[1] = 'd:' . $rates[1] unless $rates[1] =~ m|^d(?:/\d+)?:|; + } } elsif ( @rates > 2 ) { fatal error "Only two rates may be specified"; }