From 54b64881134207e28ded2a5b290a18c24065cdc7 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Wed, 23 Dec 2015 08:24:00 -0800 Subject: [PATCH] Allow a timeout to be specified in ADD rules Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Rules.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Rules.pm b/Shorewall/Perl/Shorewall/Rules.pm index dce4c555a..5a69b33a3 100644 --- a/Shorewall/Perl/Shorewall/Rules.pm +++ b/Shorewall/Perl/Shorewall/Rules.pm @@ -2477,13 +2477,21 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) { $actiontype |= HELPER; } elsif ( $actiontype & SET ) { my %xlate = ( ADD => 'add-set' , DEL => 'del-set' ); + my ( $setname, $flags, $timeout, $rest ) = split ':', $param, 4; - my ( $setname, $flags, $rest ) = split ':', $param, 3; fatal_error "Invalid ADD/DEL parameter ($param)" if $rest; $setname =~ s/^\+//; fatal_error "Expected ipset name ($setname)" unless $setname =~ /^(6_)?[a-zA-Z][-\w]*$/; - fatal_error "Invalid flags ($flags)" unless defined $flags && $flags =~ /^(dst|src)(,(dst|src)){0,5}$/; + fatal_error "Invalid flags ($flags)" unless defined $flags && $flags =~ /^(dst|src)(,(dst|src)){0,5}$/; + $action = join( ' ', 'SET --' . $xlate{$basictarget} , $setname , $flags ); + + if ( supplied $timeout ) { + fatal_error "A timeout may only be supplied in an ADD rule" unless $basictarget eq 'ADD'; + fatal_error "Invalid Timeout ($timeout)" unless $timeout && $timeout =~ /^\d+$/; + + $action .= " --timeout $timeout"; + } } } #