Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: dizzy [...] wurley.net
Cc:
AdminCc:

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



Subject: Problem with AUTHORITY records?
Hi, I'm having trouble getting data out of an AUTHORITY section, when there is no ANSWER section. (And it seems that the arcount is the same as ancount, when there are ANSWER records.) Am I doing something wrong? For example: I am querying a COM.AU DNS Server for centralkitchens.com.au, which gives me the following: ;; query(centralkitchens.com.au, NS, IN) ;; send_udp(210.8.15.253:53) ;; answer from 210.8.15.253:53 : 113 bytes ;; HEADER SECTION ;; id = 24503 ;; qr = 1 opcode = QUERY aa = 0 tc = 0 rd = 1 ;; ra = 0 ad = 0 cd = 0 rcode = NOERROR ;; qdcount = 1 ancount = 0 nscount = 3 arcount = 0 ;; QUESTION SECTION (1 record) ;; centralkitchens.com.au. IN NS ;; ANSWER SECTION (0 records) ;; AUTHORITY SECTION (3 records) centralkitchens.com.au. 86400 IN NS lnk.maets.com. centralkitchens.com.au. 86400 IN NS lnk.wurley.net. centralkitchens.com.au. 86400 IN NS dsl.wurley.net. ;; ADDITIONAL SECTION (0 records) My $query->header->arcount complains "Cant call method on undefined value." And $query->authority is undef. If I query a root COM.AU server which returns the following result: ;; query(com.au, NS, IN) ;; send_udp(10.1.3.65:53) ;; answer from 10.1.3.65:53 : 357 bytes ;; HEADER SECTION ;; id = 23973 ;; qr = 1 opcode = QUERY aa = 0 tc = 0 rd = 1 ;; ra = 1 ad = 0 cd = 0 rcode = NOERROR ;; qdcount = 1 ancount = 8 nscount = 0 arcount = 8 ;; QUESTION SECTION (1 record) ;; com.au. IN NS ;; ANSWER SECTION (8 records) com.au. 69442 IN NS ns3.melbourneit.com. com.au. 69442 IN NS ns4.ausregistry.net. com.au. 69442 IN NS dns1.telstra.net. com.au. 69442 IN NS dmssyd.nsw.cmis.csiro.au. com.au. 69442 IN NS ns.ripe.net. com.au. 69442 IN NS ns1.ausregistry.net. com.au. 69442 IN NS ns2.ausregistry.net. com.au. 69442 IN NS ns3.ausregistry.net. ;; AUTHORITY SECTION (0 records) ;; ADDITIONAL SECTION (8 records) ns.ripe.net. 169647 IN A 193.0.0.193 ns1.ausregistry.net. 113504 IN A 203.18.56.41 ns2.ausregistry.net. 113504 IN A 203.18.56.42 ns3.ausregistry.net. 113504 IN A 203.18.56.43 ns3.melbourneit.com. 27105 IN A 203.27.227.10 ns4.ausregistry.net. 113504 IN A 210.8.15.253 dns1.telstra.net. 862 IN A 203.50.5.200 dmssyd.nsw.cmis.csiro.au. 243265 IN A 130.155.16.1 Then, header->arcount = 8 and header->ancount = 8 ?? Is the authority records and answer records being confused somewhere? How can I find out the AUTHORITY results and there are no ANSWER results? (I'm using this in my code: foreach $rr ($gQuery->authority) { print "Working AUTHORITY record [".$rr->type."] [".$rr->nsdname."]\n"; next unless $rr->type eq "NS"; push (@lResults, $rr->nsdname); } Which never prints anything.)
From: "Deon George" <dizzy [...] wurley.net>
To: <bug-Net-DNS [...] rt.cpan.org>
Subject: RE: [cpan #1616] AutoReply: Problem with AUTHORITY records?
Date: Sun, 6 Oct 2002 00:35:56 +1000
Ohh.. Forgot to add. Here is my perl -V: Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=linux, osvers=2.4.17-0.13smp, archname=i386-linux uname='linux daffy.perf.redhat.com 2.4.17-0.13smp #1 smp fri feb 1 10:30:48 est 2002 i686 unknown ' config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dcccdlflags=-fPIC -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-l inux -Dvendorprefix=/usr -Dsiteprefix=/usr -Uusethreads -Uuseithreads -Uusel argefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Di_ndbm -Di_gdbm -Di_shadow -D i_syslog -Dman3ext=3pm' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include', optimize='-O2 -march=i386 -mcpu=i686', cppflags='-fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.2 2.96-109)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil libc=/lib/libc-2.2.5.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: Built under linux Compiled at Apr 1 2002 12:23:22 @INC: /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.6.1/i386-linux /usr/lib/perl5/vendor_perl/5.6.1 /usr/lib/perl5/vendor_perl .
From: "Deon George" <dizzy [...] wurley.net>
To: <bug-Net-DNS [...] rt.cpan.org>
Subject: [cpan #1616] Fixed my problem, and here is a patch if you are interested.
Date: Sun, 6 Oct 2002 09:35:28 +1000
OK - I was confused before with the arcount and ancount... They appear to be set to the correct values. What I have noticed is that the query is undef, unless you get an ANSWER. Unfortunatly, the COM.AU DNS servers dont return answer records when you query for NS records, and the records are not in the .COM.AU domain. (Which is probably a good thing - but anyway...) So, I've patched Resolver.pm so that it will return a query object if it has ANSWER or AUTHORITY results - which gets me what I want... The patch is below, if you are interested... Is there a reason why you would discard the AUTHORITY records if your query doesnt return any ANSWER? Is there another way of getting the AUTHORITY information (that I should be doing, instead of this patch?) Lemme know! Here is the patch: --- Resolver.pm.orig Wed Oct 2 16:02:37 2002 +++ Resolver.pm Sun Oct 6 09:30:13 2002 @@ -523,7 +523,7 @@ if (index($name, '.') >= 0) { print ";; search($name, $type, $class)\n" if $self->{'debug'}; $ans = $self->query($name, $type, $class); - return $ans if (defined $ans) && ($ans->header->ancount > 0); + return $ans if (defined $ans) && (($ans->header->ancount > 0) || ($ans->header->nscount > 0)); } # If the name doesn't end in a dot then apply the search list. @@ -533,7 +533,7 @@ print ";; search($newname, $type, $class)\n" if $self->{'debug'}; $ans = $self->query($newname, $type, $class); - return $ans if (defined $ans) && ($ans->header->ancount > 0); + return $ans if (defined $ans) && (($ans->header->ancount > 0) || ($ans->header->nscount > 0)); } } @@ -541,7 +541,7 @@ if (index($name, '.') < 0) { print ";; search($name, $type, $class)\n" if $self->{'debug'}; $ans = $self->query("$name.", $type, $class); - return $ans if (defined $ans) && ($ans->header->ancount > 0); + return $ans if (defined $ans) && (($ans->header->ancount > 0) || ($ans->header->nscount > 0)); } # No answer was found. @@ -595,7 +595,7 @@ my $ans = $self->send($packet); - return (defined($ans) && ($ans->header->ancount > 0)) ? $ans : undef; + return (defined($ans) && (($ans->header->ancount > 0) || ($ans->header->nscount > 0))) ? $ans : undef; } ...deon Wurley Solutions --- _--_|\ | Deon George <dizzy@wurley.net> / \ | \_.--.*/ | v | This email coming to you from the 'burbs of Melbourne, Australia.
[dizzy@wurley.net - Sat Oct 5 19:35:38 2002]: Show quoted text
> OK - I was confused before with the arcount and ancount... They appear to be > set to the correct values. > > What I have noticed is that the query is undef, unless you get an ANSWER. > Unfortunatly, the COM.AU DNS servers dont return answer records when you > query for NS records, and the records are not in the .COM.AU domain. (Which > is probably a good thing - but anyway...)
If you need the answer object even when the answer section is empty, you should use Net::DNS::Resolver::send(). This always returns the answer (as long as it got an answer that is). Show quoted text
> So, I've patched Resolver.pm so that it will return a query object if it has > ANSWER or AUTHORITY results - which gets me what I want... The patch is > below, if you are interested...
The patch will break exsisting code, where people are expecting query to return undef if no answers were found. Show quoted text
> Is there a reason why you would discard the AUTHORITY records if your > query doesnt return any ANSWER? Is there another way of getting the > AUTHORITY information (that I should be doing, instead of this patch?)
It is the traditional way that C function res_query() from libresolv behaves. Net::DNS's query function is modeled after that behavoir. See my above comments about send() for getting around this. -- Chris Reinhardt ctriv@dyndns.org Systems Architect Dynamic DNS Network Services http://www.dyndns.org/