fcrdns: document the is_valid_localhost skip

with a logdebug line
This commit is contained in:
Matt Simerson 2015-01-04 02:48:01 -05:00
parent 07fad0ffd0
commit 4226dfaa3e
2 changed files with 6 additions and 6 deletions

View File

@ -165,13 +165,15 @@ sub is_valid_localhost {
if ($self->is_localhost($self->qp->connection->remote_ip)) {
$self->adjust_karma(1);
$self->log(LOGDEBUG, "pass, is localhost");
$self->log(LOGINFO, "pass, is localhost");
return 1;
}
my $rh = $self->qp->connection->remote_host;
return 0 if ! $rh;
return 0 if lc $self->qp->connection->remote_host ne 'localhost';
if (! $rh || lc $self->qp->connection->remote_host ne 'localhost') {
$self->log(LOGDEBUG, "skip, not pretending to be localhost");
return 1;
}
$self->adjust_karma(-1);
$self->log(LOGINFO, "fail, not localhost");

View File

@ -26,20 +26,18 @@ sub _is_valid_localhost {
cmp_ok( $self->is_valid_localhost(), '==', 1, "$pass, true");
}
$self->qp->connection->remote_host('localhost');
foreach my $fail (@fails) {
$self->qp->connection->remote_ip($fail);
cmp_ok( $self->is_valid_localhost(), '==', 0, "$fail, false");
}
$self->qp->connection->remote_host('localhost');
cmp_ok( $self->is_valid_localhost(), '==', 0, "localhost, non-loopback IP, false");
$self->qp->connection->remote_ip('127.0.0.1');
$self->qp->connection->remote_host('localhost');
cmp_ok( $self->is_valid_localhost(), '==', 1, "localhost, loop IP, true");
$self->qp->connection->remote_ip('::1');
$self->qp->connection->remote_host('localhost');
cmp_ok( $self->is_valid_localhost(), '==', 1, "localhost, IPv6 loop, true");
}