import Net::Whois::Raw into install/5.005 directory *sigh*
authorivan <ivan>
Wed, 7 Apr 2004 09:08:34 +0000 (09:08 +0000)
committerivan <ivan>
Wed, 7 Apr 2004 09:08:34 +0000 (09:08 +0000)
install/5.005/Net-Whois-Raw/COPYRIGHT [new file with mode: 0644]
install/5.005/Net-Whois-Raw/Changes [new file with mode: 0644]
install/5.005/Net-Whois-Raw/MANIFEST [new file with mode: 0644]
install/5.005/Net-Whois-Raw/META.yml [new file with mode: 0644]
install/5.005/Net-Whois-Raw/Makefile.PL [new file with mode: 0755]
install/5.005/Net-Whois-Raw/README [new file with mode: 0644]
install/5.005/Net-Whois-Raw/lib/Net/Whois/Raw.pm [new file with mode: 0644]
install/5.005/Net-Whois-Raw/lib/Net/Whois/Raw/Data.pm [new file with mode: 0644]
install/5.005/Net-Whois-Raw/pwhois [new file with mode: 0755]
install/5.005/Net-Whois-Raw/t/01.t [new file with mode: 0644]

diff --git a/install/5.005/Net-Whois-Raw/COPYRIGHT b/install/5.005/Net-Whois-Raw/COPYRIGHT
new file mode 100644 (file)
index 0000000..78fd312
--- /dev/null
@@ -0,0 +1,7 @@
+Copyright 2003-2003 Walery Studennikov
+Copyright 2003-2003 Corris Randall
+Copyright 2003-2003 Gabor Szabo
+Copyright 2000-2002 Ariel Brosh
+
+This package is free software. You may redistribute it or modify it under
+the same terms as Perl itself.
diff --git a/install/5.005/Net-Whois-Raw/Changes b/install/5.005/Net-Whois-Raw/Changes
new file mode 100644 (file)
index 0000000..68310b0
--- /dev/null
@@ -0,0 +1,53 @@
+Revision history for Perl extension Net::Whois::Raw.
+
+0.01  Jul 05 12:35:47 2000
+       - original version; created by h2xs 1.19
+
+0.02 - 0.22  ???
+       -  ???
+
+0.23  Mar 25 09:23:37 PST 2003
+       - only exports &whois by default, the other variables are exportable still.
+       - incorporated new whois servers ( thanks Toni Mueller <support@oeko.net> )
+       - now tests the main tlds
+       - added some more regexen to strip out disclaimers and such ( for $OMIT_MSG > 2 ).
+       - moved %servers to %Net::Whois::Raw::Data::servers
+
+0.24  Nov 18 2003      Walery Studennikov <despair@cpan.org>
+       - fixed whois server for .org domains and add new whois servers
+         for multilingual domains
+       - fixed recursive whois requests for .org domains
+       - new fail-check and strip patterns added
+       - more verbose error messages
+       - added support for third level domains
+       - some bugfixes
+
+0.25  Nov 21 2003      Walery Studennikov <despair@cpan.org>
+       - fixed multilingual domains whois via whois.melbourneit.com server
+       - whois_config function for setting config variables
+         (if setting imported variables $OMIT_MSG, $CHECK_FAIL etc.
+         doesn't work for some reason, for example because of
+         namespace problems in mod_perl scripts)
+
+0.26  Jan 09 2004      Walery Studennikov <despair@cpan.org>
+       - added recursive whois requests for .cc domains
+       - fixed recursive whois requests for whois.crsnic.net
+
+0.27  Feb 10 2004      Alex Kapranoff <alex@kapranoff.ru>
+       - patch to check availability of .info and .biz domains
+
+0.28  Feb 20 2004      Alex Kapranoff <alex@kapranoff.ru>
+       - fixed documentation for pwhois.PL
+
+0.29  Feb 24 2004      Walery Studennikov <despair@cpan.org>
+       - fixed extra rules which strips the copyright message or disclaimer
+       - removed pwhois.PL. "pwhois" is shipped now instead.
+       - data structures in Net/Whois/Raw/Data.pm reformatted
+       - new strip patterns for whois.crsnic.net
+
+
+0.30  Mar 15 2004      Walery Studennikov <despair@cpan.org>
+       - added strip rules for whois.dns.be
+
+0.31  Mar 19 2004      Walery Studennikov <despair@cpan.org>
+       - more robust recursive whois queries
diff --git a/install/5.005/Net-Whois-Raw/MANIFEST b/install/5.005/Net-Whois-Raw/MANIFEST
new file mode 100644 (file)
index 0000000..643f3ce
--- /dev/null
@@ -0,0 +1,10 @@
+Changes
+MANIFEST
+Makefile.PL
+lib/Net/Whois/Raw.pm
+lib/Net/Whois/Raw/Data.pm
+t/01.t
+pwhois
+README
+COPYRIGHT
+META.yml                                Module meta-data (added by MakeMaker)
diff --git a/install/5.005/Net-Whois-Raw/META.yml b/install/5.005/Net-Whois-Raw/META.yml
new file mode 100644 (file)
index 0000000..56efaa6
--- /dev/null
@@ -0,0 +1,11 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Net-Whois-Raw
+version:      0.29
+version_from: lib/Net/Whois/Raw.pm
+installdirs:  site
+requires:
+    IO::Socket:                    1
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
diff --git a/install/5.005/Net-Whois-Raw/Makefile.PL b/install/5.005/Net-Whois-Raw/Makefile.PL
new file mode 100755 (executable)
index 0000000..abd0ca3
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+
+sub MY::postamble {
+        package MY;
+        shift->SUPER::postamble . <<'MAKE';
+dist : README
+
+README : lib/Net/Whois/Raw.pm
+       @$(PERL) -MPod::Text -e "pod2text('$<');" > $@
+
+MAKE
+}
+
+WriteMakefile(
+    'NAME'     => 'Net::Whois::Raw',
+    'VERSION_FROM' => 'lib/Net/Whois/Raw.pm', # finds $VERSION
+    'PREREQ_PM' => {'IO::Socket' => 1.0},
+    'EXE_FILES' => ['pwhois'],
+    'dist' => {'COMPRESS' => 'gzip --best --force'},
+);
diff --git a/install/5.005/Net-Whois-Raw/README b/install/5.005/Net-Whois-Raw/README
new file mode 100644 (file)
index 0000000..916a53f
--- /dev/null
@@ -0,0 +1,129 @@
+NAME
+    Net::Whois::Raw - Perl extension for unparsed raw whois information
+
+SYNOPSIS
+      use Net::Whois::Raw qw( whois );
+  
+      $s = whois('perl.com');
+      $s = whois('funet.fi');
+      $s = whois('yahoo.co.uk');
+
+            ### if you do "use Net::Whois::Raw qw( whois $OMIT_MSG $CHECK_FAIL 
+            ###              $CACHE_DIR $CACHE_TIME $USE_CNAMES $TIMEOUT );
+            ### you can use these:
+
+      $OMIT_MSG = 1; # This will attempt to strip several known copyright
+                    messages and disclaimers sorted by servers.
+                    Default is to give the whole response.
+
+      $OMIT_MSG = 2; # This will try some additional stripping rules
+                    if none are known for the spcific server.
+
+      $CHECK_FAIL = 1; # This will return undef if the response matches
+                    one of the known patterns for a failed search,
+                    sorted by servers.
+                    Default is to give the textual response.
+
+      $CHECK_FAIL = 2; # This will match against several more rules
+                    if none are known for the specific server.
+
+      $CACHE_DIR = "/var/spool/pwhois/"; # Whois information will be
+                    cached in this directory. Default is no cache.
+
+      $CACHE_TIME = 24; # Cache files will be cleared after not accessed
+                    for a specific number of hours. Documents will not be
+                    cleared if they keep get requested for, independent
+                    of disk space. Default is not to clear the cache.
+
+      $USE_CNAMES = 1; # Use whois-servers.net to get the whois server
+                    name when possible. Default is to use the 
+                    hardcoded defaults.
+
+      $TIMEOUT = 10; # Cancel the request if connection is not made within
+                    a specific number of seconds.
+
+      Note: as of version 0.21, extra data will be loaded only if the
+      OMIT_MSG or CHECK_FAIL flags were used, in order to reduce memory usage.
+
+DESCRIPTION
+    Net::Whois::Raw queries NetworkSolutions and follows the Registrar:
+    answer for ORG, EDU, COM and NET domains. For other TLDs it uses the
+    whois-servers.net namespace. ($TLD.whois-servers.net).
+
+    Setting the variables $OMIT_MSG and $CHECK_FAIL will match the results
+    against a set of known patterns. The first flag will try to omit the
+    copyright message/disclaimer, the second will attempt to determine if
+    the search failed and return undef in such a case.
+
+    IMPORTANT: these checks merely use pattern matching; they will work on
+    several servers but certainly not on all of them.
+
+    (This features were contributed by Walery Studennikov despair@sama.ru)
+
+AUTHOR
+    Original author Ariel Brosh, schop@cpan.org, Inspired by jwhois.pl
+    available on the net.
+
+    Since Ariel has passed away in September 2002:
+
+    Past maintainers Gabor Szabo, gabor@perl.org.il, Corris Randall
+    corris@cpan.org
+
+    Current Maintainer: Walery Studennikov despair@cpan.org
+
+CREDITS
+    Fixed regular expression to match hyphens. (Peter Chow,
+    peter@interq.or.jp)
+
+    Added support for Tonga TLD. (.to) (Peter Chow, peter@interq.or.jp)
+
+    Added support for reverse lookup of IP addresses via the ARIN registry.
+    (Alex Withers awithers@gonzaga.edu)
+
+    This will work now for RIPE addresses as well, according to a
+    redirection from ARIN. (Philip Hands phil@uk.alcove.com, Trevor Peirce
+    trev@digitalcon.ca)
+
+    Added the pattern matching switches, (Walery Studennikov
+    despair@sama.ru)
+
+    Modified pattern matching, added cache. (Tony L. Svanstrom
+    tony@svanstrom.org)
+
+CHANGES
+    See file "Changes" in the distribution
+
+CLARIFICATION
+    As NetworkSolutions got most of the domains of InterNic as legacy, we
+    start by querying their server, as this way one whois query would be
+    sufficient for many domains. Starting at whois.internic.net or
+    whois.crsnic.net will result in always two requests in any case.
+
+NOTE
+    Some users complained that the die statements in the module make their
+    CGI scripts crash. Please consult the entries on eval and die on
+    perlfunc about exception handling in Perl.
+
+COPYRIGHT
+    Copyright 2000-2002 Ariel Brosh. Copyright 2003-2003 Gabor Szabo.
+    Copyright 2003-2003 Corris Randall. Copyright 2003-2003 Walery
+    Studennikov.
+
+    This package is free software. You may redistribute it or modify it
+    under the same terms as Perl itself.
+
+    I apologize for any misunderstandings caused by the lack of a clear
+    licence in previous versions.
+
+COMMERCIAL SUPPORT
+    Not available anymore.
+
+LEGAL
+    Notice that registrars forbid querying their whois servers as a part of
+    a search engine, or querying for a lot of domains by script. Also,
+    omitting the copyright information (that was requested by users of this
+    module) is forbidden by the registrars.
+
+SEE ALSO
+    perl(1), Net::Whois, whois.
+
diff --git a/install/5.005/Net-Whois-Raw/lib/Net/Whois/Raw.pm b/install/5.005/Net-Whois-Raw/lib/Net/Whois/Raw.pm
new file mode 100644 (file)
index 0000000..04db671
--- /dev/null
@@ -0,0 +1,393 @@
+package Net::Whois::Raw;
+
+require Net::Whois::Raw::Data;
+
+use strict;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $OMIT_MSG $CHECK_FAIL
+       %notfound %strip $CACHE_DIR $CACHE_TIME $USE_CNAMES
+       $TIMEOUT);
+use IO::Socket;
+
+require Exporter;
+
+@ISA = qw(Exporter);
+
+@EXPORT    = qw( whois whois_config ); ### It's bad manners to export lots.
+@EXPORT_OK = qw( $OMIT_MSG $CHECK_FAIL $CACHE_DIR $CACHE_TIME $USE_CNAMES $TIMEOUT);
+
+$VERSION = '0.31';
+
+($OMIT_MSG, $CHECK_FAIL, $CACHE_DIR, $CACHE_TIME, $USE_CNAMES, $TIMEOUT) = (0) x 6;
+
+sub whois {
+    my ($dom, $srv) = @_;
+    my $res;
+    unless ($srv) {
+        ($res, $srv) = query($dom);
+    } else {
+        $res = _whois($dom, uc($srv));
+    }
+    finish($res, $srv);
+}
+
+sub whois_config {
+    my ($par) = @_;
+    my @parnames = qw(OMIT_MSG CHECK_FAIL CACHE_DIR CACHE_TIME USE_CNAMES TIMEOUT);
+    foreach my $parname (@parnames) {
+       if (exists($par->{$parname})) {
+           eval('$'.$parname.'='.int($par->{$parname}));
+       }
+    }
+}
+
+sub query {
+    my $dom = shift;
+    my $tld;
+    if ($dom =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) {
+        $tld = "IP";
+    } else { 
+       my @alltlds = keys %Net::Whois::Raw::Data::servers;
+       @alltlds = sort { dlen($b) <=> dlen($a) } @alltlds;
+       foreach my $awailtld (@alltlds) {
+           $awailtld = lc $awailtld;
+           if ($dom =~ /(.+?)\.($awailtld)$/) {
+               $tld = uc $2;
+               last;
+           }
+       }
+       unless ($tld) {
+           my @tokens = split(/\./, $dom);
+           $tld = uc($tokens[-1]); 
+       }
+    }
+
+
+    $dom =~ s/.NS$//i;
+    my $cname = "$tld.whois-servers.net";
+    my $srv = $Net::Whois::Raw::Data::servers{$tld} || $cname;
+    $srv = $cname if $USE_CNAMES && gethostbyname($cname);
+    my $flag = (
+       $srv eq 'whois.crsnic.net' ||
+       $srv eq 'whois.publicinterestregistry.net' ||
+       $srv eq 'whois.nic.cc' ||
+       $tld eq 'ARPA'
+    );
+    my $res = do_whois($dom, uc($srv), $flag, [], $tld);
+    wantarray ? ($res, $srv) : $res;
+}
+
+sub do_whois {
+    my ($dom) = @_; # receives 4 parameters, do NOT shift
+    return _whois(@_) unless $CACHE_DIR;
+    mkdir $CACHE_DIR, 0644;
+    if (-f "$CACHE_DIR/$dom") {
+        if (open(I, "$CACHE_DIR/$dom")) {
+            my $res = join("", <I>);
+            close(I);
+            return $res;
+        }
+    }
+    my $res = _whois(@_);
+    return $res unless $res;
+    return $res unless open(O, ">$CACHE_DIR/$dom");
+    print O $res;
+    close(O);
+
+
+    return $res unless $CACHE_TIME;
+
+    my $now = time;
+    foreach (glob("$CACHE_DIR/*.*")) {
+        my $atime = (stat($_))[8];
+        my $elapsed = $now - $atime;
+        unlink $_ if ($elapsed / 3600 > $CACHE_TIME); 
+    }
+    $res;
+}
+
+sub finish {
+    my ($text, $srv) = @_;
+    return $text unless $CHECK_FAIL || $OMIT_MSG;
+    *notfound = \%Net::Whois::Raw::Data::notfound;
+    *strip = \%Net::Whois::Raw::Data::strip;
+
+    my $notfound = $notfound{lc($srv)};
+    my @strip = $strip{lc($srv)} ? @{$strip{lc($srv)}} : ();
+    my @lines;
+    MAIN: foreach (split(/\n/, $text)) {
+        return undef if $CHECK_FAIL && $notfound && /$notfound/;
+        if ($OMIT_MSG) {
+            foreach my $re (@strip) {
+                next MAIN if (/$re/);
+            }
+        }
+        push(@lines, $_);
+    }
+    local ($_) = join("\n", @lines, "");
+
+    if ($CHECK_FAIL > 1) {
+       return undef unless check_existance($_);
+    }
+
+    if ($OMIT_MSG > 1) {       
+        s/The Data.+(policy|connection)\.\n//is;
+        s/% NOTE:.+prohibited\.//is;
+        s/Disclaimer:.+\*\*\*\n?//is;
+        s/NeuLevel,.+A DOMAIN NAME\.//is;
+        s/For information about.+page=spec//is;
+        s/NOTICE: Access to.+this policy.//is;
+        s/The previous information.+completeness\.//s;
+        s/NOTICE AND TERMS OF USE:.*modify these terms at any time\.//s;
+        s/TERMS OF USE:.*?modify these terms at any time\.//s;
+        s/NOTICE:.*expiration for this registration\.//s;
+
+       s/By submitting a WHOIS query.+?DOMAIN AVAILABILITY.\n?//s;
+       s/Registration and WHOIS.+?its accuracy.\n?//s;
+        s/Disclaimer:.+?\*\*\*\n?//s;
+       s/The .COOP Registration .+ Information\.//s;
+       s/Whois Server Version \d+\.\d+.//is;
+       s/NeuStar,.+www.whois.us\.//is;
+        s/\n?Domain names in the \.com, .+ detailed information.\n?//s;
+        s/\n?The Registry database .+?Registrars\.\n//s;
+        s/\n?>>> Last update of .+? <<<\n?//;
+        s/% .+?\n//gs;
+    }
+    $_;
+}
+
+sub _whois {
+    my ($dom, $srv, $flag, $ary, $tld) = @_;
+    my $state;
+
+    my $sock;
+    eval {
+        local $SIG{'ALRM'} = sub { die "Connection timeout to $srv" };
+        alarm $TIMEOUT if $TIMEOUT;
+        $sock = new IO::Socket::INET("$srv:43") || die "$srv: $!";
+    };
+    alarm 0;
+    die $@ if $@;
+    my $israce = $dom =~ /ra--/ || $dom =~ /bq--/;
+    my $whoisquery = $dom;
+    if ($srv eq 'WHOIS.MELBOURNEIT.COM' && $israce) {
+       $whoisquery .= ' race';
+    }
+    #warn "$srv: $whoisquery ($OMIT_MSG, $CHECK_FAIL, $CACHE_DIR, $CACHE_TIME, $USE_CNAMES, $TIMEOUT)\n";
+    print $sock "$whoisquery\r\n";
+    my @lines = <$sock>;
+    close($sock);
+    my $answer = join '', @lines;
+    if ($flag) {
+        foreach (@lines) {
+            $state ||= (/Registrar:/);
+            if ( $state && /Whois Server:\s*([A-Za-z0-9\-_\.]+)/ ) {
+                my $newsrv = uc("$1");
+                next if (($newsrv) eq uc($srv));
+                return undef if (grep {$_ eq $newsrv} @$ary);
+               my $whois = eval { _whois($dom, $newsrv, $flag, [@$ary, $srv]) };
+               if ($@ && !$whois || $whois && !check_existance($whois)) {
+                   return $answer;
+               }
+                return $whois;
+            }
+            if (/^\s+Maintainer:\s+RIPE\b/ && $tld eq 'ARPA') {
+                my $newsrv = uc($Net::Whois::Raw::Data::servers{'RIPE'});
+                next if ($newsrv eq $srv);
+                return undef if (grep {$_ eq $newsrv} @$ary);
+                my $whois = eval { _whois($dom, $newsrv, $flag, [@$ary, $srv]) };
+               if ($@ && !$whois) {
+                   return $answer;
+               }
+                return $whois;
+            }
+        }
+    }
+    my $whois = join("", @lines);
+
+    if ($whois =~ /To single out one record, look it up with \"xxx\",/s) {
+        my $newsrv = uc('whois.networksolutions.com');
+        return _whois($dom, $newsrv, $flag, [@{$ary||[]}, $srv]);
+    }
+    
+    return $whois;
+}
+
+sub dlen {
+    my ($str) = @_;
+    my $dotcount = $str =~ tr/././;
+    return length($str) * (1 + $dotcount);
+}
+
+
+sub check_existance {
+    $_ = $_[0];
+
+    return undef if
+       /is unavailable/is ||
+       /No entries found for the selected source/is ||
+       /Not found:/s ||
+       /No match\./s ||
+       /is available/is ||
+       /Not found/is &&
+           !/ your query returns "NOT FOUND"/ &&
+           !/Domain not found locally/ ||
+       /No match for/is ||
+       /No Objects Found/s ||
+       /No domain records were found/s ||
+       /No such domain/s ||
+       /No entries found in the /s ||
+       /Unable to find any information for your query/s ||
+       /is not registered and may be available for registration/s;
+    return 1;
+}
+
+
+# Preloaded methods go here.
+
+# Autoload methods go after =cut, and are processed by the autosplit program.
+
+1;
+__END__
+# Below is the stub of documentation for your module. You better edit it!
+
+=head1 NAME
+
+Net::Whois::Raw - Perl extension for unparsed raw whois information
+
+=head1 SYNOPSIS
+
+  use Net::Whois::Raw qw( whois );
+  
+  $s = whois('perl.com');
+  $s = whois('funet.fi');
+  $s = whois('yahoo.co.uk');
+
+       ### if you do "use Net::Whois::Raw qw( whois $OMIT_MSG $CHECK_FAIL 
+       ###              $CACHE_DIR $CACHE_TIME $USE_CNAMES $TIMEOUT );
+       ### you can use these:
+
+  $OMIT_MSG = 1; # This will attempt to strip several known copyright
+               messages and disclaimers sorted by servers.
+               Default is to give the whole response.
+
+  $OMIT_MSG = 2; # This will try some additional stripping rules
+               if none are known for the spcific server.
+
+  $CHECK_FAIL = 1; # This will return undef if the response matches
+               one of the known patterns for a failed search,
+               sorted by servers.
+               Default is to give the textual response.
+
+  $CHECK_FAIL = 2; # This will match against several more rules
+               if none are known for the specific server.
+
+  $CACHE_DIR = "/var/spool/pwhois/"; # Whois information will be
+               cached in this directory. Default is no cache.
+
+  $CACHE_TIME = 24; # Cache files will be cleared after not accessed
+               for a specific number of hours. Documents will not be
+               cleared if they keep get requested for, independent
+               of disk space. Default is not to clear the cache.
+
+  $USE_CNAMES = 1; # Use whois-servers.net to get the whois server
+               name when possible. Default is to use the 
+               hardcoded defaults.
+
+
+  $TIMEOUT = 10; # Cancel the request if connection is not made within
+               a specific number of seconds.
+
+  Note: as of version 0.21, extra data will be loaded only if the
+  OMIT_MSG or CHECK_FAIL flags were used, in order to reduce memory usage.
+
+=head1 DESCRIPTION
+
+Net::Whois::Raw queries NetworkSolutions and follows the Registrar: answer
+for ORG, EDU, COM and NET domains.
+For other TLDs it uses the whois-servers.net namespace.
+(B<$TLD>.whois-servers.net).
+
+Setting the variables $OMIT_MSG and $CHECK_FAIL will match the results
+against a set of known patterns. The first flag will try to omit the
+copyright message/disclaimer, the second will attempt to determine if
+the search failed and return undef in such a case.
+
+B<IMPORTANT>: these checks merely use pattern matching; they will work
+on several servers but certainly not on all of them.
+
+(This features were contributed by Walery Studennikov B<despair@sama.ru>)
+
+=head1 AUTHOR
+
+Original author Ariel Brosh, B<schop@cpan.org>, 
+Inspired by jwhois.pl available on the net.
+
+Since Ariel has passed away in September 2002:
+
+Past maintainers Gabor Szabo, B<gabor@perl.org.il>,
+Corris Randall B<corris@cpan.org>
+
+Current Maintainer: Walery Studennikov B<despair@cpan.org>
+
+=head1 CREDITS
+
+Fixed regular expression to match hyphens. (Peter Chow,
+B<peter@interq.or.jp>)
+
+Added support for Tonga TLD. (.to) (Peter Chow, B<peter@interq.or.jp>)
+
+Added support for reverse lookup of IP addresses via the ARIN registry. (Alex Withers B<awithers@gonzaga.edu>)
+
+This will work now for RIPE addresses as well, according to a redirection from ARIN. (Philip Hands B<phil@uk.alcove.com>, Trevor Peirce B<trev@digitalcon.ca>)
+
+Added the pattern matching switches, (Walery Studennikov B<despair@sama.ru>)
+
+Modified pattern matching, added cache. (Tony L. Svanstrom B<tony@svanstrom.org>)
+
+=head1 CHANGES
+
+See file "Changes" in the distribution
+
+
+=head1 CLARIFICATION
+
+As NetworkSolutions got most of the domains of InterNic as legacy, we
+start by querying their server, as this way one whois query would be
+sufficient for many domains. Starting at whois.internic.net or
+whois.crsnic.net will result in always two requests in any case.
+
+=head1 NOTE
+
+Some users complained that the B<die> statements in the module make their
+CGI scripts crash. Please consult the entries on B<eval> and
+B<die> on L<perlfunc> about exception handling in Perl.
+
+=head1 COPYRIGHT
+
+Copyright 2000-2002 Ariel Brosh.
+Copyright 2003-2003 Gabor Szabo.
+Copyright 2003-2003 Corris Randall.
+Copyright 2003-2003 Walery Studennikov.
+
+This package is free software. You may redistribute it or modify it under
+the same terms as Perl itself.
+
+I apologize for any misunderstandings caused by the lack of a clear
+licence in previous versions.
+
+=head1 COMMERCIAL SUPPORT
+
+Not available anymore.
+
+=head1 LEGAL
+
+Notice that registrars forbid querying their whois servers as a part of
+a search engine, or querying for a lot of domains by script. 
+Also, omitting the copyright information (that was requested by users of this 
+module) is forbidden by the registrars.
+
+=head1 SEE ALSO
+
+L<perl(1)>, L<Net::Whois>, L<whois>.
+
+=cut
diff --git a/install/5.005/Net-Whois-Raw/lib/Net/Whois/Raw/Data.pm b/install/5.005/Net-Whois-Raw/lib/Net/Whois/Raw/Data.pm
new file mode 100644 (file)
index 0000000..7b51e25
--- /dev/null
@@ -0,0 +1,509 @@
+package Net::Whois::Raw::Data;
+
+use strict;
+use vars qw(%notfound %strip);
+
+our %servers = qw(
+    COM    whois.crsnic.net
+    NET    whois.crsnic.net
+    EDU    whois.educause.net
+    ORG    whois.publicinterestregistry.net
+    ARPA   whois.arin.net
+    RIPE   whois.ripe.net
+    MIL    whois.nic.mil
+    COOP   whois.nic.coop
+    MUSEUM whois.museum
+
+    BIZ    whois.neulevel.biz
+    INFO   whois.afilias.net
+    NAME   whois.nic.name
+    GOV    whois.nic.gov
+    AERO   whois.information.aero
+    NS     whois.internic.net
+    IP     whois.ripe.net
+
+    AD  whois.ripe.net
+    AL  whois.ripe.net
+    AM  whois.ripe.net
+    AS  whois.gdns.net
+    AT  whois.nic.at
+    AU  box2.aunic.net
+    AZ  whois.ripe.net
+    BA  whois.ripe.net
+    BE  whois.dns.be
+    BG  whois.ripe.net
+    BR  whois.nic.br
+    BY  whois.ripe.net
+    CA  eider.cira.ca
+    CC  whois.nic.cc
+    CH  domex.switch.ch
+    CK  whois.ck-nic.org.ck
+    CL  nic.cl
+    CN  log.cnnic.net.cn
+    CX  whois.nic.cx
+    CY  whois.ripe.net
+    CZ  dc1.eunet.cz
+    DE  whois.denic.de
+    DK  whois.dk-hostmaster.dk
+    DO  ns.nic.do
+    DZ  whois.ripe.net
+    EE  whois.ripe.net
+    EG  whois.ripe.net
+    ES  whois.ripe.net
+    FI  whois.ripe.net
+    FO  whois.ripe.net
+    FR  winter.nic.fr
+    GA  whois.ripe.net
+    GB  whois.ripe.net
+    GE  whois.ripe.net
+    GL  whois.ripe.net
+    GM  whois.ripe.net
+    GR  whois.ripe.net
+    GS  whois.adamsnames.tc
+    HK  whois.hkdnr.net.hk
+    HR  whois.ripe.net
+    HU  whois.nic.hu
+    ID  muara.idnic.net.id
+    IE  whois.domainregistry.ie
+    IL  whois.isoc.org.il
+    IN  whois.ncst.ernet.in
+    IS  horus.isnic.is
+    IT  whois.nic.it
+    JO  whois.ripe.net
+    JP  whois.nic.ad.jp
+    KG  whois.domain.kg
+    KH  whois.nic.net.kh
+    KR  whois.krnic.net
+    LA  whois.nic.la
+    LI  domex.switch.ch
+    LK  arisen.nic.lk
+    LT  ns.litnet.lt
+    LU  whois.dns.lu
+    LV  whois.ripe.net
+    MA  whois.ripe.net
+    MC  whois.ripe.net
+    MD  whois.ripe.net
+    MM  whois.nic.mm
+    MS  whois.adamsnames.tc
+    MT  whois.ripe.net
+    MX  whois.nic.mx
+    NL  gw.domain-registry.nl
+    NO  ask.norid.no
+    NU  whois.worldnames.net
+    NZ  akl-iis.domainz.net.nz
+    PL  nazgul.nask.waw.pl
+    PT  whois.ripe.net
+    RO  whois.rotld.ro
+    RU  whois.ripn.net
+    SE  ear.nic-se.se
+    SG  qs.nic.net.sg
+    SH  whois.nic.sh
+    SI  whois.arnes.si
+    SK  whois.ripe.net
+    SM  whois.ripe.net
+    ST  whois.nic.st
+    SU  whois.ripn.net
+    TC  whois.adamsnames.tc
+    TF  whois.adamsnames.tc
+    TH  whois.thnic.net
+    TJ  whois.nic.tj
+    TN  whois.ripe.net
+    TO  whois.tonic.to
+    TR  whois.ripe.net
+    TW  whois.twnic.net
+    UA  whois.net.ua
+    UK  whois.nic.uk
+    US  whois.nic.us
+    VA  whois.ripe.net
+    VG  whois.adamsnames.tc
+    WS  whois.worldsite.ws
+    YU  whois.ripe.net
+    ZA  apies.frd.ac.za
+
+    RA--AQ5D4PA        whois.i-dns.net
+    RA--AQ6TKQQ        whois.i-dns.net
+    RA--AQ7EAMY        whois.i-dns.net
+    XN--P1AG   ru.whois.i-dns.net
+    XN--P1AG   ru.whois.i-dns.net
+    XN--J1AEF  whois.i-dns.net
+    XN--E1APQ  whois.i-dns.net
+    XN--C1AVG  whois.i-dns.net
+
+    NET.RU     whois.ripn.net
+    ORG.RU     whois.ripn.net
+    PP.RU      whois.ripn.net
+    SPB.RU     whois.relcom.ru
+    MSK.RU     whois.relcom.ru
+    RU.NET     whois.relcom.ru
+);
+
+# These do not seem to work
+#         CN  log.cnnic.net.cn
+#         DK  whois.dk-hostmaster.dk
+#         US  whois.isi.edu
+# These serve only several subdomains
+#         ZA  apies.frd.ac.za
+
+
+%notfound = (
+    'whois.nic.cc' => '^No match for',
+    'whois.arin.net' => '^No match for',
+    'whois.nic.br' => 'No match for',
+    'ear.nic-se.se' => 'No data found',
+    'whois.nic.sh' => '^No match for',
+    'whois.nic.mx' => '^Nombre del Dominio:',
+    'whois.domainregistry.ie' => 'There was no match',
+    'domex.switch.ch' => '^We do not have an entry in our database matching your',
+    'whois.dns.lu' => 'No entries found',
+    'whois.worldsite.ws' => 'No match for',
+    'whois.nic.it' => '^No entries found',
+    'whois.nic.coop' => 'No Objects Found',
+    'whois.nic.at' => 'nothing found',
+    'ask.norid.no' => 'no matches',
+    'whois.nic.uk' => '^\\s*No match for',
+    'whois.nic.ad.jp' => 'No match',
+    'whois.arnes.si' => 'No entries found',
+    'whois.tonic.to' => 'No match for',
+    'whois.hkdnr.net.hk' => '^No Match for',
+    'whois.worldnames.net' => 'NO MATCH for domain',
+    'whois.rotld.ro' => 'No entries found',
+    'whois.nic.st' => '^No entries found',
+    'whois.isoc.org.il' => 'No data was found',
+    'eider.cira.ca' => 'Status:\\s*UNAV',
+    'whois.nic.tj' => '^No match for',
+    'aardvark.dns.be' => 'No such domain',
+    'nazgul.nask.waw.pl' => '^Domain name .* does not exists',
+    'whois.ncst.ernet.in' => '^No matches',
+    'whois.krnic.net' => 'Above domain name is not registered',
+    'whois.museum' => '^No information for',
+    'whois.net.ua' => 'No entries found',
+    'apies.frd.ac.za' => 'No information is available',
+    'gw.domain-registry.nl' => 'invalid query',
+    'whois.denic.de' => 'No entries found',
+    'whois.nic.mil' => '^No match for',
+    'horus.isnic.is' => 'No entries found',
+    'winter.nic.fr' => 'No entries found',
+    'whois.ripe.net' => 'No entries found',
+    'whois.ripn.net' => 'No entries found',
+    'qs.nic.net.sg' => 'NO entry found',
+    'whois.twnic.net' => '^NO MATCH: This domain is',
+    'nic.cl' => 'Invalid domain name',
+    'whois.gdns.net' => '^Domain Not Found',
+    'box2.aunic.net' => 'No entries found',
+    'whois.nic.cx' => '^No match for',
+    'dc1.eunet.cz' => 'No data found',
+    'akl-iis.domainz.net.nz' => 'domain_name_status: 00 Not Listed',
+    'ns.litnet.lt' => 'No matches found',
+    'whois.adamsnames.tc' => 'is not a domain controlled by',
+    'whois.nic.la' => '^NO MATCH for',
+    'whois.networksolutions.com' => '(?i)no match',
+    'whois.thnic.net' => 'No entries found',
+    'whois.neulevel.biz' => '^Not found:',
+    'whois.afilias.net' => '^NOT FOUND',
+);
+
+%strip = (
+    'whois.crsnic.net' => [
+       '^TERMS OF USE:',
+       '^database through',
+       '^automated except',
+       '^modify existing',
+       '^Services\' \(\"VeriSign\"\)',
+       '^information purposes only',
+       '^about or related to a',
+       '^guarantee its accuracy\.',
+       '^by the following terms',
+       '^for lawful purposes and',
+       '^to: (1) allow, enable,',
+       '^unsolicited, commercial',
+       '^or facsimile; or \(2\)',
+       '^that apply to VeriSign',
+       '^repackaging, dissemination',
+       '^prohibited without the',
+       '^use electronic processes',
+       '^query the Whois database',
+       '^domain names or modify',
+       '^to restrict your access',
+       '^operational stability\.',
+       '^Whois database for',
+       '^reserves the right',
+
+       '^NOTICE AND TERMS OF USE:',
+       '^Data in Network Solutions',
+       '^purposes only, and to assist',
+       '^to a domain name registration',
+       '^By submitting a WHOIS query,',
+       '^You agree that you may use',
+       '^circumstances will you use',
+       '^the transmission of mass',
+       '^via e-mail, telephone, or',
+       '^electronic processes that',
+       '^compilation, repackaging,',
+       '^high-volume, automated,',
+       '^database. Network Solutions',
+       '^database in its sole discretion,',
+       '^querying of the WHOIS database',
+       '^Network Solutions reserves the',
+
+       '^NOTICE: The expiration date',
+       '^registrar\'s sponsorship of',
+       '^currently set to expire\.',
+       '^date of the domain name',
+       '^registrar.  Users may',
+       '^view the registrar\'s',
+       '^to: \(1\) allow, enable,',
+       '^The Registry database',
+       '^Registrars\.',
+       '^Domain not found locally,',
+       '^Local WHOIS DB must be out',
+
+       '^Whois Server Version',
+       '^Domain names in the .com',
+       '^with many different',
+       '^for detailed information\.',
+
+       '^>>> Last update of whois database',
+       '^$',
+    ],
+    'whois.tonic.to' => [
+       '^Tonic whoisd',
+    ],
+    'whois.net.ua' => [
+       '^%',
+    ],
+    'whois.nic.cx' => [
+       '^ Registrar: Christmas Island',
+       '^ Whois Server: whois.nic.cx',
+    ],
+    'gw.domain-registry.nl' => [
+       'Rights restricted by copyright',
+       'http://www.domain-registry.nl',
+    ],
+    'whois.denic.de' => [
+       '^%',
+    ],
+    'whois.gdns.net' => [
+       '^\\w+ Whois Server',
+       '^Access to .* WHOIS information is provided to',
+       '^determining the contents of a domain name',
+       '^registrar database.  The data in',
+       '^informational purposes only, and',
+       '^Compilation, repackaging, dissemination,',
+       '^in its entirety, or a substantial portion',
+       'prior written permission.  By',
+       '^by this policy.  All rights reserved.',
+    ],
+    'whois.isoc.org.il' => [
+       '^%',
+    ],
+    'whois.dns.lu' => [
+       '^%',
+    ],
+    'whois.worldnames.net' => [
+       '^----------------------------------',
+       '^.\\w+ Domain .* Whois service',
+       '^Copyright by .* Domain LTD',
+       '^----------------------------------',
+       '^Database last updated',
+    ],
+    'whois.nic.sh' => [
+       '^NIC Whois Server',
+    ],
+    'whois.nic.coop' => [
+       '^%',
+       '^ The .COOP Registration',
+       '^ Please use the',
+    ],
+    'domex.switch.ch' => [
+       '^whois: This information is subject',
+       '^See http',
+    ],
+    'whois.twnic.net' => [
+       '^Registrar:',
+       '^URL: http://rs.twnic.net.tw',
+    ],
+    'nic.cl' => [
+       '^cl.cl:',
+       '^Más información: http://www.nic.cl/',
+    ],
+    'whois.nic.mx' => [
+       '^------------------',
+       '^La información que ha',
+       '^relacionados con la',
+       '^DNS administrado por el NIC-México.',
+       '^Queda absolutamente prohibido',
+       '^envío de e-mail no solicitado',
+       '^productos y servicios',
+       '^del NIC-México.',
+       '^La base de datos generada',
+       '^protegida por las leyes de',
+       '^internacionales sobre la materia.',
+    ],
+    'whois.domainregistry.ie' => [
+       '^%',
+    ],
+    'ns.litnet.lt' => [
+       '^%',
+    ],
+    'dc1.eunet.cz' => [
+       '^%',
+    ],
+    'whois.ripn.net' => [
+       '^%',
+    ],
+    'whois.nic.uk' => [
+       '^The .* Registration Host contains information',
+       '^registrations in the .*co.uk',
+       'and .*\\.uk second-level domains.',
+    ],
+    'whois.nic.br' => [
+       '^%',
+    ],
+    'whois.krnic.net' => [
+       '^Korea Internet Information Service',
+       '^20\\d\\d³â 7¿ù 2ÀϺÎÅʹ °³¼±µÈ Whois',
+       '^.com, .net, .org',
+    ],
+    'whois.arnes.si' => [
+       '^\\*',
+    ],
+    'nazgul.nask.waw.pl' => [
+       '^%',
+    ],
+    'whois.nic.la' => [
+       '^   WHOIS server',
+       '^   The Data in the',
+       'for information purposes,',
+       '^   and to assist persons in obtaining',
+       '^   domain name registration record. Sterling Holdings, Limited,',
+       '^   does not guarantee its accuracy.',
+       '^   you will use this Data only for lawful',
+       '^   circumstances will you use this Data',
+       '^   \\(1\\) allow, enable, or otherwise s',
+       '^   unsolicited, commercial advertising',
+       '^   \\(spam\\); or',
+       '^   that apply to Sterling Holdings',
+       '^   Sterling Holdings .* reserves the right to modify',
+       '^   terms at any time. By submitting this',
+       '^   policy.',
+    ],
+    'horus.isnic.is' => [
+       '^%',
+    ],
+    'whois.rotld.ro' => [
+       '^%',
+    ],
+    'whois.nic.st' => [
+       '^The data in the .* database is provided',
+       '^The .* Registry does not guarantee',
+       '^The data in the .* database is protected',
+       '^By submitting a .* query, you agree that you will',
+       '^The Domain Council of .* reserves the right',
+    ],
+    'ask.norid.no' => [
+       '^%',
+    ],
+    'whois.hkdnr.net.hk' => [
+       '^Whois server',
+       '^Domain names in the',
+       '^and .* can now be registered',
+       '^Go to http://www.hkdnr.net.hk',
+       '^---------',
+       '^The Registry contains ONLY',
+       '^.* and .*\\.HK domains.',
+    ],
+    'whois.arin.net' => [
+       '^The ARIN Registration Services Host contains',
+       '^Network Information:.*Networks',
+       '^Please use the whois server at',
+       '^Information and .* for .* Information.',
+    ],
+    'qs.nic.net.sg' => [
+       '^\\*',
+    ],
+    'akl-iis.domainz.net.nz' => [
+       '^%',
+    ],
+    'whois.nic.hu' => [
+       '^%',
+    ],
+    'whois.worldsite.ws' => [
+       '^Welcome to the .* Whois Server',
+       '^Use of this service for any',
+       '^than determining the',
+       '^in the .* to be registered',
+       '^prohibited.',
+    ],
+    'whois.ripe.net' => [
+       '^%',
+    ],
+    'whois.nic.cc' => [
+       '^This information is',
+       '^The Data in eNIC',
+       '^Corporation for information',
+       '^in obtaining information',
+       '^registration record',
+       '^accuracy.  By submitting',
+       '^will use this Data only',
+       '^no circumstances will',
+       '^or otherwise support',
+       '^commercial advertising',
+       '^or \\(2\\) enable high volume',
+       '^apply to eNIC Corporation',
+       '^reserves the right to',
+       '^submitting this query,',
+    ],
+    'whois.nic.mil' => [
+       '^To single out one record',
+       '^handle, shown in parenthesis',
+       '^Please be advised that this whois',
+       '^All INTERNET Domain, IP Network Number,',
+       '^the Internet Registry, RS.INTERNIC.NET.',
+    ],
+    'box2.aunic.net' => [
+       '^%',
+    ],
+    'whois.nic.ad.jp' => [
+       '^[',
+    ],
+    'winter.nic.fr' => [
+       '^Tous droits reserves par copyright.',
+       '^Voir http://www.nic.fr',
+       '^Rights restricted by copyright.',
+       '^See http://www.nic.fr/outils',
+    ],
+    'ear.nic-se.se' => [
+       '^#',
+    ],
+    'whois.networksolutions.com' => [
+       '^The Data in',
+       '^Solutions for information',
+       '^information about or',
+       '^Network Solutions does not guarantee',
+       '^WHOIS query, you agree that',
+       '^purposes and that, under no circumstances',
+       '^\\(1\\) allow, enable, or',
+       '^unsolicited, commercial advertising',
+       '^\\(spam\\); or',
+       '^that apply to Network',
+       '^reserves the right',
+       '^this query, you',
+    ],
+    'aardvark.dns.be' => [
+       '^%',
+    ],
+    'whois.dns.be' => [
+       '^%-',
+    ],
+    'whois.nic.tj' => [
+       '^This Whois server looks up only',
+       '^Please see http://nic.tj for more',
+       '^Tajikistan, and the Public Registrar Network.',
+    ],
+    'whois.nic.at' => [
+       '^%',
+    ],
+);
+
+
+1;
diff --git a/install/5.005/Net-Whois-Raw/pwhois b/install/5.005/Net-Whois-Raw/pwhois
new file mode 100755 (executable)
index 0000000..56d9a7e
--- /dev/null
@@ -0,0 +1,106 @@
+#!/usr/bin/perl -w
+
+use Net::Whois::Raw qw( whois $OMIT_MSG $CHECK_FAIL $TIMEOUT $CACHE_DIR );
+use Getopt::Std;
+use strict;
+use vars qw($opt_s $opt_c $opt_S $opt_C $opt_t $opt_T $opt_h);
+
+getopts("scSCtT:h");
+
+if ($opt_h) {
+       print <<EOM;
+       $0 [ -s | -S ] [ -c | -C ] [ -t <timeout> ] [ -T] <domain> [ <server> ]
+
+The -s switch attempts to strip the copyright message or disclaimer.
+The -S switch will attempt some exra rules for it.
+The -c switch attempts to return an empty answer for failed searches.
+The -C switch will attempt some exra rules for it.
+The -T switch takes a parameter that is used for the timeout for
+connection attempts.
+The -t switch enables caching.
+EOM
+       exit; 
+}
+
+
+$OMIT_MSG = $CHECK_FAIL = 0;
+
+$OMIT_MSG = 1 if $opt_s;
+$OMIT_MSG = 2 if $opt_S;
+$CHECK_FAIL = 1 if $opt_c;
+$CHECK_FAIL = 2 if $opt_C;
+$TIMEOUT = $opt_T;
+
+$CACHE_DIR = undef;
+if ($opt_t) {
+    if ($^O =~ /Win/) {
+        $CACHE_DIR = $ENV{'TEMP'} || "C:\\temp";
+    } else {
+        $CACHE_DIR = $ENV{'TEMP'} || "/tmp";
+        my @ent = getpwuid($>);
+        if (@ent) {
+            foreach ("/tmp/$ent[0]", "$ent[7]/.pwhois") {
+                mkdir $_, 0644;
+                if (open(O, ">$_/__$$-$$.tmp")) {
+                    close(O);
+                    unlink "$_/__$$-$$.tmp";
+                    $CACHE_DIR = $_;
+                    last;
+                 }
+            }
+        }
+    }
+}
+
+my $dom = $ARGV[0] || die "Usage: $0 domain";
+
+my $server = $ARGV[1];
+
+eval {
+       my $result = whois($dom, $server);
+       if ($result) {
+               print $result;
+       } 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;
+}      
+
+__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.
+The B<-s> switch attempts to strip the copyright message or disclaimer.
+The B<-c> switch attempts to return an empty answer for failed searches.
+The B<-T> switch takes a parameter that is used for the timeout for
+connection attempts.
+=head1 AUTHOR
+
+Ariel Brosh, B<schop@cpan.org>
+
+=head1 SEE ALSO
+
+L<Net::Whois::Raw>.
+
diff --git a/install/5.005/Net-Whois-Raw/t/01.t b/install/5.005/Net-Whois-Raw/t/01.t
new file mode 100644 (file)
index 0000000..dd7ffc4
--- /dev/null
@@ -0,0 +1,22 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+use strict;
+
+use Test::More tests => 5;
+BEGIN { use_ok('Net::Whois::Raw',qw( whois )) };
+
+my @domains = qw( 
+       yahoo.com
+       freshmeat.net
+       freebsd.org
+       ucsb.edu
+);
+
+print "The following tests requires internet connection...\n";
+
+foreach my $domain ( @domains ) {
+       my $txt = whois( $domain );
+       ok($txt =~ /$domain/i, "$domain resolved");
+}
+