local $ofs = 6 * 2;
{
id => $id,
qr => ! ! ($flags & 0x8000),
aa => ! ! ($flags & 0x0400),
tc => ! ! ($flags & 0x0200),
rd => ! ! ($flags & 0x0100),
ra => ! ! ($flags & 0x0080),
ad => ! ! ($flags & 0x0020),
cd => ! ! ($flags & 0x0010),
op => $opcode_str{($flags & 0x001e) >> 11},
rc => $rcode_str{($flags & 0x000f)},
qd => [map _dec_qd, 1 .. $qd],
an => [map _dec_rr, 1 .. $an],
ns => [map _dec_rr, 1 .. $ns],
ar => [map _dec_rr, 1 .. $ar],
}
}
#############################################################################
=back
=head2 THE AnyEvent::DNS RESOLVER CLASS
This is the class which does the actual protocol work.
=over 4
=cut
use Carp ();
use Scalar::Util ();
use Socket ();
our $NOW;
=item AnyEvent::DNS::resolver
This function creates and returns a resolver that is ready to use and
should mimic the default resolver for your system as good as possible.
It only ever creates one resolver and returns this one on subsequent
calls.
Unless you have special needs, prefer this function over creating your own
resolver object.
=cut
our $RESOLVER;
sub resolver() {
$RESOLVER || do {
$RESOLVER = new AnyEvent::DNS;
$RESOLVER->os_config;
$RESOLVER
}
}
=item $resolver = new AnyEvent::DNS key => value...
Creates and returns a new resolver.
The following options are supported:
=over 4
=item server => [...]
A list of server addresses (default: C<v127.0.0.1>) in network format
(i.e. as returned by C<AnyEvent::Socket::parse_address> - both IPv4 and
IPv6 are supported).
=item timeout => [...]
A list of timeouts to use (also determines the number of retries). To make
three retries with individual time-outs of 2, 5 and 5 seconds, use C<[2,
5, 5]>, which is also the default.
=item search => [...]
The default search list of suffixes to append to a domain name (default: none).
=item ndots => $integer
The number of dots (default: C<1>) that a name must have so that the resolver
tries to resolve the name without any suffixes first.
=item max_outstanding => $integer
Most name servers do not handle many parallel requests very well. This
option limits the number of outstanding requests to C<$integer>
(default: C<10>), that means if you request more than this many requests,
then the additional requests will be queued until some other requests have
been resolved.
=7= |