helo: added IPv6 support to invalid_localhost
and also suppress a test warning
This commit is contained in:
parent
40783dbe87
commit
39c454c95e
13
plugins/helo
13
plugins/helo
@ -340,13 +340,14 @@ sub is_regex_match {
|
||||
sub invalid_localhost {
|
||||
my ($self, $host) = @_;
|
||||
return if lc $host ne 'localhost';
|
||||
if ($self->qp->connection->remote_ip ne '127.0.0.1') {
|
||||
|
||||
#$self->log( LOGINFO, "fail, not localhost" );
|
||||
return ("You are not localhost", "invalid localhost");
|
||||
my $ip = $self->qp->connection->remote_ip;
|
||||
if ($ip && ($ip eq '127.0.0.1' || $ip eq '::1')) {
|
||||
$self->log(LOGDEBUG, "pass, is localhost");
|
||||
return;
|
||||
}
|
||||
$self->log(LOGDEBUG, "pass, is localhost");
|
||||
return;
|
||||
|
||||
#$self->log( LOGINFO, "fail, not localhost" );
|
||||
return ("You are not localhost", "invalid localhost");
|
||||
}
|
||||
|
||||
sub is_plain_ip {
|
||||
|
@ -11,7 +11,7 @@ sub register_tests {
|
||||
$self->register_test('test_init_resolver', 2);
|
||||
$self->register_test('test_is_in_badhelo', 2);
|
||||
$self->register_test('test_is_regex_match', 3);
|
||||
$self->register_test('test_invalid_localhost', 4);
|
||||
$self->register_test('test_invalid_localhost', 5);
|
||||
$self->register_test('test_is_plain_ip', 3);
|
||||
$self->register_test('test_is_address_literal', 3);
|
||||
$self->register_test('test_no_forward_dns', 2);
|
||||
@ -73,9 +73,11 @@ sub test_invalid_localhost {
|
||||
($err, $why) = $self->invalid_localhost('localhost');
|
||||
ok( $err, "localhost, invalid remote IP: $why");
|
||||
|
||||
$self->qp->connection->remote_ip('127.0.0.1');
|
||||
($err, $why) = $self->invalid_localhost('localhost');
|
||||
ok( ! $err, "localhost, correct remote IP");
|
||||
foreach my $ip (qw/ ::1 127.0.0.1 / ) {
|
||||
$self->qp->connection->remote_ip($ip);
|
||||
($err, $why) = $self->invalid_localhost('localhost');
|
||||
ok( ! $err, "localhost, correct remote IP ($ip)");
|
||||
}
|
||||
};
|
||||
|
||||
sub test_is_plain_ip {
|
||||
|
Loading…
Reference in New Issue
Block a user