From b085388cda28012a1a63da9c3c94225b399ac6a8 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Sun, 1 Dec 2013 03:45:12 -0500 Subject: [PATCH] TcpServer: optimize DNS lookups for PTR a. don't use search path (/etc/resolv.conf) b. explicitely specify PTR in query request --- lib/Qpsmtpd/TcpServer.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Qpsmtpd/TcpServer.pm b/lib/Qpsmtpd/TcpServer.pm index 8641576..5651aa4 100644 --- a/lib/Qpsmtpd/TcpServer.pm +++ b/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() {