karma: added adjust_karma method

makes it easier to set karma in plugins
This commit is contained in:
Matt Simerson 2012-06-30 15:37:25 -04:00
parent 672a034fb0
commit 01d7c7e228
4 changed files with 7 additions and 14 deletions

View File

@ -285,7 +285,7 @@ sub is_immune {
sub adjust_karma {
my ( $self, $value ) = @_;
my $karma = $self->connection->notes('karma') || 0;
my $karma = $self->connection->notes('karma') || 0
$karma += $value;
$self->connection->notes('karma', $value);
return $value;

View File

@ -195,12 +195,12 @@ sub rcpt_handler {
$self->log(LOGINFO, "error, SHOULD NOT HAPPEN"), $k++ if $rv == 0xfe;
$self->log(LOGINFO, "fail, address not local"), $k++ if $rv == 0xff;
if ( $rv ) {
$self->log(LOGINFO, sprintf("error, unknown: 0x%02x", $rv)) if not $k;
return DECLINED;
};
$self->log(LOGINFO, sprintf("Unknown: 0x%02x", $rv)) if $rv and not $k;
return (DENY, "Sorry, no mailbox by that name. qd (#5.1.1)" );
return DECLINED if $rv;
$self->adjust_karma( -1 );
return (DENY, "fail, no mailbox by that name. qd (#5.1.1)" );
}
sub _smtproute {

View File

@ -413,7 +413,7 @@ sub reject {
}
}
$self->connection->notes('karma', ($self->connection->notes('karma') - 1));
$self->adjust_karma( -1 );
# default of media_unsupported is DENY, so just change the message
$self->log(LOGINFO, "fail, $status, > $reject, $learn");
return ($self->get_reject_type(), "spam score exceeded threshold");

View File

@ -94,12 +94,6 @@ automatically allow relaying from that IP.
=cut
use strict;
use warnings;
use lib 'lib';
use Qpsmtpd::Constants;
my $VERSION = 0.02;
# Default is to merge whitelists in per_recipient mode
@ -150,7 +144,6 @@ sub check_host {
return OK;
}
}
$self->log(LOGDEBUG, "skip: $ip is not whitelisted");
return DECLINED;
}