Skip Menu |

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

Report information
The Basics
Id: 105915
Status: rejected
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: frnkblk [...] iname.com
Cc:
AdminCc:

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



Subject: Object is undefined on SERVFAIL even though debug displays it all
Date: Thu, 16 Jul 2015 23:57:29 -0500
To: <bug-Net-DNS [...] rt.cpan.org>
From: "Frank Bulk" <frnkblk [...] iname.com>
I'm a newbie with this module, but I discovered through trial and error that although the debug option spits out all the details about queries, including those with SERVFAIL, the header method can't be called against the returned packet object because the packet object is undefined on a SERVFAIL response. Although I can detect the SERVFAIL response using the errorstring method, the Net::DNS modules ought to return all the relevant objects regardless of success or not. Here's a code snipper where I'm testing that at incorrectly signed DNSSec zone correctly SERVFAILs when queried on a DNS server that has DNSSec validation turned on. my $reply; my $resolver = new Net::DNS::Resolver(); # Set options in the constructor $resolver = new Net::DNS::Resolver( nameservers => [ '10.20.0.5' ], recurse => 1, debug => 1 ); $resolver->dnssec(1); $reply = $resolver->query( 'sigfail.verteiltesysteme.net', 'A' ); if (defined($reply)) { $header = $reply->header; print "query response code = ", $header->rcode, "\n"; } else { print "undefined\n"; $header = $reply->header; }
From: rwfranks [...] acm.org
On Fri Jul 17 00:58:38 2015, frnkblk@iname.com wrote: Show quoted text
> I'm a newbie with this module, but I discovered through trial and error that > although the debug option spits out all the details about queries, including > those with SERVFAIL, the header method can't be called against the returned > packet object because the packet object is undefined on a SERVFAIL response. > > Although I can detect the SERVFAIL response using the errorstring method, > the Net::DNS modules ought to return all the relevant objects regardless of > success or not. > > Here's a code snipper where I'm testing that at incorrectly signed DNSSec > zone correctly SERVFAILs when queried on a DNS server that has DNSSec > validation turned on. > > > my $reply; > > my $resolver = new Net::DNS::Resolver(); > > # Set options in the constructor > $resolver = new Net::DNS::Resolver( > nameservers => [ '10.20.0.5' ], > recurse => 1, > debug => 1 > ); > > $resolver->dnssec(1); > $reply = $resolver->query( 'sigfail.verteiltesysteme.net', 'A' ); > if (defined($reply)) { > $header = $reply->header; > print "query response code = ", $header->rcode, "\n"; > } > else { > print "undefined\n"; > $header = $reply->header; > } >
You could have saved yourself a lot of time by reading the explanation in Net::DNS::FAQ: Why does $resolver->query() return undef when the answer section is empty? The short answer is, do not use query(). $resolver->send() will always return the answer packet, as long as an answer was received. The longer answer is that query() is modeled after the res_query() function from the libresolv C library, which has similar behavior. or the documentation for Net::DNS::Resolver: query . . Returns a Net::DNS::Packet object, or undef if no answers were found. If you need to examine the response packet, whether it contains any answers or not, use the send() method instead.
Subject: RE: [rt.cpan.org #105915] Object is undefined on SERVFAIL even though debug displays it all
Date: Fri, 17 Jul 2015 19:29:42 +0000
To: "frnkblk [...] iname.com" <frnkblk [...] iname.com>, "bug-Net-DNS [...] rt.cpan.org" <bug-Net-DNS [...] rt.cpan.org>
From: Frank Bulk <fbulk [...] mypremieronline.com>
Thanks. I looked through the documentation, but not carefully enough. And I should have scanned thru the FAQ. Thanks again, Frank Sent from my Samsung Galaxy S5 using i wireless' 4G network Show quoted text
-----Original Message----- From: Dick Franks via RT [bug-Net-DNS@rt.cpan.org] Received: Friday, 17 Jul 2015, 1:09PM To: frnkblk@iname.com [frnkblk@iname.com] Subject: [rt.cpan.org #105915] Object is undefined on SERVFAIL even though debug displays it all <URL: https://rt.cpan.org/Ticket/Display.html?id=105915 > On Fri Jul 17 00:58:38 2015, frnkblk@iname.com wrote:
> I'm a newbie with this module, but I discovered through trial and error that > although the debug option spits out all the details about queries, including > those with SERVFAIL, the header method can't be called against the returned > packet object because the packet object is undefined on a SERVFAIL response. > > Although I can detect the SERVFAIL response using the errorstring method, > the Net::DNS modules ought to return all the relevant objects regardless of > success or not. > > Here's a code snipper where I'm testing that at incorrectly signed DNSSec > zone correctly SERVFAILs when queried on a DNS server that has DNSSec > validation turned on. > > > my $reply; > > my $resolver = new Net::DNS::Resolver(); > > # Set options in the constructor > $resolver = new Net::DNS::Resolver( > nameservers => [ '10.20.0.5' ], > recurse => 1, > debug => 1 > ); > > $resolver->dnssec(1); > $reply = $resolver->query( 'sigfail.verteiltesysteme.net', 'A' ); > if (defined($reply)) { > $header = $reply->header; > print "query response code = ", $header->rcode, "\n"; > } > else { > print "undefined\n"; > $header = $reply->header; > } >
You could have saved yourself a lot of time by reading the explanation in Net::DNS::FAQ: Why does $resolver->query() return undef when the answer section is empty? The short answer is, do not use query(). $resolver->send() will always return the answer packet, as long as an answer was received. The longer answer is that query() is modeled after the res_query() function from the libresolv C library, which has similar behavior. or the documentation for Net::DNS::Resolver: query . . Returns a Net::DNS::Packet object, or undef if no answers were found. If you need to examine the response packet, whether it contains any answers or not, use the send() method instead.