Create the DB entry in one transaction to reduce the amount of logs for each ban
This commit is contained in:
parent
093957117d
commit
8c158ec422
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue