naughty: support reject_type set by original plugin

that marked the connection as naughty
This commit is contained in:
Matt Simerson 2012-06-23 00:46:39 -04:00
parent 5dbc47ed1a
commit 4761e3f41a

View File

@ -88,7 +88,8 @@ from detecting address validity.
=head2 reject_type [ temp | perm | disconnect ]
What type of rejection should be sent? See docs/config.pod
If the plugin that set naughty didn't specify, what type of rejection should
be sent? See docs/config.pod
=head2 loglevel
@ -99,7 +100,7 @@ Adjust the quantity of logging for this plugin. See docs/logging.pod
Here's how to use naughty and get_reject in your plugin:
sub register {
my ($self,$qp) = shift, shift;
my ($self, $qp) = (shift, shift);
$self->{_args} = { @_ };
$self->{_args}{reject} ||= 'naughty';
};
@ -123,7 +124,7 @@ use warnings;
use Qpsmtpd::Constants;
sub register {
my ($self, $qp ) = shift, shift;
my ($self, $qp) = (shift, shift);
$self->log(LOGERROR, "Bad arguments") if @_ % 2;
$self->{_args} = { @_ };
$self->{_args}{reject} ||= 'rcpt';
@ -156,6 +157,8 @@ sub naughty {
return DECLINED;
};
$self->log(LOGINFO, "disconnecting");
return ( $self->get_reject_type(), $naughty );
my $type = $self->get_reject_type( 'disconnect',
$self->connection->notes('naughty_reject_type') );
return ( $type, $naughty );
};