NAME
POE::Component::Client::Whois::Smart - Provides very quick WHOIS queries with smart features.
DESCRIPTION
POE::Component::Client::Whois::Smart provides a very quick WHOIS queries with smart features to other POE sessions and components. The component will attempt to guess the appropriate whois server to connect to. Supports cacheing, HTTP-queries to some servers, stripping useless information, using more then one local IP, handling server's bans.
SYNOPSIS
use strict;
use warnings;
use POE qw(Component::Client::Whois::Smart);
my @queries = qw(
google.com
yandex.ru
84.45.68.23
REGRU-REG-RIPN
);
POE::Session->create(
package_states => [
'main' => [ qw(_start _response) ],
],
);
$poe_kernel->run();
exit 0;
sub _start {
POE::Component::Client::Whois::Smart->whois(
query => \@queries,
event => '_response',
);
}
sub _response {
my $all_results = $_[ARG0];
foreach my $result ( @{$all_results} ) {
my $query = $result->{query} if $result;
if ($result->{error}) {
print "Can't resolve WHOIS-info for ".$result->{query}."\n";
} else {
print "QUERY: ".$result->{query}."\n";
print "SERVER: ".$result->{server}."\n";
print "WHOIS: ".$result->{whois}."\n\n";
};
}
}
Constructor
- whois()
-
Creates a POE::Component::Client::Whois session. Takes two mandatory arguments and a number of optional:
- query
-
query is an arrayref of domains, IPs or registaras to send to whois server. Required.
- event
-
The event name to call on success/failure. Required.
- session
-
A session or alias to send the above 'event' to, defaults to calling session. Optional.
- server
-
Specify server to connect. Defaults try to be determined by the component. Optional.
- referral
-
Optional.
0 - make just one query, do not follow if redirections can be done;
1 - follow redirections if possible, return last response from server; # default
2 - follow redirections if possible, return all responses;
Exapmle:
#... POE::Component::Client::Whois->whois( query => [ 'google.com', 'godaddy.com' ], event => '_response', referral => 2, ); #... sub _response { my $all_results = $_[ARG0]; foreach my $result ( @{$all_results} ) { my $query = $result->{query} if $result; if ($result->{error}) { print "Can't resolve WHOIS-info for ".$result->{query}."\n"; } else { print "Query for: ".$result->{query}."\n"; # process all subqueries my $count = scalar @{$result->{subqueries}}; print "There were $count subqueries:\n"; foreach my $subquery (@{$result->{subqueries}}) { print "\tTo server ".$subquery->{server}."\n"; # print "\tQuery: ".$subquery->{query}."\n"; # print "\tResponse:\n".$subquery->{whois}."\n"; } } } } #...
- omit_msg
-
1 - attempt to strip several known copyright messages and disclaimers.
2 - will try some additional stripping rules if some are known for the spcific server.
Default is to give the whole response.
- use_cnames
-
Use whois-servers.net to get the whois server name when possible. Default is to use the hardcoded defaults.
- timeout
-
Cancel the request if connection is not made within a specific number of seconds. Default 30 sec.
- local_ips
-
List of local IP addresses to use for WHOIS queries. Addresses will be used used successively in the successive queries
- cache_dir
-
Whois information will be cached in this directory. Default is no cache.
- cache_time
-
Number of minutes to save cache. 1 minute by default.
- exceed_wait
-
If exceed_wait true, will wait for for 1 minute and requery server in case if your IP banned for excessive querying. By default return 'Connection rate exceeded' in $result->{error};
OUTPUT
ARG0 will be an array of hashrefs, which contains replies. See example above.
AUTHOR
Sergey Kotenko <graykot@gmail.com>
This module is based on the Net::Whois::Raw http://search.cpan.org/perldoc?Net::Whois::Raw and POE::Component::Client::Whois http://search.cpan.org/perldoc?POE::Component::Client::Whois
SEE ALSO
RFC 812 http://www.faqs.org/rfcs/rfc812.html.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 1157:
You forgot a '=back' before '=head1'