Thanks,
in the meantime I'd realised that myself. Just in case it's useful to anybody else I include my code so far for asynchronous resolution. As far as I can see from the documentation retrieving records from the results should be as simple as traversing an array of arrays and picking out the bits you want. e.g. A or AAAA records.
#!/usr/bin/perl -w
use strict;
use warnings;
use Data::Dumper;
use AnyEvent::DNS;
my ($domain,$START_TIME,$MAX_QUERIES,$MAX_QUEUE,
$time,$done,$resolved);
my (@domains,@condvars);
$START_TIME = time;
$MAX_QUERIES = 1000;
$MAX_QUEUE = 10;
$resolved = 0;
# setup resolver
my $resolver = AnyEvent::DNS::resolver;
$resolver->max_outstanding($MAX_QUEUE);
#$resolver->timeout([0,1,2]);
while (1)
{
# send dns packets
for my $i (1..$MAX_QUERIES)
{
$domain = <>;
# clean off newline
chomp $domain;
$resolver->resolve($domain,"*",my $condvar = AnyEvent->condvar);
push @condvars, $condvar;
}
# receive dns packets
while (my $condvar = pop @condvars)
{
$resolved++ if ($condvar->recv);
#warn Dumper [$condvar->recv];
}
$done += $MAX_QUERIES;
$time = time - $START_TIME;
print "Done $done domains, $resolved resolved in $time seconds.\n";
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.