Skip to content

Commit

Permalink
Ported to support Apache::Qpsmtpd
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@439 958fd67b-6ff1-0310-b445-bb7760255be9
  • Loading branch information
Matt Sergeant committed Jun 20, 2005
1 parent 9ba9d68 commit b906f67
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion plugins/check_earlytalker
Expand Up @@ -62,12 +62,46 @@ sub register {
'defer-reject' => 0,
@args,
};
$self->register_hook('connect', 'connect_handler');
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('mail', 'mail_handler')
if $self->{_args}->{'defer-reject'};
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 {
my ($self, $transaction) = @_;
my $in = new IO::Select;
Expand Down

0 comments on commit b906f67

Please sign in to comment.