Browse files

TcpServer: optimize DNS lookups for PTR

a. don't use search path (/etc/resolv.conf)
b. explicitely specify PTR in query request
  • Loading branch information...
1 parent 6b4b714 commit ddb613f173c6226a9e537c35ddb23f11489ac50e @msimerson msimerson committed Dec 1, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/Qpsmtpd/TcpServer.pm
View
8 lib/Qpsmtpd/TcpServer.pm
@@ -191,18 +191,18 @@ sub tcpenv {
return ($TCPLOCALIP, $TCPREMOTEIP,
$TCPREMOTEIP ? "[$ENV{TCPREMOTEIP}]" : "[noip!]");
}
- my $res = new Net::DNS::Resolver;
+ my $res = Net::DNS::Resolver->new( dnsrch => 0 );
$res->tcp_timeout(3);
$res->udp_timeout(3);
- my $query = $res->query($nto_iaddr);
+ my $query = $res->query($nto_iaddr, 'PTR');
my $TCPREMOTEHOST;
if ($query) {
foreach my $rr ($query->answer) {
- next unless $rr->type eq "PTR";
+ next if $rr->type ne 'PTR';
$TCPREMOTEHOST = $rr->ptrdname;
}
}
- return ($TCPLOCALIP, $TCPREMOTEIP, $TCPREMOTEHOST || "Unknown");
+ return ($TCPLOCALIP, $TCPREMOTEIP, $TCPREMOTEHOST || 'Unknown');
}
sub check_socket() {

0 comments on commit ddb613f

Please sign in to comment.