mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-18 20:30:43 +01:00
Implement Shorewall::Chains::clone_rule()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
3498076a96
commit
61d5c6d6da
@ -41,6 +41,7 @@ our @EXPORT = qw(
|
|||||||
add_ijump
|
add_ijump
|
||||||
insert_rule
|
insert_rule
|
||||||
insert_irule
|
insert_irule
|
||||||
|
clone_rule
|
||||||
insert_ijump
|
insert_ijump
|
||||||
rule_target
|
rule_target
|
||||||
clear_rule_target
|
clear_rule_target
|
||||||
@ -1281,6 +1282,20 @@ sub insert_irule( $$$$;@ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
# Clone an existing rule. Only the rule hash itself is cloned; reference values are shared between the new rule
|
||||||
|
# reference and the old.
|
||||||
|
#
|
||||||
|
sub clone_rule( $ ) {
|
||||||
|
my $oldruleref = $_[0];
|
||||||
|
my $newruleref = {};
|
||||||
|
|
||||||
|
while ( my ( $key, $value ) = each %$oldruleref ) {
|
||||||
|
$newruleref->{$key} = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$newruleref;
|
||||||
|
}
|
||||||
|
|
||||||
# Do final work to 'delete' a chain. We leave it in the chain table but clear
|
# Do final work to 'delete' a chain. We leave it in the chain table but clear
|
||||||
# the 'referenced', 'rules', 'references' and 'blacklist' members.
|
# the 'referenced', 'rules', 'references' and 'blacklist' members.
|
||||||
#
|
#
|
||||||
|
@ -1406,29 +1406,17 @@ sub handle_stickiness( $ ) {
|
|||||||
|
|
||||||
for my $chainref ( $stickyref, $setstickyref ) {
|
for my $chainref ( $stickyref, $setstickyref ) {
|
||||||
if ( $chainref->{name} eq 'sticky' ) {
|
if ( $chainref->{name} eq 'sticky' ) {
|
||||||
$rule1 = {};
|
$rule1 = clone_rule( $_ );
|
||||||
|
|
||||||
while ( my ( $key, $value ) = each %$_ ) {
|
|
||||||
$rule1->{$key} = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_rule_target( $rule1, 'MARK', "--set-mark $mark" );
|
set_rule_target( $rule1, 'MARK', "--set-mark $mark" );
|
||||||
set_rule_option( $rule1, 'recent', "--name $list --update --seconds 300" );
|
set_rule_option( $rule1, 'recent', "--name $list --update --seconds 300" );
|
||||||
|
|
||||||
$rule2 = {};
|
$rule2 = clone_rule( $_ );
|
||||||
|
|
||||||
while ( my ( $key, $value ) = each %$_ ) {
|
|
||||||
$rule2->{$key} = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
clear_rule_target( $rule2 );
|
clear_rule_target( $rule2 );
|
||||||
set_rule_option( $rule2, 'mark', "--mark 0/$mask -m recent --name $list --remove" );
|
set_rule_option( $rule2, 'mark', "--mark 0/$mask -m recent --name $list --remove" );
|
||||||
} else {
|
} else {
|
||||||
$rule1 = {};
|
$rule1 = clone_rule( $_ );
|
||||||
|
|
||||||
while ( my ( $key, $value ) = each %$_ ) {
|
|
||||||
$rule1->{$key} = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
clear_rule_target( $rule1 );
|
clear_rule_target( $rule1 );
|
||||||
set_rule_option( $rule1, 'mark', "--mark $mark\/$mask -m recent --name $list --set" );
|
set_rule_option( $rule1, 'mark', "--mark $mark\/$mask -m recent --name $list --set" );
|
||||||
|
Loading…
Reference in New Issue
Block a user