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]:
> 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.