AnyEvent-Whois-Raw
view release on metacpan or search on metacpan
lib/AnyEvent/Whois/Raw.pm view on Meta::CPAN
my $sockname = getsockname($fh);
my $timeout = $Net::Whois::Raw::TIMEOUT||30;
if (exists $stash->{params}{on_prepare}) {
$timeout = $stash->{params}{on_prepare}->($fh);
}
my $rotate_reference = eval { Net::Whois::Raw::get_ips_for_query($srv) };
if (!$rotate_reference && @Net::Whois::Raw::SRC_IPS && $sockname eq getsockname($fh)) {
# we have ip and there was no bind request in on_prepare callback
$rotate_reference = \@Net::Whois::Raw::SRC_IPS;
}
if ($rotate_reference) {
my $ip = shift @$rotate_reference;
bind $fh, AnyEvent::Socket::pack_sockaddr(0, parse_address($ip));
push @$rotate_reference, $ip; # rotate ips
}
return exists $stash->{params}{timeout} ?
$stash->{params}{timeout} :
$timeout;
}
sub Net::Whois::Raw::www_whois_query {
my $call = $stash->{calls}{www_whois_query}++;
lib/AnyEvent/Whois/Raw.pm view on Meta::CPAN
Available %PARAMS are:
=over
=item timeout => $seconds
Timeout for whois request in seconds
=item on_prepare => $cb
Same as prepare callback from AnyEvent::Socket. So you can bind socket to some ip:
whois 'google.com', on_prepare => sub {
bind $_[0], AnyEvent::Socket::pack_sockaddr(0, AnyEvent::Socket::parse_ipv4($ip)));
}, sub {
my $info = shift;
}
=back
CB is a callback which will be called when request will be finished. On success callback arguments
are whois text data and whois server used for request. On failed false value (not undef) and failed reason.
=head2 get_whois DOMAIN [, SRV [, WHICH_WHOIS] [, %PARAMS]], CB
( run in 1.312 second using v1.01-cache-2.11-cpan-2398b32b56e )