karma,relay: karma plugin awards karma later

by detecting during DATA if relay_client is set
This commit is contained in:
Matt Simerson 2013-03-28 17:30:25 -04:00
parent ce0d2b80ef
commit 6b16704b4a
2 changed files with 9 additions and 1 deletions

View File

@ -243,6 +243,7 @@ sub register {
}; };
#$self->prune_db(); # keep the DB compact #$self->prune_db(); # keep the DB compact
$self->register_hook('connect', 'connect_handler'); $self->register_hook('connect', 'connect_handler');
$self->register_hook('data', 'data_handler' );
$self->register_hook('disconnect', 'disconnect_handler'); $self->register_hook('disconnect', 'disconnect_handler');
} }
@ -316,6 +317,14 @@ sub connect_handler {
return $self->get_reject( $mess, $karma ); return $self->get_reject( $mess, $karma );
} }
sub data_handler {
my ($self, $transaction) = @_;
return DECLINED if ! $self->qp->connection->relay_client;
$self->adjust_karma( 5 ); # big karma boost for authenticated user/IP
return DECLINED;
};
sub disconnect_handler { sub disconnect_handler {
my $self = shift; my $self = shift;

View File

@ -241,7 +241,6 @@ sub hook_connect {
# 95586 (connect) relay: pass, octet match in relayclients (127.0.0.) # 95586 (connect) relay: pass, octet match in relayclients (127.0.0.)
if ( $self->is_in_cidr_block() || $self->is_octet_match() ) { if ( $self->is_in_cidr_block() || $self->is_octet_match() ) {
$self->adjust_karma( 2 ); # big karma boost!
$self->qp->connection->relay_client(1); $self->qp->connection->relay_client(1);
return (DECLINED); return (DECLINED);
}; };