hosts_allow: allow +karma senders +3 concurrents

this is really useful if you set max-per-ip to <= 3.
This commit is contained in:
Matt Simerson 2013-03-23 01:47:34 -04:00
parent 6a41d1ea0d
commit 1dfa55c230

View File

@ -80,7 +80,7 @@ sub hook_pre_connection {
if ($num_conn > $max ) { if ($num_conn > $max ) {
my $err_mess = "too many connections from $remote"; my $err_mess = "too many connections from $remote";
$self->log(LOGINFO, "fail: $err_mess ($num_conn > $max)"); $self->log(LOGINFO, "fail: $err_mess ($num_conn > $max)");
return (DENYSOFT, "Sorry, $err_mess, try again later"); return (DENYSOFT, "$err_mess, try again later");
} }
} }
@ -118,8 +118,13 @@ sub in_hosts_allow {
sub karma_bump { sub karma_bump {
my ($self, $karma, $max) = @_; my ($self, $karma, $max) = @_;
if ( $karma > 5 ) {
$self->log(LOGDEBUG, "increasing max connects for positive karma");
return $max + 3;
};
if ( $karma <= 0 ) { if ( $karma <= 0 ) {
$self->log(LOGINFO, "limiting max connects to 1 for negative karma ($karma)"); $self->log(LOGINFO, "limiting max connects to 1 (karma $karma)");
return 1; return 1;
}; };
return $max; return $max;