Subject: | Net::DNS::Resolver only populates $res->{answer} if debug=>1 on Win32 platform |
Take a standard PC running Windows XP, download & install ActivePerl
5.8.9.825, and use ppm to install Net::DNS. Then run the following
test program:
use strict;
use warnings;
use Data::Dumper;
use Net::DNS;
my $host = shift || 'www.google.com';
my $res = Net::DNS::Resolver->new;
my $ret = $res->search($host);
print "Resolver state: ", $res->print, "\n";
print "Status String: ", $res->errorstring, "\n";
print "res DUMP:\n", Dumper($ret), "\n";
Here is the output that I get:
;; RESOLVER state:
;; domain = mydomain.com
;; searchlist = mydomain.com myotherdomain.com
;; nameservers = 1.1.1.111 1.1.1.110
;; port = 53
;; srcport = 0
;; srcaddr = 0.0.0.0
;; tcp_timeout = 120
;; retrans = 5 retry = 4
;; usevc = 0 stayopen = 0 igntc = 0
;; defnames = 1 dnsrch = 1
;; recurse = 1 debug = 0
;; force_v4 = 0 (IPv6 Transport is not available)
Resolver state: 1
Status String: NOERROR
res DUMP:
$VAR1 = bless( {
'answer' => [],
'buffer' => <binary buffer stuff removed>
'question' => [
bless( {
'qclass' => 'IN',
'qname' => 'www.google.com',
'qtype' => 'A'
}, 'Net::DNS::Question' )
],
'answerfrom' => '135.1.1.111',
'answersize' => 116,
'additional' => [],
'authority' => [],
'header' => bless( {
'nscount' => 0,
'cd' => 0,
'qdcount' => 1,
'ancount' => 5,
'rcode' => 'NOERROR',
'tc' => 0,
'opcode' => 'QUERY',
'ad' => 0,
'ra' => 1,
'qr' => 1,
'arcount' => 0,
'id' => 13037,
'aa' => 0,
'rd' => 1
}, 'Net::DNS::Header' ),
'offset' => 32
}, 'Net::DNS::Packet' );
Notice that there is nothing in the $res->{answer} array, even though
we did get a valid answer from the query. The same code works fine on
Unix platforms (MacOS, Solaris are the 2 I've tried).
Now, turn on debugging in this test program, by modifying the "new"
line to look like this:
my $res = Net::DNS::Resolver->new(debug=>1);
Then rerun the newly modified test program, and you will get $res->
{answer} populated.
I played around in the Net::DNS modules a bit, and discovered that
running ANY of these map commands from Packet.pm (sub string), seems
to cause $res->{answer} to get populated:
365 my @answer = map{$_->string} $self->answer;
372 my @authority = map{$_->string} $self->authority;
378 my @additional = map{$_->string} $self->additional;
That's as far as I got.
I think my current plan will be to run it in debugging mode until a
better resolution comes along.
Thanks
-Craig