Hello community, here is the log from the commit of package perl-Net-Whois-Raw for openSUSE:Factory checked in at 2015-10-30 13:43:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Net-Whois-Raw (Old) and /work/SRC/openSUSE:Factory/.perl-Net-Whois-Raw.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Net-Whois-Raw" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Net-Whois-Raw/perl-Net-Whois-Raw.changes 2015-10-28 17:31:15.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Net-Whois-Raw.new/perl-Net-Whois-Raw.changes 2015-10-30 13:43:40.000000000 +0100 @@ -1,0 +2,9 @@ +Thu Oct 29 10:13:54 UTC 2015 - co...@suse.com + +- updated to 2.91 + see /usr/share/doc/packages/perl-Net-Whois-Raw/Changes + + 2.91 Oct 28 2015 Vadim Likhota + - even more new tlds of whois.centralnic.com + +------------------------------------------------------------------- Old: ---- Net-Whois-Raw-2.90.tar.gz New: ---- Net-Whois-Raw-2.91.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Net-Whois-Raw.spec ++++++ --- /var/tmp/diff_new_pack.C0ettK/_old 2015-10-30 13:43:40.000000000 +0100 +++ /var/tmp/diff_new_pack.C0ettK/_new 2015-10-30 13:43:40.000000000 +0100 @@ -17,7 +17,7 @@ Name: perl-Net-Whois-Raw -Version: 2.90 +Version: 2.91 Release: 0 %define cpan_name Net-Whois-Raw Summary: Get Whois information of domains and IP addresses @@ -35,6 +35,7 @@ BuildRequires: perl(HTTP::Request) BuildRequires: perl(IO::Socket::IP) BuildRequires: perl(LWP::UserAgent) +BuildRequires: perl(Net::IDN::Punycode) BuildRequires: perl(Regexp::IPv6) BuildRequires: perl(Test::RequiresInternet) BuildRequires: perl(URI::URL) @@ -42,6 +43,7 @@ Requires: perl(HTTP::Request) Requires: perl(IO::Socket::IP) Requires: perl(LWP::UserAgent) +Requires: perl(Net::IDN::Punycode) Requires: perl(Regexp::IPv6) Requires: perl(URI::URL) %{perl_requires} @@ -60,7 +62,6 @@ %prep %setup -q -n %{cpan_name}-%{version} -find . -type f -print0 | xargs -0 chmod 644 %build %{__perl} Makefile.PL INSTALLDIRS=vendor @@ -76,6 +77,6 @@ %files -f %{name}.files %defattr(-,root,root,755) -%doc Changes COPYRIGHT LICENSE pwhois README +%doc Changes COPYRIGHT LICENSE README %changelog ++++++ Net-Whois-Raw-2.90.tar.gz -> Net-Whois-Raw-2.91.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-Whois-Raw-2.90/Changes new/Net-Whois-Raw-2.91/Changes --- old/Net-Whois-Raw-2.90/Changes 2015-10-27 10:16:24.000000000 +0100 +++ new/Net-Whois-Raw-2.91/Changes 2015-10-28 11:09:15.000000000 +0100 @@ -1,5 +1,8 @@ Revision history for Perl module Net::Whois::Raw. +2.91 Oct 28 2015 Vadim Likhota + - even more new tlds of whois.centralnic.com + 2.89, 2.90 Oct 27 2015 Alexander Nalobin - more new tlds of whois.centralnic.com diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-Whois-Raw-2.90/MANIFEST new/Net-Whois-Raw-2.91/MANIFEST --- old/Net-Whois-Raw-2.90/MANIFEST 2015-10-27 10:16:24.000000000 +0100 +++ new/Net-Whois-Raw-2.91/MANIFEST 2015-10-28 11:09:15.000000000 +0100 @@ -6,11 +6,11 @@ META.yml Makefile.PL README +bin/pwhois dist.ini lib/Net/Whois/Raw.pm lib/Net/Whois/Raw/Common.pm lib/Net/Whois/Raw/Data.pm -pwhois t/01-local.t t/02-www_parse_tj_cgi_whois.t t/03-read_write_cache.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-Whois-Raw-2.90/META.yml new/Net-Whois-Raw-2.91/META.yml --- old/Net-Whois-Raw-2.90/META.yml 2015-10-27 10:16:24.000000000 +0100 +++ new/Net-Whois-Raw-2.91/META.yml 2015-10-28 11:09:15.000000000 +0100 @@ -22,10 +22,12 @@ Data::Dumper: '0' Encode: '0' File::Temp: '0' + Getopt::Long: '0' HTTP::Headers: '0' HTTP::Request: '0' IO::Socket::IP: '0' LWP::UserAgent: '0' + Net::IDN::Punycode: '0' Regexp::IPv6: '0' URI::URL: '0' perl: 5.008_001 @@ -35,4 +37,4 @@ resources: bugtracker: https://github.com/regru/Net-Whois-Raw/issues repository: git://github.com/regru/Net-Whois-Raw.git -version: '2.90' +version: '2.91' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-Whois-Raw-2.90/Makefile.PL new/Net-Whois-Raw-2.91/Makefile.PL --- old/Net-Whois-Raw-2.90/Makefile.PL 2015-10-27 10:16:24.000000000 +0100 +++ new/Net-Whois-Raw-2.91/Makefile.PL 2015-10-28 11:09:15.000000000 +0100 @@ -13,6 +13,10 @@ "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Net-Whois-Raw", + "EXE_FILES" => [ + "bin/pwhois", + "bin/pwhois" + ], "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.008_001", "NAME" => "Net::Whois::Raw", @@ -21,10 +25,12 @@ "Data::Dumper" => 0, "Encode" => 0, "File::Temp" => 0, + "Getopt::Long" => 0, "HTTP::Headers" => 0, "HTTP::Request" => 0, "IO::Socket::IP" => 0, "LWP::UserAgent" => 0, + "Net::IDN::Punycode" => 0, "Regexp::IPv6" => 0, "URI::URL" => 0, "strict" => 0, @@ -38,7 +44,7 @@ "Test::More" => 0, "Test::RequiresInternet" => 0 }, - "VERSION" => "2.90", + "VERSION" => "2.91", "test" => { "TESTS" => "t/*.t" } @@ -51,10 +57,12 @@ "Data::Dumper" => 0, "Encode" => 0, "File::Temp" => 0, + "Getopt::Long" => 0, "HTTP::Headers" => 0, "HTTP::Request" => 0, "IO::Socket::IP" => 0, "LWP::UserAgent" => 0, + "Net::IDN::Punycode" => 0, "Regexp::IPv6" => 0, "Socket" => 0, "Test::More" => 0, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-Whois-Raw-2.90/bin/pwhois new/Net-Whois-Raw-2.91/bin/pwhois --- old/Net-Whois-Raw-2.90/bin/pwhois 1970-01-01 01:00:00.000000000 +0100 +++ new/Net-Whois-Raw-2.91/bin/pwhois 2015-10-28 11:09:15.000000000 +0100 @@ -0,0 +1,293 @@ +#!/usr/bin/env perl + +# PODNAME: phwois +# ABSTRACT: Get Whois information of domains and IP addresses. + +use strict; +use warnings; +use Net::Whois::Raw; +use Getopt::Long; +use Encode; +use Net::IDN::Punycode qw( :all ); +use utf8; + +my $help; +my $do_strip; +my $do_strip_more; +my $do_checkfail; +my $do_checkfail_more; +my $debug = 0; +my $timeout = 10; +my $enable_caching; +my @source_addresses; +my $return_first; +my $return_last; +my $return_all; + +Getopt::Long::Configure( 'bundling', 'no_ignore_case' ); + +GetOptions( + 'help|h' => \$help, + 'strip|s' => \$do_strip, + 'checkfail|c' => \$do_checkfail, + 'debug|d+' => \$debug, + 'timeout|T=i' => \$timeout, + 'enable_caching|t' => \$enable_caching, + 'src_addr|a=s@' => \@source_addresses, + 'return_first|F' => \$return_first, + 'return_last|L' => \$return_last, + 'return_all|A' => \$return_all, +) or die; + +if ($help || !@ARGV) { + print <<EOM; +Usage: $0 [ -s ] [ -c ] [ -d ] [ -T <timeout> ] [ -a <src_ip> ] [ -t ] [ -F | -L | -A ] <domain> [ <server> ] + +Switches: +-s attempt to strip the copyright message or disclaimer. +-c attempts to return an empty answer for failed searches. +-T set timeout for connection attempts +-t enables caching. +-a specify an ip address that should be used as source address +-d enables debugging messages. +-F returns results of the first query of recursive whois requests +-L returns results of the last query of recursive whois requests (the default) +-A returns results of the all queries of recursive whois requests +EOM + exit; +} + +$Net::Whois::Raw::DEBUG = $debug; +$Net::Whois::Raw::OMIT_MSG = $do_strip ? 1 : 0; +$Net::Whois::Raw::CHECK_FAIL = $do_checkfail ? 1 : 0; +$Net::Whois::Raw::TIMEOUT = $timeout; +@Net::Whois::Raw::SRC_IPS = @source_addresses if @source_addresses; + +if ($enable_caching) { + if ($^O eq 'MSWin32') { + $Net::Whois::Raw::CACHE_DIR = $ENV{TEMP} || "C:\\temp"; + } + else { + $Net::Whois::Raw::CACHE_DIR = $ENV{TMPDIR} || '/tmp'; + } +} +else { + $Net::Whois::Raw::CACHE_DIR = undef; +} + +my ( $input_cp, $output_cp ) = detect_encodings(); + +my $dom = $ARGV[0]; +my $server = $ARGV[1]; + +$dom = prepare_domain($dom, $input_cp); + +unless (validate_domain($dom)) { + print encode_output("\nIncorrect domain name:\n$dom\n", $output_cp); + exit -1; +} + +$dom = to_punycode($dom); + +eval { + my ($result, $result_server); + my $which_whois = + $return_first ? 'QRY_FIRST' : + $return_all ? 'QRY_ALL' : 'QRY_LAST'; + + ($result, $result_server) = + Net::Whois::Raw::get_whois( $dom, $server, $which_whois ); + + if ($result and ref $result eq 'ARRAY') { + make_output($_->{text}, $_->{srv}, $output_cp) for @{$result}; + } + elsif ($result) { + make_output($result, $result_server, $output_cp); + } + else { + print STDERR "Failed.\n"; + } +}; + +if ($@) { + my $err = $@; + + $err =~ s/\s+at \S+ line \d+\.$//; + print "\nWhois information could not be fetched:\n$err\n"; + exit -1; +} + +# Prepare and print output +sub make_output { + my ($result, $server, $cp) = @_; + + $result = encode_output( $result, $cp ); + + print "[$server]\n"; + print $result, "\n"; +} + +# Encode output +sub encode_output { + my ( $output, $cp ) = @_; + + if ( $cp =~ /utf\-?8/ ) { + $output = encode_utf8( $output ); + } + else { + $output = encode( $cp, $output ); + } + + return $output; +} + +# Detect terminal input and output encodings +sub detect_encodings { + my ( $input_cp, $output_cp ); + + if ( $^O =~ /Win/ ) { + # Read encoding from registry + require Win32API::Registry; + Win32API::Registry->import( qw( :ALL ) ); + + my ( $key, $type, $data ); + RegOpenKeyEx( HKEY_LOCAL_MACHINE(), 'SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage', 0, KEY_READ(), $key ) + or die "Can't read system encodings from registry: ".regLastError(); + RegQueryValueEx( $key, 'ACP', [], $type, $data, [] ) + or die "Can't read system encodings from registry: ".regLastError(); + $input_cp = 'cp'.$data; + RegQueryValueEx( $key, 'OEMCP', [], $type, $data, [] ) + or die "Can't read system encodings from registry: ".regLastError(); + $output_cp = 'cp'.$data; + } else { + # Read encoding from environment + my $cp = $ENV{LANG}; + if ( $cp ) { + $cp =~ s/^[a-z]{2}_[A-Z]{2}[.]//; + } + else { + $cp = 'utf-8'; + } + + $input_cp = $output_cp = lc $cp; + } + + return $input_cp, $output_cp; +} + +# Prepare domain name +sub prepare_domain { + my ($dom, $input_cp) = @_; + + # Decode command-line input + $dom = decode($input_cp, $dom); + + # Lowercase latin and cyrillic characters + $dom =~ tr/A-ZА-ЯЁ\xAA\xA5\xB2\xAF/a-zа-яё\xBA\xB4\xB3\xBF/; + + return $dom; +} + +# Decode domain name to punycode if needed +sub to_punycode { + my ($dom) = @_; + + unless ($dom =~ /^[a-z0-9.\-]*$/) { + # Convert to Punycode + my @parts; + foreach my $part (split /\./, $dom) { + $part = 'xn--'.Net::IDN::Punycode::encode_punycode( $part ) + unless $part =~ /^[a-z0-9.-]*$/; + push @parts, $part; + } + $dom = join('.', @parts); + } + + return $dom; +} + +# Validate domain name +sub validate_domain { + my ($dom) = @_; + + return 0 unless $dom; + + $dom =~ /(.+?)\.([^.]+)$/; + my ($name, $tld) = ($1, $2); + + return 0 if $name =~ /^-/; + return 0 if $name =~ /-$/; + return 0 if $name =~ /^..--/ && $dom !~ /^xn--/; + + # Only latin and cyrillic characters allowed now + return 0 if $dom =~ m/[^-a-z0-9\.ёа-я\xAA\xBA\xB4\xB2\xB3\xAF\xBF\xA1\xA2]/; + + return 1; +} + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +phwois - Get Whois information of domains and IP addresses. + +=head1 VERSION + +version 2.91 + +=head1 SYNOPSIS + + pwhois perl.com + pwhois gnu.org + pwhois -s police.co.il + pwhois -c there.is.no.tld.called.foobar + pwhois yahoo.com whois.networksolutions.com + pwhois -T 10 funet.fi + +etc etc..... + +=head1 DESCRIPTION + +Just invoke with a domain name, optionally with a whois server name. +Switches: + B<-s> attempt to strip the copyright message or disclaimer. + B<-c> attempts to return an empty answer for failed searches. + B<-e> forces die if connection rate to server have been exceeded. + B<-T> set timeout for connection attempts + B<-t> enables caching. + B<-a> specify an ip address that should be used as source address + B<-d> enables debugging messages. + B<-F> returns results of the first query of recursive whois requests + B<-L> returns results of the last query of recursive whois requests (the default) + B<-A> returns results of the all queries of recursive whois requests + +=head1 NAME + +pwhois - Perl written whois client + +=head1 AUTHORS + +Ariel Brosh B<sc...@cpan.org> + +Current Maintainer: Walery Studennikov B<desp...@cpan.org> + +=head1 SEE ALSO + +L<Net::Whois::Raw>. + +=head1 AUTHOR + +Alexander Nalobin <alexan...@nalobin.ru> + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2002-2015 by Alexander Nalobin. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-Whois-Raw-2.90/dist.ini new/Net-Whois-Raw-2.91/dist.ini --- old/Net-Whois-Raw-2.90/dist.ini 2015-10-27 10:16:24.000000000 +0100 +++ new/Net-Whois-Raw-2.91/dist.ini 2015-10-28 11:09:15.000000000 +0100 @@ -4,14 +4,16 @@ copyright_holder = Alexander Nalobin copyright_year = 2002-2015 -version = 2.90 +version = 2.91 [@Filter] -bundle = @Basic -remove = Readme [AutoPrereqs] +skip = Win32API::Registry [Prereqs] File::Temp = 0 +[ExecDir] [PodWeaver] [PkgVersion] [TestRelease] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-Whois-Raw-2.90/lib/Net/Whois/Raw/Common.pm new/Net-Whois-Raw-2.91/lib/Net/Whois/Raw/Common.pm --- old/Net-Whois-Raw-2.90/lib/Net/Whois/Raw/Common.pm 2015-10-27 10:16:24.000000000 +0100 +++ new/Net-Whois-Raw-2.91/lib/Net/Whois/Raw/Common.pm 2015-10-28 11:09:15.000000000 +0100 @@ -1,5 +1,5 @@ package Net::Whois::Raw::Common; -$Net::Whois::Raw::Common::VERSION = '2.90'; +$Net::Whois::Raw::Common::VERSION = '2.91'; # ABSTRACT: Helper for Net::Whois::Raw. use Encode; @@ -619,7 +619,7 @@ =head1 VERSION -version 2.90 +version 2.91 =head1 AUTHOR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-Whois-Raw-2.90/lib/Net/Whois/Raw/Data.pm new/Net-Whois-Raw-2.91/lib/Net/Whois/Raw/Data.pm --- old/Net-Whois-Raw-2.90/lib/Net/Whois/Raw/Data.pm 2015-10-27 10:16:24.000000000 +0100 +++ new/Net-Whois-Raw-2.91/lib/Net/Whois/Raw/Data.pm 2015-10-28 11:09:15.000000000 +0100 @@ -1,5 +1,5 @@ package Net::Whois::Raw::Data; -$Net::Whois::Raw::Data::VERSION = '2.90'; +$Net::Whois::Raw::Data::VERSION = '2.91'; # ABSTRACT: Config for Net::Whois::Raw. use utf8; @@ -305,6 +305,8 @@ LUXURY whois.nic.luxury WIEN whois.nic.wien ONE whois.nic.one + TOP whois.nic.top + TRADING whois.nic.trading PINK whois.afilias.net RED whois.afilias.net @@ -470,7 +472,6 @@ TR whois.nic.tr TW whois.twnic.net.tw UA whois.com.ua - NET.UA whois.net.ua UK whois.nic.uk US whois.nic.us UZ whois.cctld.uz @@ -646,6 +647,7 @@ ORG.TW whois.twnic.net COM.UA whois.com.ua + NET.UA whois.net.ua ORG.UA whois.com.ua BIZ.UA whois.biz.ua CO.UA whois.co.ua @@ -675,51 +677,59 @@ XN--E1APQ whois.i-dns.net XN--C1AVG whois.publicinterestregistry.net + AE.ORG whois.centralnic.com + AFRICA.COM whois.centralnic.com + AR.COM whois.centralnic.com + BR.COM whois.centralnic.com + CN.COM whois.centralnic.com + CO.COM whois.centralnic.com + DE.COM whois.centralnic.com + COM.DE whois.centralnic.com EU.COM whois.centralnic.com GB.COM whois.centralnic.com - KR.COM whois.centralnic.com - US.COM whois.centralnic.com - QC.COM whois.centralnic.com - DE.COM whois.centralnic.com - NO.COM whois.centralnic.com + GB.NET whois.centralnic.com + GR.COM whois.centralnic.com HU.COM whois.centralnic.com + HU.NET whois.centralnic.com + IN.NET whois.centralnic.com + JP.NET whois.centralnic.com JPN.COM whois.centralnic.com - UY.COM whois.centralnic.com - ZA.COM whois.centralnic.com - BR.COM whois.centralnic.com - CN.COM whois.centralnic.com + KR.COM whois.centralnic.com + MEX.COM whois.centralnic.com + NO.COM whois.centralnic.com + QC.COM whois.centralnic.com + RU.COM whois.centralnic.com SA.COM whois.centralnic.com SE.COM whois.centralnic.com + COM.SE whois.centralnic.com + SE.NET whois.centralnic.com UK.COM whois.centralnic.com - RU.COM whois.centralnic.com - - GB.NET whois.centralnic.com UK.NET whois.centralnic.com - SE.NET whois.centralnic.com - AE.ORG whois.centralnic.com - IN.NET whois.centralnic.com - SITE whois.centralnic.com - AFRICA.COM whois.centralnic.com + US.COM whois.centralnic.com + UY.COM whois.centralnic.com + ZA.COM whois.centralnic.com + + BAR whois.centralnic.com + COLLEGE whois.centralnic.com DESIGN whois.centralnic.com FANS whois.centralnic.com + FEEDBACK whois.centralnic.com HOST whois.centralnic.com + INK whois.centralnic.com LOVE whois.centralnic.com - MEX.COM whois.centralnic.com ONLINE whois.centralnic.com + PRESS whois.centralnic.com PROTECTION whois.centralnic.com REIT whois.centralnic.com RENT whois.centralnic.com + REST whois.centralnic.com SECURITY whois.centralnic.com + SITE whois.centralnic.com SPACE whois.centralnic.com TECH whois.centralnic.com THEATRE whois.centralnic.com TICKETS whois.centralnic.com WEBSITE whois.centralnic.com - BAR whois.centralnic.com - COLLEGE whois.centralnic.com - FEEDBACK whois.centralnic.com - INK whois.centralnic.com - REST whois.centralnic.com WIKI whois.centralnic.com XYZ whois.centralnic.com @@ -731,7 +741,6 @@ XXX whois.nic.xxx MOSCOW whois.nic.moscow TATAR whois.nic.tatar - PRESS whois.nic.press ); @@ -2599,7 +2608,7 @@ =head1 VERSION -version 2.90 +version 2.91 =head1 AUTHOR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-Whois-Raw-2.90/lib/Net/Whois/Raw.pm new/Net-Whois-Raw-2.91/lib/Net/Whois/Raw.pm --- old/Net-Whois-Raw-2.90/lib/Net/Whois/Raw.pm 2015-10-27 10:16:24.000000000 +0100 +++ new/Net-Whois-Raw-2.91/lib/Net/Whois/Raw.pm 2015-10-28 11:09:15.000000000 +0100 @@ -1,5 +1,5 @@ package Net::Whois::Raw; -$Net::Whois::Raw::VERSION = '2.90'; +$Net::Whois::Raw::VERSION = '2.91'; # ABSTRACT: Get Whois information of domains and IP addresses. require 5.008_001; @@ -472,7 +472,7 @@ =head1 VERSION -version 2.90 +version 2.91 =head1 SYNOPSIS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-Whois-Raw-2.90/pwhois new/Net-Whois-Raw-2.91/pwhois --- old/Net-Whois-Raw-2.90/pwhois 2015-10-27 10:16:24.000000000 +0100 +++ new/Net-Whois-Raw-2.91/pwhois 1970-01-01 01:00:00.000000000 +0100 @@ -1,265 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use warnings; -use Net::Whois::Raw; -use Getopt::Long; -use Encode; -use Net::IDN::Punycode qw( :all ); -use utf8; - -my $help; -my $do_strip; -my $do_strip_more; -my $do_checkfail; -my $do_checkfail_more; -my $debug = 0; -my $timeout = 10; -my $enable_caching; -my @source_addresses; -my $return_first; -my $return_last; -my $return_all; - -Getopt::Long::Configure( 'bundling', 'no_ignore_case' ); - -GetOptions( - 'help|h' => \$help, - 'strip|s' => \$do_strip, - 'checkfail|c' => \$do_checkfail, - 'debug|d+' => \$debug, - 'timeout|T=i' => \$timeout, - 'enable_caching|t' => \$enable_caching, - 'src_addr|a=s@' => \@source_addresses, - 'return_first|F' => \$return_first, - 'return_last|L' => \$return_last, - 'return_all|A' => \$return_all, -) or die; - -if ($help || !@ARGV) { - print <<EOM; -Usage: $0 [ -s ] [ -c ] [ -d ] [ -T <timeout> ] [ -a <src_ip> ] [ -t ] [ -F | -L | -A ] <domain> [ <server> ] - -Switches: --s attempt to strip the copyright message or disclaimer. --c attempts to return an empty answer for failed searches. --T set timeout for connection attempts --t enables caching. --a specify an ip address that should be used as source address --d enables debugging messages. --F returns results of the first query of recursive whois requests --L returns results of the last query of recursive whois requests (the default) --A returns results of the all queries of recursive whois requests -EOM - exit; -} - -$Net::Whois::Raw::DEBUG = $debug; -$Net::Whois::Raw::OMIT_MSG = $do_strip ? 1 : 0; -$Net::Whois::Raw::CHECK_FAIL = $do_checkfail ? 1 : 0; -$Net::Whois::Raw::TIMEOUT = $timeout; -@Net::Whois::Raw::SRC_IPS = @source_addresses if @source_addresses; - -if ($enable_caching) { - if ($^O eq 'MSWin32') { - $Net::Whois::Raw::CACHE_DIR = $ENV{TEMP} || "C:\\temp"; - } - else { - $Net::Whois::Raw::CACHE_DIR = $ENV{TMPDIR} || '/tmp'; - } -} -else { - $Net::Whois::Raw::CACHE_DIR = undef; -} - -my ( $input_cp, $output_cp ) = detect_encodings(); - -my $dom = $ARGV[0]; -my $server = $ARGV[1]; - -$dom = prepare_domain($dom, $input_cp); - -unless (validate_domain($dom)) { - print encode_output("\nIncorrect domain name:\n$dom\n", $output_cp); - exit -1; -} - -$dom = to_punycode($dom); - -eval { - my ($result, $result_server); - my $which_whois = - $return_first ? 'QRY_FIRST' : - $return_all ? 'QRY_ALL' : 'QRY_LAST'; - - ($result, $result_server) = - Net::Whois::Raw::get_whois( $dom, $server, $which_whois ); - - if ($result and ref $result eq 'ARRAY') { - make_output($_->{text}, $_->{srv}, $output_cp) for @{$result}; - } - elsif ($result) { - make_output($result, $result_server, $output_cp); - } - else { - print STDERR "Failed.\n"; - } -}; - -if ($@) { - my $err = $@; - - $err =~ s/\s+at \S+ line \d+\.$//; - print "\nWhois information could not be fetched:\n$err\n"; - exit -1; -} - -# Prepare and print output -sub make_output { - my ($result, $server, $cp) = @_; - - $result = encode_output( $result, $cp ); - - print "[$server]\n"; - print $result, "\n"; -} - -# Encode output -sub encode_output { - my ( $output, $cp ) = @_; - - if ( $cp =~ /utf\-?8/ ) { - $output = encode_utf8( $output ); - } - else { - $output = encode( $cp, $output ); - } - - return $output; -} - -# Detect terminal input and output encodings -sub detect_encodings { - my ( $input_cp, $output_cp ); - - if ( $^O =~ /Win/ ) { - # Read encoding from registry - require Win32API::Registry; - Win32API::Registry->import( qw( :ALL ) ); - - my ( $key, $type, $data ); - RegOpenKeyEx( HKEY_LOCAL_MACHINE(), 'SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage', 0, KEY_READ(), $key ) - or die "Can't read system encodings from registry: ".regLastError(); - RegQueryValueEx( $key, 'ACP', [], $type, $data, [] ) - or die "Can't read system encodings from registry: ".regLastError(); - $input_cp = 'cp'.$data; - RegQueryValueEx( $key, 'OEMCP', [], $type, $data, [] ) - or die "Can't read system encodings from registry: ".regLastError(); - $output_cp = 'cp'.$data; - } else { - # Read encoding from environment - my $cp = $ENV{LANG}; - if ( $cp ) { - $cp =~ s/^[a-z]{2}_[A-Z]{2}[.]//; - } - else { - $cp = 'utf-8'; - } - - $input_cp = $output_cp = lc $cp; - } - - return $input_cp, $output_cp; -} - -# Prepare domain name -sub prepare_domain { - my ($dom, $input_cp) = @_; - - # Decode command-line input - $dom = decode($input_cp, $dom); - - # Lowercase latin and cyrillic characters - $dom =~ tr/A-ZА-ЯЁ\xAA\xA5\xB2\xAF/a-zа-яё\xBA\xB4\xB3\xBF/; - - return $dom; -} - -# Decode domain name to punycode if needed -sub to_punycode { - my ($dom) = @_; - - unless ($dom =~ /^[a-z0-9.\-]*$/) { - # Convert to Punycode - my @parts; - foreach my $part (split /\./, $dom) { - $part = 'xn--'.Net::IDN::Punycode::encode_punycode( $part ) - unless $part =~ /^[a-z0-9.-]*$/; - push @parts, $part; - } - $dom = join('.', @parts); - } - - return $dom; -} - -# Validate domain name -sub validate_domain { - my ($dom) = @_; - - return 0 unless $dom; - - $dom =~ /(.+?)\.([^.]+)$/; - my ($name, $tld) = ($1, $2); - - return 0 if $name =~ /^-/; - return 0 if $name =~ /-$/; - return 0 if $name =~ /^..--/ && $dom !~ /^xn--/; - - # Only latin and cyrillic characters allowed now - return 0 if $dom =~ m/[^-a-z0-9\.ёа-я\xAA\xBA\xB4\xB2\xB3\xAF\xBF\xA1\xA2]/; - - return 1; -} - -__END__ - -=head1 NAME - -pwhois - Perl written whois client - -=head1 SYNOPSIS - - pwhois perl.com - pwhois gnu.org - pwhois -s police.co.il - pwhois -c there.is.no.tld.called.foobar - pwhois yahoo.com whois.networksolutions.com - pwhois -T 10 funet.fi - -etc etc..... - -=head1 DESCRIPTION - -Just invoke with a domain name, optionally with a whois server name. -Switches: - B<-s> attempt to strip the copyright message or disclaimer. - B<-c> attempts to return an empty answer for failed searches. - B<-e> forces die if connection rate to server have been exceeded. - B<-T> set timeout for connection attempts - B<-t> enables caching. - B<-a> specify an ip address that should be used as source address - B<-d> enables debugging messages. - B<-F> returns results of the first query of recursive whois requests - B<-L> returns results of the last query of recursive whois requests (the default) - B<-A> returns results of the all queries of recursive whois requests - -=head1 AUTHORS - -Ariel Brosh B<sc...@cpan.org> - -Current Maintainer: Walery Studennikov B<desp...@cpan.org> - -=head1 SEE ALSO - -L<Net::Whois::Raw>.