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

tags/0.1.2_el5 0.1.2_el5
Daniel Berteaud 11 years ago
parent 093957117d
commit 8c158ec422
  1. 18
      root/sbin/e-smith/smeserver-fail2ban

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

Loading…
Cancel
Save