From 4226dfaa3e67652f0622e7ca37276e92c1570445 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Sun, 4 Jan 2015 02:48:01 -0500 Subject: [PATCH] fcrdns: document the is_valid_localhost skip with a logdebug line --- plugins/fcrdns | 8 +++++--- t/plugin_tests/fcrdns | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/fcrdns b/plugins/fcrdns index f606a19..60f4c7a 100644 --- a/plugins/fcrdns +++ b/plugins/fcrdns @@ -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"); diff --git a/t/plugin_tests/fcrdns b/t/plugin_tests/fcrdns index acd655e..b014ba4 100644 --- a/t/plugin_tests/fcrdns +++ b/t/plugin_tests/fcrdns @@ -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"); }