Skip Menu |

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

Report information
The Basics
Id: 71544
Status: resolved
Worked: 30 min
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: sunguonian [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.66
Fixed in: (no value)



Sorry if I misuse the Net::DNS. I wrote a dig script with Net::DNS::Resolver->query(), it works when debug=1, but when debug=0, it don't work. the same result if I change query() to send(). digsoa.pl =========== x ========== #!/usr/bin/perl require 5.002; use strict; use Carp; use Net::DNS; use Data::Dumper; my($soa); digsoa('203.119.25.1', 53, 'cn', \$soa); print "$soa\n"; sub digsoa { my($server, $port, $domain, $rsoa) = @_; print STDERR "($server, $port, $domain, $rsoa)\n"; my($res) = Net::DNS::Resolver->new( nameservers => [ $server ], port => $port, recurse => 0, debug => 0, ); my($packet); $res->udp_timeout(9); $res->retrans(3); $res->retry(2); $packet = $res->query($domain, 'SOA'); if(defined($packet)) { print STDERR Data::Dumper->Dump([$packet]); $$rsoa = $packet->{'answer'}->[0]->{'serial'}; return 1; }; return 0; } =========== x ========== when I add some lines on Packet.pm, # diff -c Packet.pm_00 Packet.pm *** Packet.pm_00 2009-12-30 19:01:39.000000000 +0800 --- Packet.pm 2011-10-08 20:13:41.000000000 +0800 *************** *** 122,127 **** --- 122,132 ---- ($self || die $@)->print if $debug; + #$self->question; + $self->answer; + $self->authority; + $self->additional; + return wantarray ? ($self, $@) : $self; } it works whether I set debug to 0 or 1. # perl -v This is perl, v5.8.8 built for x86_64-linux-thread-multi Copyright 1987-2006, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. # uname -a Linux oldtest09.knet.cn 2.6.18-274.3.1.el5 #1 SMP Tue Sep 6 20:13:52 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux # cat /etc/redhat-release CentOS release 5.7 (Final)
Subject: Resolvers without the debug flag
Hi Sunguonian, I wouldn't say misuse :), but you don't use the library how it is intended (and documented). If you get the answer list via the answer method (in stead of directly accessing the internal hash key), your script works fine: --- digsoa_orig.pl 2011-10-18 14:59:08.226636095 +0200 +++ digsoa.pl 2011-10-18 14:58:37.938485949 +0200 @@ -27,8 +27,8 @@ $res->retry(2); $packet = $res->query($domain, 'SOA'); if(defined($packet)) { + $$rsoa = ($packet->answer)[0]->serial; print STDERR Data::Dumper->Dump([$packet]); - $$rsoa = $packet->{'answer'}->[0]->{'serial'}; return 1; }; return 0; Cheers, -- Willem