S
Sun Guonian
Base.pm_00 is original Base.pm file of Net-DNS-0.47,
Base.pm if my updated version.
# diff -c Base.pm_00 Base.pm
*** Base.pm_00 Sat Feb 21 20:45:27 2004
--- Base.pm Sun May 30 10:28:51 2004
***************
*** 430,436 ****
my $ans = $self->send($packet);
! return $ans && $ans->header->ancount ? $ans : undef;
}
--- 430,436 ----
my $ans = $self->send($packet);
! return $ans ? $ans : undef;
}
My question is why it check $ans->header->ancount,
for some authority-only server, its reply has no answer
record, and we think it is right answer. for example,
==== foo.pl ====
#!/usr/bin/perl
use Net:NS;
my $res1 = Net:NS::Resolver->new(
nameservers => [qw(81.91.161.5)],
recurse => 1,
debug => 1,
);
my $query1 = $res1->query("nokia.de", "NS");
if (defined($query1)) {
foreach $rr (grep { $_->type eq 'NS' } $query1->answer) {
print $rr->nsdname, "\n";
}
}
else {
warn "query1 failed: ", $res1->errorstring, "\n";
}
==== foo.pl ====
its output is the followed :
;; query(nokia.de, NS, IN)
;; send_udp(81.91.161.5:53)
;; answer from 81.91.161.5:53 : 101 bytes
;; HEADER SECTION
;; id = 39479
;; qr = 1 opcode = QUERY aa = 0 tc = 0 rd = 0
;; ra = 0 ad = 0 cd = 0 rcode = NOERROR
;; qdcount = 1 ancount = 0 nscount = 2 arcount = 2
;; QUESTION SECTION (1 record)
;; nokia.de. IN NS
;; ANSWER SECTION (0 records)
;; AUTHORITY SECTION (2 records)
nokia.de. 86400 IN NS ns1.openit.de.
nokia.de. 86400 IN NS ns2.openit.de.
;; ADDITIONAL SECTION (2 records)
ns1.openit.de. 86400 IN A 217.69.65.1
ns2.openit.de. 86400 IN A 217.10.64.100
query1 failed: NOERROR
Any advice is appreciated !
Best Regard,
Sun Guonian
Base.pm if my updated version.
# diff -c Base.pm_00 Base.pm
*** Base.pm_00 Sat Feb 21 20:45:27 2004
--- Base.pm Sun May 30 10:28:51 2004
***************
*** 430,436 ****
my $ans = $self->send($packet);
! return $ans && $ans->header->ancount ? $ans : undef;
}
--- 430,436 ----
my $ans = $self->send($packet);
! return $ans ? $ans : undef;
}
My question is why it check $ans->header->ancount,
for some authority-only server, its reply has no answer
record, and we think it is right answer. for example,
==== foo.pl ====
#!/usr/bin/perl
use Net:NS;
my $res1 = Net:NS::Resolver->new(
nameservers => [qw(81.91.161.5)],
recurse => 1,
debug => 1,
);
my $query1 = $res1->query("nokia.de", "NS");
if (defined($query1)) {
foreach $rr (grep { $_->type eq 'NS' } $query1->answer) {
print $rr->nsdname, "\n";
}
}
else {
warn "query1 failed: ", $res1->errorstring, "\n";
}
==== foo.pl ====
its output is the followed :
;; query(nokia.de, NS, IN)
;; send_udp(81.91.161.5:53)
;; answer from 81.91.161.5:53 : 101 bytes
;; HEADER SECTION
;; id = 39479
;; qr = 1 opcode = QUERY aa = 0 tc = 0 rd = 0
;; ra = 0 ad = 0 cd = 0 rcode = NOERROR
;; qdcount = 1 ancount = 0 nscount = 2 arcount = 2
;; QUESTION SECTION (1 record)
;; nokia.de. IN NS
;; ANSWER SECTION (0 records)
;; AUTHORITY SECTION (2 records)
nokia.de. 86400 IN NS ns1.openit.de.
nokia.de. 86400 IN NS ns2.openit.de.
;; ADDITIONAL SECTION (2 records)
ns1.openit.de. 86400 IN A 217.69.65.1
ns2.openit.de. 86400 IN A 217.10.64.100
query1 failed: NOERROR
Any advice is appreciated !
Best Regard,
Sun Guonian