Create the DB entry in one transaction to reduce the amount of logs for each ban

This commit is contained in:
Daniel Berteaud 2013-11-19 11:48:21 +01:00
parent 093957117d
commit 8c158ec422
1 changed files with 9 additions and 9 deletions

View File

@ -114,16 +114,16 @@ if ($opts{unban}){
}
else{
my $id = generate_uniq_id();
$f2bdb->new_record($id, {type => 'ban'});
$f2bdb->set_prop($id, 'Host', $opts{host});
$f2bdb->set_prop($id, 'Protocol', $opts{proto})
my %props;
$props{'type'} = 'ban';
$props{'Host'} = $opts{host};
$props{'Protocol'} = $opts{proto}
if ($opts{proto});
$f2bdb->set_prop($id, 'Port', $opts{port})
if ($opts{port});
# Set the current timestamp
$f2bdb->set_prop($id, 'BanTimestamp', time());
# Set the timestamp of the unban
$f2bdb->set_prop($id, 'UnbanTimestamp', time()+$opts{bantime});
$props{'Port'} = $opts{proto}
if ($opts{proto});
$props{'BanTimestamp'} = time();
$props{'UnbanTimestamp'} = time()+$opts{bantime};
$f2bdb->new_record($id, \%props);
}
die "An error occured while updating the firewall rules"