Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: internationils [...] gmx.net
Cc:
AdminCc:

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



Subject: net::dns::resolver no longer sets errorstring
Hello, I check $res->errorstring after a resolver object, but that appears to no longer exist: $ ./dyndns-update.pl none.asdsdg.com Net::DNS::Resolver { Parents Net::DNS::Resolver::UNIX public methods (2) : CONFIG, OS_CONF private methods (0) internals: { adflag 0, cdflag 0, debug 0, defnames 1, dnsrch 1, dnssec 0, force_v4 0, force_v6 0, igntc 0, nameservers [ [0] "89.15.176.90" ], nameserver4 [ [0] "89.15.176.90" ], nameserver6 [], ndots 1, persistent_tcp 0, persistent_udp 0, port 53, prefer_v4 0, prefer_v6 0, recurse 1, retrans 5, retry 4, searchlist [ [0] "something.de" ], srcaddr4 "0.0.0.0", srcaddr6 "::", srcport 0, tcp_timeout 120, udp_timeout 30, udppacketsize 0, usevc 0 } } This breaks my script, and there seems to be no other way to see if the resolver was created OK. I would expect errorstrint to be NOERROR (as in teh past) or something else helpful, as I check: # check $res object... if no network, there will be an error if ($res->errorstring ne "NOERROR") { print "Resolver $server failed: ", $res->errorstring, "\n"; p $res; $ip = "0.0.0.0"; return $ip; }
From: internationils [...] gmx.net
FYI, this happened after a 'cpan-outdated -p | cpanm run', and seems to be a regression since 1.09: --> Working on Net::DNS Fetching http://www.cpan.org/authors/id/N/NL/NLNETLABS/Net-DNS-1.12.tar.gz ... OK Configuring Net-DNS-1.12 ... OK Building and testing Net-DNS-1.12 ... OK Successfully installed Net-DNS-1.12 (upgraded from 1.09)
From: internationils [...] gmx.net
For completeness: sub get_dns_ip { my $server = shift; my $host = shift; my $ip; # my $res = Net::DNS::Resolver->new; my $res = new Net::DNS::Resolver( nameservers => $server, recurse => 1, debug => 0 ); # check $res object... if no network, there will be an error if ($res->errorstring ne "NOERROR") { print "Resolver $server failed: ", $res->errorstring, "\n"; p $res; $ip = "0.0.0.0"; return $ip; } my $query = $res->search($host); if ($query) { foreach my $rr ($query->answer) { next unless $rr->type eq "A"; # print "$host: ", $rr->address, "\n"; $ip = $rr->address; } } else { print "Query for $server failed: ", $res->errorstring, "\n"; $ip = "0.0.0.0"; } return $ip; }
From: rwfranks [...] acm.org
errorstring print 'query status: ', $resolver->errorstring, "\n"; Returns a string containing error information from the most recent method call. errorstring() is meaningful only when interrogated immediately after an error. The documentation (1.09) clearly states that errorstring is valid after a method call, and your script has not yet called one. Perhaps, the wording should be more specific about which method calls are involved (query, search, send, bgsend, bgread, axfr). I am happy to do that, but do not think it appropriate to broaden the scope of errorstring, which in any case is a fairly blunt instrument. Anything as serious as a failure to create the resolver instance will raise an exception. Explicit testing for irrecoverable errors is inefficient and does not tell you anything about what went wrong deep inside.
From: internationils [...] gmx.net
Fair enough... but the resolver object fails to get created when there is no network, for example, and that was the reason I put that check there at that point (running on a laptop). How do you know what the problem is if $res is undef after the new() ?
From: rwfranks [...] acm.org
On Tue Aug 22 14:26:23 2017, CQu wrote: Show quoted text
> Fair enough... but the resolver object fails to get created when there > is no network, for example, and that was the reason I put that check > there at that point (running on a laptop).
That is an entirely different matter. Let me try it on my laptop. Show quoted text
> How do you know what the problem is if $res is undef after the new() ?
First we need to identify the problem.
From: rwfranks [...] acm.org
On Tue Aug 22 14:51:54 2017, rwfranks@acm.org wrote: Show quoted text
> On Tue Aug 22 14:26:23 2017, CQu wrote:
> > Fair enough... but the resolver object fails to get created when there > > is no network,
Show quoted text
> Let me try it on my laptop.
Network disconnected. Local BIND stopped. [rwf devel]$ cat test.pl #!/usr/bin/perl -w # use Net::DNS 1.12; my $resolver = Net::DNS::Resolver->new(); print "resolver instance created\n" if ref($resolver); print $resolver->errorstring, "\n"; my $packet = $resolver->send( qw(net-dns.org. SOA) ); print $resolver->errorstring, "\n"; exit; [rwf devel]$ perl test.pl resolver instance created Use of uninitialized value in print at test.pl line 9. query timed out [rwf devel]$ Which is much as I expected.
From: internationils [...] gmx.net
OK, this might just be a RTFM issue on my part then. Feel free to close. What had happened last time is that I was resolving via dns.gandi.net (their nameservers are a,b,c.dns.gandi.net) and that stopped working (not sure what role the DNS in my ipfire box played in that episode), so I put in that check which seemed to work at the time (1.09). I can live with checking after the method calls... listing those in the docs might be helpful. Thanks for your help!
From: rwfranks [...] acm.org
On Tue Aug 22 15:32:18 2017, CQu wrote: Show quoted text
> I can live with checking after the method calls... listing those in > the docs might be helpful.
There are a lot of them, and I am hard pressed to find a collective noun. In the end I settled on the following text: errorstring print 'query status: ', $resolver->errorstring, "\n"; Returns a string containing error information from the most recent DNS protocol interaction. errorstring() is meaningful only when interrogated immediately after the corresponding method call.