TcpServer: optimize DNS lookups for PTR

a. don't use search path (/etc/resolv.conf)
b. explicitely specify PTR in query request
This commit is contained in:
Matt Simerson 2013-12-01 03:45:12 -05:00
parent 6b4b714c2a
commit ddb613f173

View File

@ -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() {