AnyEvent
view release on metacpan or search on metacpan
lib/AnyEvent/DNS.pm view on Meta::CPAN
}
$ptr
}
sub reverse_lookup($$) {
my ($ip, $cb) = @_;
$ip = _munge_ptr AnyEvent::Socket::parse_address ($ip)
or return $cb->();
resolver->resolve ($ip => "ptr", sub {
$cb->(map $_->[4], @_);
});
}
sub reverse_verify($$) {
my ($ip, $cb) = @_;
my $ipn = AnyEvent::Socket::parse_address ($ip)
or return $cb->();
my $af = AnyEvent::Socket::address_family ($ipn);
my @res;
my $cnt;
my $ptr = _munge_ptr $ipn
or return $cb->();
$ip = AnyEvent::Socket::format_address ($ipn); # normalise into the same form
ptr $ptr, sub {
for my $name (@_) {
++$cnt;
# () around AF_INET to work around bug in 5.8
resolver->resolve ("$name." => ($af == (AF_INET) ? "a" : "aaaa"), sub {
for (@_) {
push @res, $name
if $_->[4] eq $ip;
}
$cb->(@res) unless --$cnt;
});
}
$cb->() unless $cnt;
};
}
#################################################################################
=back
=head2 LOW-LEVEL DNS EN-/DECODING FUNCTIONS
=over 4
=item $AnyEvent::DNS::EDNS0
This variable decides whether dns_pack automatically enables EDNS0
support. By default, this is disabled (C<0>), unless overridden by
C<$ENV{PERL_ANYEVENT_EDNS0}>, but when set to C<1>, AnyEvent::DNS will use
EDNS0 in all requests.
=cut
our $EDNS0 = $ENV{PERL_ANYEVENT_EDNS0}*1; # set to 1 to enable (partial) edns0
our %opcode_id = (
query => 0,
iquery => 1,
status => 2,
notify => 4,
update => 5,
map +($_ => $_), 3, 6..15
);
our %opcode_str = reverse %opcode_id;
our %rcode_id = (
noerror => 0,
formerr => 1,
servfail => 2,
nxdomain => 3,
notimp => 4,
refused => 5,
yxdomain => 6, # Name Exists when it should not [RFC 2136]
yxrrset => 7, # RR Set Exists when it should not [RFC 2136]
nxrrset => 8, # RR Set that should exist does not [RFC 2136]
notauth => 9, # Server Not Authoritative for zone [RFC 2136]
notzone => 10, # Name not contained in zone [RFC 2136]
# EDNS0 16 BADVERS Bad OPT Version [RFC 2671]
# EDNS0 16 BADSIG TSIG Signature Failure [RFC 2845]
# EDNS0 17 BADKEY Key not recognized [RFC 2845]
# EDNS0 18 BADTIME Signature out of time window [RFC 2845]
# EDNS0 19 BADMODE Bad TKEY Mode [RFC 2930]
# EDNS0 20 BADNAME Duplicate key name [RFC 2930]
# EDNS0 21 BADALG Algorithm not supported [RFC 2930]
map +($_ => $_), 11..15
);
our %rcode_str = reverse %rcode_id;
our %type_id = (
a => 1,
ns => 2,
md => 3,
mf => 4,
cname => 5,
soa => 6,
mb => 7,
mg => 8,
mr => 9,
null => 10,
wks => 11,
ptr => 12,
hinfo => 13,
minfo => 14,
mx => 15,
txt => 16,
( run in 1.830 second using v1.01-cache-2.11-cpan-39bf76dae61 )