Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 45064
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: craig [...] alcatel-lucent.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.65
Fixed in: (no value)



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
From: rwfranks [...] acm.org
This is expected behaviour on all platforms (version 0.63+). $res->search() returns a NET::DNS::Packet object which is never used before your script terminates. The <answer> you expected is in the <binary buffer stuff removed>. Each section of the packet buffer is unpacked only when the appropriate method is invoked. The idea is to avoid wasting time unpacking data which is subsequently discarded without being used. Data::Dumper is only useful as a debugging tool for examining data structures. It does not understand anything about the object model. If you wish to see the contents of a Net::DNS::Packet object then you should use the print method. This is what happens if the debug flag is set. use Net::DNS; my $resolver = Net::DNS::Resolver->new; my $packet = $resolver->search( shift || 'example.com' ); $packet->print; --Dick
Dick- On Sat Apr 18 00:38:49 2009, rwfranks@acm.org wrote: Show quoted text
> This is expected behaviour on all platforms (version 0.63+).
Ah, thanks for setting me straight, I didn't realize this was a planned change. My other platforms must still be working with the older version. Also, thanks for a great module! -Craig