earlytalker: updated for consistent note accessor

This commit is contained in:
Matt Simerson 2012-06-23 00:37:54 -04:00
parent 12b4c6a02a
commit fb4690ab43

View File

@ -131,7 +131,7 @@ sub apr_connect_handler {
my $rc = $socket->poll($c->pool, $timeout, APR::Const::POLLIN()); my $rc = $socket->poll($c->pool, $timeout, APR::Const::POLLIN());
if ($rc == APR::Const::SUCCESS()) { if ($rc == APR::Const::SUCCESS()) {
if ($self->{_args}{'defer-reject'}) { if ($self->{_args}{'defer-reject'}) {
$self->qp->connection->notes('earlytalker', 1); $self->connection->notes('earlytalker', 1);
return DECLINED; return DECLINED;
}; };
return $self->log_and_deny(); return $self->log_and_deny();
@ -172,7 +172,8 @@ sub connect_handler {
return $self->log_and_deny(); return $self->log_and_deny();
}; };
$self->qp->connection->notes('earlytalker', 1); $self->connection->notes('earlytalker', 1);
$self->connection->notes('karma', -1);
return DECLINED; return DECLINED;
} }
@ -194,7 +195,7 @@ sub data_handler {
sub log_and_pass { sub log_and_pass {
my $self = shift; my $self = shift;
my $ip = $self->qp->connection->remote_ip || 'remote host'; my $ip = $self->qp->connection->remote_ip || 'remote host';
$self->log(LOGINFO, "pass: $ip said nothing spontaneous"); $self->log(LOGINFO, "pass, $ip said nothing spontaneous");
return DECLINED; return DECLINED;
} }
@ -202,27 +203,19 @@ sub log_and_deny {
my $self = shift; my $self = shift;
my $ip = $self->qp->connection->remote_ip || 'remote host'; my $ip = $self->qp->connection->remote_ip || 'remote host';
my $msg = 'Connecting host started transmitting before SMTP greeting';
$self->qp->connection->notes('earlytalker', 1); $self->connection->notes('earlytalker', 1);
$self->log(LOGNOTICE, "fail: $ip started talking before we said hello");
return ( $self->get_reject_type(), $msg ) if $self->{_args}{reject}; my $log_mess = "fail, $ip started talking before we said hello";
return DECLINED; my $smtp_msg = 'Connecting host started transmitting before SMTP greeting';
return $self->get_reject( $smtp_msg, $log_mess );
} }
sub mail_handler { sub mail_handler {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;
return DECLINED unless $self->qp->connection->notes('earlytalker'); return DECLINED unless $self->connection->notes('earlytalker');
return $self->log_and_deny(); return $self->log_and_deny();
} }
sub get_reject_type {
my $self = shift;
my $deny = $self->{_args}{reject_type} or return DENY;
return $deny eq 'temp' ? DENYSOFT
: $deny eq 'disconnect' ? DENY_DISCONNECT
: DENY;
};