0
我想使用AnyEvent::DNS
來解析我的域在一些DNS服務器上。 服務器列表來自兩個地方,每個約60多個服務器。 當我運行解決只有一個服務器列表,沒有問題。但如果我運行所有列表的解決方案,我得到一個錯誤:"unable to create either an IPv4 or an IPv6 socket"
。是否有AnyEvent :: DNS最大請求限制?
我的如下腳本:
#!/usr/bin/perl
use Modern::Perl;
use AnyEvent::DNS;
use AnyEvent::Socket;
use AnyEvent;
use Module::Runtime qw/require_module/;
use lib './lib';
my $domain = $ARGV[0] // 'fmn.xnimg.cn';
my $cv = AnyEvent->condvar;
for my $mod (('DNS::xixik', 'DNS::yqie')) { # error
#for my $mod (('DNS::xixik')) { # ok
require_module($mod);
my $dnslist = $mod->new->get_dnslist;
for my $isp (keys %$dnslist) {
while (my ($addr, $dns) = each %{ $dnslist->{$isp} }) {
resolv($isp . $addr, $_, $domain) for @{$dns};
}
}
}
$cv->recv;
sub resolv {
my ($addr, $dns, $domain) = @_;
my $resolver = AnyEvent::DNS->new(
server => [ AnyEvent::Socket::parse_address $dns ],
);
$cv->begin;
$resolver->resolve(
"$domain" => 'a',
sub {
my @ips = map { $_->[-1] } @_;
printf "%s (%s) => %s\n", $dns, $addr, join(", ", @ips) if @ips;
$cv->end;
}
);
}