karma: added adjust_karma method
makes it easier to set karma in plugins
This commit is contained in:
parent
672a034fb0
commit
01d7c7e228
@ -285,7 +285,7 @@ sub is_immune {
|
|||||||
sub adjust_karma {
|
sub adjust_karma {
|
||||||
my ( $self, $value ) = @_;
|
my ( $self, $value ) = @_;
|
||||||
|
|
||||||
my $karma = $self->connection->notes('karma') || 0;
|
my $karma = $self->connection->notes('karma') || 0
|
||||||
$karma += $value;
|
$karma += $value;
|
||||||
$self->connection->notes('karma', $value);
|
$self->connection->notes('karma', $value);
|
||||||
return $value;
|
return $value;
|
||||||
|
@ -195,12 +195,12 @@ sub rcpt_handler {
|
|||||||
$self->log(LOGINFO, "error, SHOULD NOT HAPPEN"), $k++ if $rv == 0xfe;
|
$self->log(LOGINFO, "error, SHOULD NOT HAPPEN"), $k++ if $rv == 0xfe;
|
||||||
$self->log(LOGINFO, "fail, address not local"), $k++ if $rv == 0xff;
|
$self->log(LOGINFO, "fail, address not local"), $k++ if $rv == 0xff;
|
||||||
|
|
||||||
if ( $rv ) {
|
$self->log(LOGINFO, sprintf("Unknown: 0x%02x", $rv)) if $rv and not $k;
|
||||||
$self->log(LOGINFO, sprintf("error, unknown: 0x%02x", $rv)) if not $k;
|
|
||||||
return DECLINED;
|
|
||||||
};
|
|
||||||
|
|
||||||
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 {
|
sub _smtproute {
|
||||||
|
@ -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
|
# default of media_unsupported is DENY, so just change the message
|
||||||
$self->log(LOGINFO, "fail, $status, > $reject, $learn");
|
$self->log(LOGINFO, "fail, $status, > $reject, $learn");
|
||||||
return ($self->get_reject_type(), "spam score exceeded threshold");
|
return ($self->get_reject_type(), "spam score exceeded threshold");
|
||||||
|
@ -94,12 +94,6 @@ automatically allow relaying from that IP.
|
|||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
|
|
||||||
use lib 'lib';
|
|
||||||
use Qpsmtpd::Constants;
|
|
||||||
|
|
||||||
my $VERSION = 0.02;
|
my $VERSION = 0.02;
|
||||||
|
|
||||||
# Default is to merge whitelists in per_recipient mode
|
# Default is to merge whitelists in per_recipient mode
|
||||||
@ -150,7 +144,6 @@ sub check_host {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$self->log(LOGDEBUG, "skip: $ip is not whitelisted");
|
|
||||||
return DECLINED;
|
return DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user