EV-cares
view release on metacpan or search on metacpan
eg/upstream_ad_check.pl view on Meta::CPAN
# Need the EDNS flag so the upstream actually sets DO and reports AD;
# without it many resolvers strip the AD bit out of paranoia.
my $flags = ARES_FLAG_EDNS;
printf "Querying %s for an A record on %d resolver(s)\n\n", $name, scalar @servers;
printf "%-20s %-7s %-7s %-7s %s\n", 'server', 'rcode', 'ad', 'ra', 'note';
printf "%s\n", '-' x 60;
my $pending = scalar @servers;
my @resolvers; # keep resolvers alive across the for loop iterations;
# otherwise each $r drops to refcount 0 at end-of-iter,
# DESTROY runs ares_destroy, and every callback fires
# with ARES_EDESTRUCTION before we ever pump EV::run.
for my $srv (@servers) {
my $r = EV::cares->new(servers => [$srv], flags => $flags, timeout => 5);
push @resolvers, $r;
$r->query($name, C_IN, T_A, sub {
my ($status, $buf) = @_;
my $note = '';
my ($rcode, $ad, $ra) = ('-', '-', '-');
( run in 1.748 second using v1.01-cache-2.11-cpan-71847e10f99 )