Ported to support Apache::Qpsmtpd
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@439 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
9ba9d68f72
commit
b906f67123
@ -62,12 +62,46 @@ sub register {
|
|||||||
'defer-reject' => 0,
|
'defer-reject' => 0,
|
||||||
@args,
|
@args,
|
||||||
};
|
};
|
||||||
|
if ($qp->{conn} && $qp->{conn}->isa('Apache2::Connection')) {
|
||||||
|
require APR::Const;
|
||||||
|
APR::Const->import(qw(POLLIN SUCCESS));
|
||||||
|
$self->register_hook('connect', 'apr_connect_handler');
|
||||||
|
}
|
||||||
|
else {
|
||||||
$self->register_hook('connect', 'connect_handler');
|
$self->register_hook('connect', 'connect_handler');
|
||||||
|
}
|
||||||
$self->register_hook('mail', 'mail_handler')
|
$self->register_hook('mail', 'mail_handler')
|
||||||
if $self->{_args}->{'defer-reject'};
|
if $self->{_args}->{'defer-reject'};
|
||||||
1;
|
1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub apr_connect_handler {
|
||||||
|
my ($self, $transaction) = @_;
|
||||||
|
|
||||||
|
return DECLINED if ($self->qp->connection->notes('whitelistclient'));
|
||||||
|
my $ip = $self->qp->connection->remote_ip;
|
||||||
|
|
||||||
|
my $c = $self->qp->{conn};
|
||||||
|
my $socket = $c->client_socket;
|
||||||
|
my $timeout = $self->{_args}->{'wait'} * 1_000_000;
|
||||||
|
|
||||||
|
my $rc = $socket->poll($c->pool, $timeout, APR::Const::POLLIN());
|
||||||
|
if ($rc == APR::Const::SUCCESS()) {
|
||||||
|
$self->log(LOGNOTICE, "remote host started talking before we said hello [$ip]");
|
||||||
|
if ($self->{_args}->{'defer-reject'}) {
|
||||||
|
$self->qp->connection->notes('earlytalker', 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
my $msg = 'Connecting host started transmitting before SMTP greeting';
|
||||||
|
return (DENY,$msg) if $self->{_args}->{'action'} eq 'deny';
|
||||||
|
return (DENYSOFT,$msg) if $self->{_args}->{'action'} eq 'denysoft';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$self->log(LOGINFO, "remote host said nothing spontaneous, proceeding");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub connect_handler {
|
sub connect_handler {
|
||||||
my ($self, $transaction) = @_;
|
my ($self, $transaction) = @_;
|
||||||
my $in = new IO::Select;
|
my $in = new IO::Select;
|
||||||
|
Loading…
Reference in New Issue
Block a user