Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: MARKOV [...] cpan.org
Cc:
AdminCc:

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



Subject: provided hints overwritten
the ::Resolve::Recurse docs say $res->hints(@ips); If no hints are passed, the default nameserver is asked for the hints. However, the code does if (!@hints && $self->nameservers) { $self->hints($self->nameservers); } else { $self->nameservers(@hints); } $self->recurse(1); my $packet=$self->query(".", "NS", "IN"); If provided, the nameservers are set according to the hints, but the routine is not terminated: there will still be a query for '.' which overwrites the provided settings. However, this will give a dangerous recursion in the first part if the if (which setting is not used) Probably, it should just have been return $self->nameservers(@hints) if @hints;
Subject: No root IPs, still process continued
(still trying to figure-out why my root query does not return IP-addresses, reporting weird things from ::Recurse) sub hints() ends like this: } else { warn "Server [".($self->nameservers)[0]."] did not give answers"; } # Disable recursion flag. return $self->nameservers( map { @{ $_ } } values %{$self->{'hints'}}) } The comment is (of course) out-dated. The warning is too weak: when no hints where found, then the last call to "nameservers" will not set an empty list, but ask for the current settings... Also, it is very questionable whether ($self->nameservers)[0] is really the responsible name-server answering on the '.' query.
I am finally getting around to cleaning a bunch of bugs from the queue. The problem that you encounter is there by design. The intention of the HINTS is to provide a list of root-servers. Since that data can be stale it is immediately refreshed by authoritative data. In other words the hints are only there to provide a location where more authoritative data can be found. If you want to force a certain nameserver to be used a better option is to use $res->nameserver(@list); I did change the error message so it prints the IPs of all nameservers something like: Servers [127.53.53.10 127.53.53.11 ] did not give answers at blib/lib/Net/DNS/Resolver/Recurse.pm line 86. On Fri Mar 28 18:51:00 2008, MARKOV wrote: Show quoted text
> the ::Resolve::Recurse docs say > > $res->hints(@ips); > If no hints are passed, the default nameserver is asked for the hints. > > However, the code does > > if (!@hints && $self->nameservers) { > $self->hints($self->nameservers); > } else { > $self->nameservers(@hints); > } > > $self->recurse(1); > my $packet=$self->query(".", "NS", "IN"); > > If provided, the nameservers are set according to the hints, but the > routine is not terminated: there will still be a query for '.' which > overwrites the provided settings. However, this will give a dangerous > recursion in the first part if the if (which setting is not used) > Probably, it should just have been > > return $self->nameservers(@hints) > if @hints;
Subject: Re: [rt.cpan.org #34511] provided hints overwritten
Date: Wed, 17 Dec 2008 14:39:01 +0100
To: Olaf Kolkman via RT <bug-Net-DNS [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Olaf Kolkman via RT (bug-Net-DNS@rt.cpan.org) [081217 12:52]: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=34511 > > > If you want to force a certain nameserver to be used a better option is to use > $res->nameserver(@list);
The first part was a bug-report, which still needs to be addressed, I think. The problem is that, if no hints are provided, but nameservers() are set, then the code after the block (starting with recurse(1)) will be run twice. Show quoted text
> On Fri Mar 28 18:51:00 2008, MARKOV wrote:
> > if (!@hints && $self->nameservers) { > > $self->hints($self->nameservers); > > } else { > > $self->nameservers(@hints); > > } > > > > $self->recurse(1); > > my $packet=$self->query(".", "NS", "IN");
So, probably the first five lines should be replaced by Show quoted text
> > return $self->nameservers(@hints) > > if @hints;
The second part of the bug-report (about hints) is answered sufficiently. Thanks. -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
On Wed Dec 17 08:39:15 2008, Mark@Overmeer.net wrote: Show quoted text
> * Olaf Kolkman via RT (bug-Net-DNS@rt.cpan.org) [081217 12:52]:
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=34511 > > > > > If you want to force a certain nameserver to be used a better option
> is to use
> > $res->nameserver(@list);
> > The first part was a bug-report, which still needs to be addressed, I > think. > The problem is that, if no hints are provided, but nameservers() are > set, > then the code after the block (starting with recurse(1)) will be run > twice. >
> > On Fri Mar 28 18:51:00 2008, MARKOV wrote:
> > > if (!@hints && $self->nameservers) { > > > $self->hints($self->nameservers); > > > } else { > > > $self->nameservers(@hints); > > > } > > > > > > $self->recurse(1); > > > my $packet=$self->query(".", "NS", "IN");
> > So, probably the first five lines should be replaced by >
> > > return $self->nameservers(@hints) > > > if @hints;
>
That last suggestion does not really work as then the priming query would not happen. Also the corner case where the nameservers are not set and the hints are not supplied does not work. In that case you need hardcoded servers. I think this is the solution Index: lib/Net/DNS/Resolver/Recurse.pm ========================================================= ========== --- lib/Net/DNS/Resolver/Recurse.pm (revision 738) +++ lib/Net/DNS/Resolver/Recurse.pm (working copy) @@ -10,14 +10,40 @@ $VERSION = (qw$LastChangedRevision$)[1]; @ISA = qw(Net::DNS::Resolver); + +my @hardcodedhints = qw ( +198.41.0.4 +192.58.128.30 +192.112.36.4 +202.12.27.33 +192.5.5.241 +128.63.2.53 +192.36.148.17 +192.33.4.12 +192.228.79.201 +199.7.83.42 +128.8.10.90 +193.0.14.129 +192.203.230.10 +2001:503:ba3e::2:30 +2001:500:2f::f +2001:500:1::803f:235 +2001:503:c27::2:30 +2001:500:3::42 +2001:dc3::35 +); + sub hints { my $self = shift; my @hints = @_; print ";; hints(@hints)\n" if $self->{'debug'}; - if (!@hints && $self->nameservers) { - $self->hints($self->nameservers); + + if (!@hints && !$self->nameservers){ + return $self->hints( @hardcodedhints ) + }elsif (!@hints && $self->nameservers) { + return $self->hints($self->nameservers); } else { - $self->nameservers(@hints); + $self->nameservers(@hints); } print ";; verifying (root) zone...\n" if $self->{'debug'}; @@ -84,6 +110,9 @@ } } else { warn "Servers [". join " ",($self->nameservers),"] did not give answers"; + print ";; Unsetting hints and nameservers, trying with hardcoded nameservers\n" if $self->{'debug'}; + print $self->nameservers([]); + return $self->hints(); } # Disable recursion flag.
Subject: Re: [rt.cpan.org #34511] provided hints overwritten
Date: Wed, 17 Dec 2008 23:53:54 +0100
To: Olaf Kolkman via RT <bug-Net-DNS [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Olaf Kolkman via RT (bug-Net-DNS@rt.cpan.org) [081217 14:59]: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=34511 > > - if (!@hints && $self->nameservers) { > - $self->hints($self->nameservers); > + > + if (!@hints && !$self->nameservers){ > + return $self->hints( @hardcodedhints )
Yep, the "return" was exactly what was needed. I cannot tell whether the rest is needed... but the flow is logical. -- Bedankt Olaf! MarkOv ------------------------------------------------------------------------ drs Mark A.C.J. Overmeer MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net