spf: improved support for IPv6 clients
This commit is contained in:
parent
7b420252f0
commit
016d2b06bc
@ -4,3 +4,9 @@
|
|||||||
127.0.0.1
|
127.0.0.1
|
||||||
# leading/trailing whitespace is ignored
|
# leading/trailing whitespace is ignored
|
||||||
192.0.
|
192.0.
|
||||||
|
#
|
||||||
|
# IPv6 formats ends in a nibble (not a netmask, prefixlen, or colon)
|
||||||
|
# RFC 3849 example
|
||||||
|
2001:DB8
|
||||||
|
2001:DB8::1
|
||||||
|
2001:0DB8:0000:0000:0000:0000:0000:0001
|
||||||
|
@ -59,6 +59,8 @@ use warnings;
|
|||||||
#use Mail::SPF 2.000; # eval'ed in ->register
|
#use Mail::SPF 2.000; # eval'ed in ->register
|
||||||
use Qpsmtpd::Constants;
|
use Qpsmtpd::Constants;
|
||||||
|
|
||||||
|
use Net::IP;
|
||||||
|
|
||||||
sub register {
|
sub register {
|
||||||
my ($self, $qp, %args) = @_;
|
my ($self, $qp, %args) = @_;
|
||||||
eval 'use Mail::SPF';
|
eval 'use Mail::SPF';
|
||||||
@ -237,13 +239,27 @@ sub is_in_relayclients {
|
|||||||
my $more_relay_clients = $self->qp->config('morerelayclients', 'map');
|
my $more_relay_clients = $self->qp->config('morerelayclients', 'map');
|
||||||
my %relay_clients = map { $_ => 1 } @relay_clients;
|
my %relay_clients = map { $_ => 1 } @relay_clients;
|
||||||
|
|
||||||
|
my $ipv6 = $client_ip =~ /:/ ? 1 : 0;
|
||||||
|
|
||||||
|
if ( $ipv6 && $client_ip =~ /::/ ) { # IPv6 compressed notation
|
||||||
|
$client_ip = Net::IP::ip_expand_address($client_ip,6);
|
||||||
|
};
|
||||||
|
|
||||||
while ($client_ip) {
|
while ($client_ip) {
|
||||||
if ( exists $relay_clients{$client_ip} ||
|
if ( exists $relay_clients{$client_ip} ||
|
||||||
exists $more_relay_clients->{$client_ip} ) {
|
exists $more_relay_clients->{$client_ip} ) {
|
||||||
$self->log( LOGDEBUG, "skip, IP in relayclients" );
|
$self->log( LOGDEBUG, "skip, IP in relayclients" );
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
$client_ip =~ s/\d+\.?$// or last; # strip off another 8 bits
|
|
||||||
|
# added IPv6 support (Michael Holzt - 2012-11-14)
|
||||||
|
if ( $ipv6 ) {
|
||||||
|
$client_ip =~ s/[0-9a-f]:*$//; # strip off another nibble
|
||||||
|
chop $client_ip if ':' eq substr($client_ip, -1, 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$client_ip =~ s/\d+\.?$// or last; # strip off another 8 bits
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user