helo: smite senders that fail the selected tests

and made log entries more terse
This commit is contained in:
Matt Simerson 2013-03-23 01:43:32 -04:00
parent b43f369dbe
commit 7a4c789ae2

View File

@ -256,7 +256,10 @@ sub helo_handler {
foreach my $test ( @{ $self->{_helo_tests} } ) { foreach my $test ( @{ $self->{_helo_tests} } ) {
my @err = $self->$test( $host ); my @err = $self->$test( $host );
return $self->get_reject( @err ) if scalar @err; if ( scalar @err ) {
$self->adjust_karma( -1 );
return $self->get_reject( @err );
};
}; };
$self->log(LOGINFO, "pass"); $self->log(LOGINFO, "pass");
@ -389,6 +392,8 @@ sub is_not_fqdn {
sub no_forward_dns { sub no_forward_dns {
my ( $self, $host ) = @_; my ( $self, $host ) = @_;
return if $self->is_address_literal( $host );
my $res = $self->init_resolver(); my $res = $self->init_resolver();
$host = "$host." if $host !~ /\.$/; # fully qualify name $host = "$host." if $host !~ /\.$/; # fully qualify name
@ -396,7 +401,7 @@ sub no_forward_dns {
if (! $query) { if (! $query) {
if ( $res->errorstring eq 'NXDOMAIN' ) { if ( $res->errorstring eq 'NXDOMAIN' ) {
return ("HELO hostname does not exist", "HELO hostname does not exist"); return ("HELO hostname does not exist", "no such host");
} }
$self->log(LOGERROR, "skip, query failed (", $res->errorstring, ")" ); $self->log(LOGERROR, "skip, query failed (", $res->errorstring, ")" );
return; return;
@ -411,7 +416,7 @@ sub no_forward_dns {
$self->log(LOGDEBUG, "pass, forward DNS") if $hits; $self->log(LOGDEBUG, "pass, forward DNS") if $hits;
return; return;
}; };
return ("helo hostname did not resolve", "fail, HELO forward DNS"); return ("HELO hostname did not resolve", "no forward DNS");
}; };
sub no_reverse_dns { sub no_reverse_dns {
@ -451,7 +456,7 @@ sub no_matching_dns {
if ( $self->connection->notes('helo_forward_match') && if ( $self->connection->notes('helo_forward_match') &&
$self->connection->notes('helo_reverse_match') ) { $self->connection->notes('helo_reverse_match') ) {
$self->log( LOGDEBUG, "foward and reverse match" ); $self->log( LOGDEBUG, "foward and reverse match" );
$self->adjust_karma( 1 ); # whoppee, a match! $self->adjust_karma( 1 ); # a perfect match
return; return;
}; };
@ -465,7 +470,7 @@ sub no_matching_dns {
}; };
$self->log( LOGINFO, "fail, no forward or reverse DNS match" ); $self->log( LOGINFO, "fail, no forward or reverse DNS match" );
return ("That HELO hostname fails forward and reverse DNS checks", "no matching DNS"); return ("That HELO hostname fails FCrDNS", "no matching DNS");
}; };
sub check_ip_match { sub check_ip_match {