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;
}