summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile24
-rw-r--r--README4
-rw-r--r--TODO2
-rw-r--r--as_del_list15
-rw-r--r--config.h7
-rw-r--r--data.h50
-rw-r--r--debian/changelog29
-rw-r--r--ip_del_list57
-rwxr-xr-xmake_as_del.pl20
-rwxr-xr-xmake_tld_serv.pl2
-rw-r--r--po/it.po42
-rwxr-xr-xtest-whois.pl108
-rw-r--r--tld_serv_list73
-rw-r--r--whois.118
-rw-r--r--whois.c102
-rw-r--r--whois.h19
16 files changed, 446 insertions, 126 deletions
diff --git a/Makefile b/Makefile
index 35bccca..698ff10 100644
--- a/Makefile
+++ b/Makefile
@@ -1,24 +1,38 @@
+prefix=/usr/local
+
OPTS=-O2
+# Solaris
+#LDFLAGS=-lnsl -lsocket
+
all: whois #pos
-whois: whois.c whois.h config.h data.h ip_del.h tld_serv.h
- $(CC) $(OPTS) whois.c -o whois
+whois: whois.c whois.h config.h data.h as_del.h ip_del.h tld_serv.h
+ $(CC) $(OPTS) whois.c -o whois $(LDFLAGS)
mkpasswd:
$(CC) $(OPTS) mkpasswd.c -o mkpasswd -lcrypt
+as_del.h: as_del_list make_as_del.pl
+ perl make_as_del.pl < as_del_list > as_del.h
+
ip_del.h: ip_del_list make_ip_del.pl
- ./make_ip_del.pl < ip_del_list > ip_del.h
+ perl make_ip_del.pl < ip_del_list > ip_del.h
tld_serv.h: tld_serv_list make_tld_serv.pl
- ./make_tld_serv.pl < tld_serv_list > tld_serv.h
+ perl make_tld_serv.pl < tld_serv_list > tld_serv.h
+
+install: whois
+ install --strip -m 0755 whois $(BASEDIR)$(prefix)/bin/
+ install --strip -m 0644 whois.1 $(BASEDIR)$(prefix)/man/man1/
+ cd po && $(MAKE) $@
+
distclean: clean
rm -f po/whois.pot
clean:
- rm -f tld_serv.h ip_del.h whois mkpasswd
+ rm -f as_del.h ip_del.h tld_serv.h whois mkpasswd
rm -f po/*.mo
test:
diff --git a/README b/README
index 361e58f..61e7645 100644
--- a/README
+++ b/README
@@ -24,8 +24,10 @@ Other information sources:
- RIPE-187 and RIPE-189 (from ftp://ftp.ripe.net/ripe/docs/ or
http://www.ripe.net/docs/)
- Greg Woods' awhois script (from ftp.weird.com)
+- the www.geektools.org CGI proxy
- home of the 6bone client: http://www.ip.qwest.net/~david/software/
-
+- http://www.apnic.net/db/RIRs.html and
+ http://www.apnic.net/maps/tld-list.html
Marco d'Itri
<md@linux.it>
diff --git a/TODO b/TODO
index 9790dbd..a32fba4 100644
--- a/TODO
+++ b/TODO
@@ -3,3 +3,5 @@ Still to sort:
Is MNT-* a standard of some registry?
+What about rwhois?
+
diff --git a/as_del_list b/as_del_list
new file mode 100644
index 0000000..c7d865a
--- /dev/null
+++ b/as_del_list
@@ -0,0 +1,15 @@
+1877 1901 ripe
+2043 2043 ripe
+2047 2047 ripe
+2107 2136 ripe
+2585 2614 ripe
+2773 2822 ripe
+2830 2879 ripe
+3154 3353 ripe
+4608 4863 apnic
+5377 5631 ripe
+6656 6911 ripe
+7467 7722 apnic
+8192 9215 ripe
+9261 10239 apnic
+12288 13311 ripe
diff --git a/config.h b/config.h
index 1addf97..7f45145 100644
--- a/config.h
+++ b/config.h
@@ -6,6 +6,9 @@
/* Suppress lame Internic disclaimer */
#define HIDE_DISCL
-/* program version */
-#define VERSION "4.3"
+/* Program version */
+#define VERSION "4.4.1"
+
+/* String sent to RIPE servers - ONLY FIVE CHARACTERS! */
+#define IDSTRING "Md4.4"
diff --git a/data.h b/data.h
index 8ff202e..58ed638 100644
--- a/data.h
+++ b/data.h
@@ -1,17 +1,36 @@
-const char *ripeflags="acFLmMrRS";
-const char *ripeflagsp="gisTtv";
-
+/*
+ * RIPE-like servers.
+ * All of them do not understand -V2.0Md with the exception of RA and RIPN.
+ * 6bone-like servers will accept the flag with a warning (the flag must
+ * match /^V [a-zA-Z]{1,4}\d+[\d\.]{0,5}$/).
+ */
const char *ripe_servers[] = {
+ /* will accept the new syntax (-V wp3.0) */
"whois.ripe.net",
- "whois.ra.net",
"whois.apnic.net",
- "whois.mci.net",
- "whois.isi.edu",
+ "whois.6bone.net", /* 3.0.0b1 */
+ "whois.aunic.net",
+ "whois.connect.com.au", /* 3.0.0b1 */
+ "whois.nic.fr",
+ "whois.nic.net.sg",
+ "whois.metu.edu.tr",
+ /* end of servers accepting new syntax */
"whois.nic.it",
- "whois.6bone.net",
"whois.ans.net",
+ "whois.ra.net",
+ "whois.ripn.net",
+ NULL
+};
+
+#if 0
+const char *rwhois_servers[] = {
+ "whois.isi.edu", /* V-1.0B9.2 */
+ "rwhois.rcp.net.pe", /* V-1.5.3 */
+ "ns.twnic.net", /* V-1.0B9 */
+ "dragon.seed.net.tw", /* V-1.0B9.2 */
NULL
};
+#endif
const char *gtlds[] = {
".com",
@@ -29,9 +48,9 @@ const char *arin_nets[] = {
};
struct ip_del {
- unsigned long int net;
- unsigned long int mask;
- const char *serv;
+ unsigned long net;
+ unsigned long mask;
+ const char *serv;
};
struct ip_del ip_assign[] = {
@@ -39,6 +58,17 @@ struct ip_del ip_assign[] = {
{ 0, 0, NULL }
};
+struct as_del {
+ unsigned short first;
+ unsigned short last;
+ const char *serv;
+};
+
+struct as_del as_assign[] = {
+#include "as_del.h"
+ { 0, 0, NULL }
+};
+
const char *tld_serv[] = {
#include "tld_serv.h"
NULL, NULL
diff --git a/debian/changelog b/debian/changelog
index c6dc8cd..d7d1f6c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,32 @@
+whois (4.4.1) unstable; urgency=low
+
+ * A space is added after "AS" when querying ARIN.
+ * Converted some strcmp to strcasecmp.
+
+ -- Marco d'Itri <md@linux.it> Mon, 15 Nov 1999 00:59:07 +0100
+
+whois (4.4.0) unstable; urgency=low
+
+ * Now the program automatically select the right server for AS queries.
+ * Added RIPE delegations of netblocks in the B class space.
+ * Extensive survey of all known whois servers and update of tld_serv_list.
+ * Now the flag -VMd4.4 is sent to RIPE-like servers.
+ * Written a test program for checking if all servers work.
+
+ -- Marco d'Itri <md@linux.it> Tue, 9 Nov 1999 22:53:35 +0100
+
+whois (4.3.3) unstable; urgency=low
+
+ * Fixed man page (closes: #49195).
+
+ -- Marco d'Itri <md@linux.it> Sun, 7 Nov 1999 14:07:59 +0100
+
+whois (4.3.2) unstable; urgency=low
+
+ * Fixed version reporting code. Now the string is "-VMd2.0".
+
+ -- Marco d'Itri <md@linux.it> Tue, 2 Nov 1999 19:50:33 +0100
+
whois (4.3.1) unstable; urgency=low
* CRSNIC code parsed the wrong field (closes: #48590).
diff --git a/ip_del_list b/ip_del_list
index 2246596..8b87882 100644
--- a/ip_del_list
+++ b/ip_del_list
@@ -3,38 +3,65 @@
61.0.0.0/8 apnic
62.0.0.0/8 ripe
0.0.0.0/2 arin # all other A classes are managed by ARIN
-## The B class space is a mess :-(
-#? 139. 20-29
-145.224.0.0/12 ripe
+## The B class space is a mess :-( - something could be still missing
+139.20.0.0/14 ripe
+139.24.0.0/14 ripe
+139.28.0.0/15 ripe
141.0.0.0/10 ripe
-141.64.0.0/11 ripe # unsure
-149.192.0.0/10 ripe # unsure
-#? 149. 202-251
+141.64.0.0/12 ripe
+141.80.0.0/14 ripe
+141.84.0.0/15 ripe
+145.224.0.0/12 ripe
+145.240.0.0/13 ripe
+145.248.0.0/14 ripe
+145.252.0.0/15 ripe
+145.254.0.0/16 ripe
+149.202.0.0/15 ripe
+149.204.0.0/16 ripe
+149.206.0.0/15 ripe
+149.208.0.0/12 ripe
+149.224.0.0/12 ripe
+149.240.0.0/13 ripe
+149.248.0.0/14 ripe
150.254.0.0/16 ripe
-151.0.0.0/8 ripe
+151.13.0.0/16 ripe
+151.14.0.0/15 ripe
+151.16.0.0/12 ripe
+151.32.0.0/11 ripe
+151.64.0.0/12 ripe
+151.80.0.0/15 ripe
+151.3.0.0/16 ripe
+151.4.0.0/15 ripe
+151.82.0.0/16 ripe
+151.91.0.0/16 ripe
+151.92.0.0/15 ripe
+151.95.0.0/16 ripe
160.216.0.0/14 ripe
-160.220.0.0/8 ripe
-163.128.0.0/12 ripe
+160.220.0.0/16 ripe
+160.44.0.0/14 ripe
+160.48.0.0/12 ripe
+163.156.0.0/14 ripe
+163.160.0.0/12 ripe
+164.0.0.0/11 ripe
+164.32.0.0/13 ripe
164.40.0.0/16 ripe
-164.0.0.0/6 ripe
+164.128.0.0/12 ripe
169.208.0.0/12 apnic
171.16.0.0/12 ripe
+171.32.0.0/15 ripe
## The C class space is cleanly delegated and the data here should be complete
192.71.0.0/16 ripe
-192.72.1.1/24 arin
-192.72.1.2/24 arin
-192.72.1.253/24 arin
-192.72.1.254/24 arin
192.72.0.0/16 whois.seed.net.tw # NETBLK-SEED-NETS
192.106.144.0/20 ripe
+192.106.196.0/23 ripe
192.162.0.0/16 ripe
192.164.0.0/14 ripe
192.0.0.0/8 arin # the swamp
193.0.0.0/8 ripe
194.0.0.0/7 ripe
+198.17.117.0/24 ripe
196.0.0.0/6 arin
200.0.0.0/7 arin
-203.0.0.0/10 aunic
202.0.0.0/7 apnic
204.0.0.0/6 arin
208.0.0.0/7 arin
diff --git a/make_as_del.pl b/make_as_del.pl
new file mode 100755
index 0000000..324d3d2
--- /dev/null
+++ b/make_as_del.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+while (<>) {
+ chomp;
+ s/^\s*(.*)\s*$/$1/;
+ s/\s*#.*$//;
+ next if /^$/;
+ die "format error: $_" unless (/^([\d\.]+)\s+([\d\.]+)\s+([\w\.]+)$/);
+ my $f=$1; my $l=$2; my $s=$3;
+ print "{ ${f}, ${l}, \"";
+ if ($s =~ /\./) {
+ print "$s";
+ } else {
+ print "whois.$s.net";
+ }
+ print "\" },\n";
+}
+
diff --git a/make_tld_serv.pl b/make_tld_serv.pl
index 8e76ce3..8c37060 100755
--- a/make_tld_serv.pl
+++ b/make_tld_serv.pl
@@ -7,7 +7,7 @@ while (<>) {
s/^\s*(.*)\s*$/$1/;
s/\s*#.*$//;
next if /^$/;
- die "format error: $_" unless (/^([\w\d\.-]+)\s+([\w\d\.-]+)$/);
+ die "format error: $_" unless (/^([\w\d\.-]+)\s+([\w\d\.:-]+)$/);
print " \"$1\",\t\"$2\",\n";
}
diff --git a/po/it.po b/po/it.po
index 560eeb1..b192976 100644
--- a/po/it.po
+++ b/po/it.po
@@ -4,8 +4,8 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: whois 3.0\n"
-"POT-Creation-Date: 1999-10-26 12:19+0200\n"
+"Project-Id-Version: whois 4.4.0\n"
+"POT-Creation-Date: 1999-11-09 22:15+0100\n"
"PO-Revision-Date: 1999-10-26 12:19+02:00\n"
"Last-Translator: Marco d'Itri <md@linux.it>\n"
"Language-Team: Italian <it@li.org>\n"
@@ -13,11 +13,11 @@ msgstr ""
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ../whois.c:95
+#: ../whois.c:93
msgid "Connecting to whois.crsnic.net.\n"
msgstr "Mi sto connettendo a whois.crsnic.net.\n"
-#: ../whois.c:103
+#: ../whois.c:97
#, c-format
msgid ""
"\n"
@@ -25,20 +25,20 @@ msgid ""
"\n"
msgstr ""
"\n"
-"Trovato un riferimento CRSNIC a %s.\n"
+"Trovato un riferimento di CRSNIC a %s.\n"
"\n"
-#: ../whois.c:113
+#: ../whois.c:105
#, c-format
msgid "Using default server %s.\n"
msgstr "Uso il server predefinito %s.\n"
-#: ../whois.c:115
+#: ../whois.c:107
#, c-format
msgid "Using server %s.\n"
msgstr "Uso il server %s.\n"
-#: ../whois.c:120
+#: ../whois.c:112
#, c-format
msgid ""
"Query string: \"%s\"\n"
@@ -47,7 +47,7 @@ msgstr ""
"Richiesta: \"%s\"\n"
"\n"
-#: ../whois.c:156
+#: ../whois.c:153
msgid ""
"I don't know where this IP has been delegated.\n"
"I'll try ARIN and hope for the best...\n"
@@ -55,20 +55,28 @@ msgstr ""
"Non so a chi č stato delegato questo IP.\n"
"Proverņ con ARIN sperando per il meglio...\n"
-#: ../whois.c:173
+#: ../whois.c:170
msgid "I guess it's a netblock name but I don't know where to look it up.\n"
msgstr "Credo che sia il nome di un netblock ma non so dove cercarlo.\n"
-#: ../whois.c:180
+#: ../whois.c:177
msgid "I guess it's a domain but I don't know where to look it up.\n"
msgstr "Credo che sia un dominio ma non so dove cercarlo.\n"
-#: ../whois.c:239
+#: ../whois.c:188
+msgid "Unknown AS number. Please upgrade this program."
+msgstr ""
+
+#: ../whois.c:211
+msgid "Warning: RIPE flags ignored for a traditional server."
+msgstr ""
+
+#: ../whois.c:254
#, c-format
msgid "Detected referral to %s on %s.\n"
msgstr "Trovato un riferimento a %s su %s.\n"
-#: ../whois.c:252
+#: ../whois.c:267
msgid ""
"Catastrophic error: INTERNIC changed the disclaimer text.\n"
"Please upgrade this program.\n"
@@ -76,22 +84,22 @@ msgstr ""
"Errore catastrofico: INTERNIC ha cambiato il testo di avvertenze.\n"
"Aggiorna questo programma.\n"
-#: ../whois.c:313
+#: ../whois.c:335
#, c-format
msgid "Host %s not found."
msgstr "Host %s non trovato."
-#: ../whois.c:322
+#: ../whois.c:344
#, c-format
msgid "%s/tcp: unknown service"
msgstr "%s/tcp: servizio sconosciuto"
-#: ../whois.c:339
+#: ../whois.c:361
#, c-format
msgid "Interrupted by signal %d..."
msgstr "Interrotto dal segnale %d..."
-#: ../whois.c:379
+#: ../whois.c:403
msgid ""
"Usage: whois [OPTION]... OBJECT...\n"
"\n"
diff --git a/test-whois.pl b/test-whois.pl
new file mode 100755
index 0000000..a68475a
--- /dev/null
+++ b/test-whois.pl
@@ -0,0 +1,108 @@
+#!/usr/bin/perl -w
+
+use IO::Socket;
+use strict;
+
+my %check=(
+ 'whois.io' => 'whois.io',
+ 'whois.nic.cx' => 'nic.cx',
+ 'whois.nic.gi' => 'nic.gi',
+ 'whois.nic.ly' => 'nic.ly',
+ 'whois.nic.pw' => 'nic.pw',
+ 'whois.nic.so' => 'nic.so',
+ 'whois.nic.st' => 'nic.st',
+ 'whois.uprr.pr' => 'uprr.pr',
+ 'whois.nplus.gf' => 'nplus.gf',
+ 'rwhois.reacciun.ve' => 'reacciun.ve',
+ 'whois.adamsnames.tc' => 'adamsnames.vg',
+ 'whois.idnic.net.id' => 'idnic.net.id',
+ 'whois.ncst.ernet.in' => 'ncst.ernet.in',
+);
+
+my @ripetest=('-V wC2.0', '-V2.0Md', '-VMd4.4');
+my %ripeserv=qw(
+ whois.ripe.net dfn.de
+ whois.aunic.net connect.com.au
+ whois.connect.com.au connect.com.au
+ whois.ra.net AS1
+ whois.apnic.net 24.192.0.0
+ whois.nic.it nic.it
+ whois.ans.net AS1
+ whois.ripn.net demos.su
+ whois.nic.fr nic.fr
+ whois.nic.net.sg nic.net.sg
+ whois.metu.edu.tr metu.edu.tr
+);
+
+open(LIST, 'tld_serv_list');
+while (<LIST>) {
+ chomp;
+ next if /^#/;
+ my ($tld, $serv, $junk)=split;
+ next unless ($tld =~/\.[a-z]{2}$/); # skip non-cctld
+ # I'm sure these won't move without notifying...
+ next if ($serv =~ /(?:isi\.edu|internic.net)/);
+
+ if ($serv eq 'whois.ripe.net') {
+ $tld =~ s/^\.//;
+ print ">>>>>>>>>Querying $serv ($tld) for $tld<<<<<<<<<<\n";
+ print whois("-i domain $tld", $serv); # untested
+ print "\n";
+ next;
+ }
+ my $q;
+ if ($serv =~ /$tld$/) {
+ $q = $serv; $q =~ s/.*\.([-a-z0-9]+?\...)$/$1/; # we know a real domain
+ } else {
+ $q = "nic$tld"; # make a random domain and try anyway
+ }
+ $tld =~ s/^\.//;
+ print ">>>>>>>>>Querying $serv ($tld) for $q<<<<<<<<<<\n";
+ print whois($q, $serv);
+ print "\n";
+}
+close LIST;
+
+print "#" x 78 . "\n";
+foreach (keys %check) {
+ print ">>>>>>>>>Querying $_ for $check{$_}<<<<<<<<<<\n";
+ print whois($check{$_}, $_);
+ print "\n";
+}
+exit 0;
+
+print "#" x 78 . "\n";
+foreach my $s (keys %ripeserv) {
+ foreach (@ripetest) {
+ my $q = "$_ $ripeserv{$s}";
+ print ">>>>>>>>>Querying $s for $q<<<<<<<<<<\n";
+ print whois($q, $s);
+ print "\n";
+ }
+}
+exit 0;
+
+sub whois {
+ my ($query, $serv, $port) = @_;
+ my (@result, $remote);
+
+ eval {
+ local $^W=0;
+ $remote = IO::Socket::INET->new(
+ Timeout => 15, PeerAddr => $serv, PeerPort => $port || 43
+ );
+ };
+ if (defined $remote and ($@ eq '')) {
+ print $remote "$query\r\n";
+ @result = <$remote>;
+ close $remote;
+ } elsif ($@ ne '') {
+ @result = ("FATAL: $@");
+ } else {
+# FIXME should disconnect from rwhois servers or the connection will hang
+# until the timeout of the server
+ @result = ("$!\n");
+ }
+ return @result;
+}
+
diff --git a/tld_serv_list b/tld_serv_list
index 04ef828..a83a91e 100644
--- a/tld_serv_list
+++ b/tld_serv_list
@@ -1,3 +1,6 @@
+# Servers in lines with a trailing hash mark have been tested and found
+# not working at the time of my survey (19991109).
+# Servers with the comment "wrong" have been tested as well but are wrong.
.gb.com whois.nomination.net
.gb.net whois.nomination.net
.uk.net whois.nomination.net
@@ -11,18 +14,21 @@
.mil whois.nic.mil
.ac whois.nic.ac
.ad whois.ripe.net
-.al whois.ripe.net
+.af whois.nic.tm
+#.al whois.ripe.net #wrong
.am whois.amnic.net
.as whois.nic.as
.at whois.univie.ac.at # CNAME whois.ripe.net
-.net.au whois.connect.com.au
+#.net.au whois.connect.com.au # obsolete?
.au whois.aunic.net
-.az whois.ripe.net
+#.az whois.ripe.net #wrong
.ba whois.ripe.net
.be whois.ripe.net
.bg whois.ripe.net
+#.bm rwhois.ibl.bm:4321
.br whois.nic.br
-.by whois.ripe.net
+.bt whois.nic.tm
+#.by whois.ripe.net #wrong
.ca whois.cdnnet.ca
.cc whois.nic.cc
.ch whois.nic.ch
@@ -30,33 +36,37 @@
.ac.cn whois.cnc.ac.cn
.cn whois.cnnic.net.cn
.uk.co whois.uk.co
-.co whois.ripe.net
+#.co whois.ripe.net #wrong
+#.cx whois.nic.cx #
.cy whois.ripe.net
.cz whois.ripe.net
.de whois.ripe.net
.dk whois.ripe.net
-.dz whois.ripe.net
-.ee whois.ripe.net
-.eg whois.ripe.net
+#.dz whois.ripe.net #wrong
+#.ee whois.ripe.net #wrong
+#.eg whois.ripe.net #wrong
.es whois.ripe.net
-.fi whois.ripe.net
+#.fi whois.ripe.net #wrong
.fo whois.ripe.net
.fr whois.nic.fr
-.ga whois.ripe.net
-.gb whois.ripe.net
-.ge whois.ripe.net
+#.ga whois.ripe.net #wrong
+#.gb whois.ripe.net #wrong
+#.ge whois.ripe.net #wrong
+#.gf whois.nplus.gf #
+#.gi whois.nic.gi #
.gl whois.ripe.net
.gm whois.ripe.net
.gr whois.ripe.net
.gs whois.adamsnames.tc
-.hk whois.apnic.net
+.hk whois.hknic.net.hk
.hm whois.nic.hm
.hr whois.ripe.net
.hu whois.ripe.net
-.id whois.idnic.net.id
+.id whois.idnic.net.id # broken
.ie whois.ripe.net
.il whois.ripe.net
-.in whois.ncst.ernet.in
+.in whois.ncst.ernet.in # empty?
+#.io whois.io #
.is whois.ripe.net
.it whois.nic.it
.jo whois.ripe.net
@@ -68,13 +78,14 @@
.lt whois.ripe.net
.lu whois.ripe.net
.lv whois.ripe.net
-.ma whois.ripe.net
+#.ly whois.nic.ly #
+#.ma whois.ripe.net #wrong
.mc whois.ripe.net
.md whois.ripe.net
-.mk whois.ripe.net
-.mm whois.nic.mm
+#.mk whois.ripe.net #wrong
+#.mm whois.nic.mm #
.ms whois.adamsnames.tc
-.mt whois.ripe.net
+#.mt whois.ripe.net #wrong
.mx whois.nic.mx
.ng pgebrehiwot.iat.cnr.it
.nl www.domain-registry.nl
@@ -83,17 +94,21 @@
.nz tardis.patho.gen.nz
.pe whois.rcp.net.pe
.pl whois.ripe.net
+#.pr whois.uprr.pr #
.pk whois.pknic.net.pk
-.pt whois.dns.pt
-.ro whois.nic.ro
+#.pt whois.dns.pt # disabled - use http://www.dns.pt/info/
+.pw whois.nic.pw
+.ro whois.ripe.net
.ru whois.ripn.net
.se whois.nic-se.se
.sg whois.nic.net.sg
.sh whois.nic.sh
-.si whois.ripe.net
+#.si whois.ripe.net #wrong
.sk whois.ripe.net
.sm whois.ripe.net
-.su whois.ripe.net
+#.so whois.nic.so #
+.st whois.nic.st
+.su whois.ripn.net
.tc whois.adamsnames.tc
.tf whois.adamsnames.tc
.th whois.thnic.net
@@ -108,12 +123,18 @@
.uk whois.nic.uk
.us whois.isi.edu
.va whois.ripe.net
+#.ve rwhois.reacciun.ve:4321
+.vg whois.adamsnames.tc
.yu whois.ripe.net
.za whois.frd.ac.za
--arin whois.arin.net
--ripe whois.ripe.net
--ap whois.apnic.net
-dom whois.internic.net
-org whois.internic.net
-hst whois.internic.net
+-arin whois.arin.net
+-ripe whois.ripe.net
+-ap whois.apnic.net
+-au whois.aunic.net
-6bone whois.6bone.net
+-ripn whois.ripn.net
+-sgnic whois.nic.net.sg
+-metu whois.metu.edu.tr
diff --git a/whois.1 b/whois.1
index 6d4a6e0..7a6c572 100644
--- a/whois.1
+++ b/whois.1
@@ -1,4 +1,4 @@
-.TH WHOIS 1 "8 October 1999" "Marco d'Itri" "Debian GNU/Linux"
+.TH WHOIS 1 "15 November 1999" "Marco d'Itri" "Debian GNU/Linux"
.SH NAME
whois \- client for the whois directory service
.SH SYNOPSIS
@@ -65,6 +65,19 @@ to find the registrar for a GTLD subdomain. This option overrides
Be verbose.
.TP 8
Other options are flags understood by RIPE-like servers.
+.SH FEATURES
+When querying
+.I whois.arin.net
+for AS numbers, the program will automatically convert the request in
+the appropriate format, inserting a space after the string "AS".
+.P
+When querying
+.I whois.nic.ad.jp
+english text is requested unless the
+.I LANG
+environment variable specifies a Japanese locale.
+.P
+RIPE-specific options are ignored when querying non-RIPE servers.
.SH "SEE ALSO"
.I RFC 812:
NICNAME/WHOIS
@@ -74,7 +87,7 @@ RIPE NCC Database Documentation
.PP
Detailed help on available flags can be found in
.I RIPE-157
-or in the help file, which can be downloaded with the command:
+or in the help file, which can be obtained with the command:
.IP
.B whois -h whois.ripe.net HELP
.SH HISTORY
@@ -87,4 +100,3 @@ Kessens of QWest for the 6bone server.
.B Whois
and this man page were written by Marco d'Itri <md@linux.it>
and are licensed under the GPL.
-
diff --git a/whois.c b/whois.c
index f4f63ef..e817a03 100644
--- a/whois.c
+++ b/whois.c
@@ -19,18 +19,19 @@
#include <errno.h>
#include <signal.h>
+/* Application-specific */
#include "config.h"
-#include "whois.h"
#include "data.h"
+#include "whois.h"
+/* Global variables */
int sockfd, verb = 0;
-
int main(int argc, char *argv[])
{
int ch, nopar = 0, optC = 0;
const char *server = NULL;
- char *p, qstring[256] = "\0", fstring[64] = "\0", *port = NULL,
+ char *p, *q, qstring[256] = "\0", fstring[64] = "\0", *port = NULL,
defaultserv[] = "whois.internic.net";
#ifdef ENABLE_NLS
@@ -39,7 +40,7 @@ int main(int argc, char *argv[])
textdomain(NLS_CAT_NAME);
#endif
- while ((ch = GETOPT(argc, argv, "acCFg:h:i:LmMp:rRs:St:T:v:V")) > 0) {
+ while ((ch = getopt(argc, argv, "acCFg:h:i:LmMp:rRs:St:T:v:V")) > 0) {
/* RIPE flags */
if (strchr(ripeflags, ch)) {
for (p = fstring; *p != '\0'; p++);
@@ -56,7 +57,8 @@ int main(int argc, char *argv[])
/* program flags */
switch (ch) {
case 'h':
- server = optarg;
+ server = q = malloc(strlen(optarg) + 1);
+ for (p = optarg; *p != '\0'; *q++ = tolower(*p++));
break;
case 'p':
port = optarg;
@@ -89,7 +91,7 @@ int main(int argc, char *argv[])
if (optC && domfind(qstring, gtlds)) {
if (verb)
- printf(_("Connecting to whois.crsnic.net.\n"));
+ fputs(_("Connecting to whois.crsnic.net.\n"), stdout);
sockfd = openconn("whois.crsnic.net", "43");
server = query_crsnic(sockfd, qstring);
if (verb && server)
@@ -107,8 +109,9 @@ int main(int argc, char *argv[])
}
p = queryformat(server, fstring, qstring);
- if (verb)
+ if (verb) {
printf(_("Query string: \"%s\"\n\n"), p);
+ }
strcat(p, "\r\n");
signal(SIGTERM, sighandler);
@@ -130,22 +133,26 @@ const char *whichwhois(const char *s)
if (*s == '\0')
return "whois.ripe.net";
+ /* no dot and no hyphen means it's a internic NIC handle or an AS (?) */
+ if (!strpbrk(s, ".-")) {
+ if (strncasecmp(s, "AS", 2) == 0) { /* it's an AS */
+ return whereas(atoi(s + 2), as_assign);
+ } else /* it's an internic NIC handle (?) */
+ return "whois.internic.net";
+ }
+
/* IPv6 address */
if (strchr(s, ':'))
return "whois.6bone.net";
- /* no dot and no hyphen means it's a internic NIC handle or an AS (?) */
- if (!strpbrk(s, ".-"))
- return "whois.internic.net";
-
/* smells like an IP? */
if ((ip = myinet_aton(s))) {
for (i = 0; ip_assign[i].serv; i++)
if ((ip & ip_assign[i].mask) == ip_assign[i].net)
return ip_assign[i].serv;
if (verb)
- printf(_("I don't know where this IP has been delegated.\n"
- "I'll try ARIN and hope for the best...\n"));
+ fputs(_("I don't know where this IP has been delegated.\n"
+ "I'll try ARIN and hope for the best...\n"), stdout);
return "whois.arin.net";
}
@@ -157,35 +164,62 @@ const char *whichwhois(const char *s)
/* no dot but hyphen, check for ARIN netblock names */
if (!strchr(s, '.')) {
for (i = 0; arin_nets[i]; i++)
- if (!strncmp(s, arin_nets[i], strlen(arin_nets[i])))
+ if (!strncasecmp(s, arin_nets[i], strlen(arin_nets[i])))
return "whois.arin.net";
/* could be one of *NETBLK-RIPE* *NET-RIPE* *APNIC* *AUNIC-AU* */
if (verb)
- printf(_("I guess it's a netblock name but I don't know where to"
- " look it up.\n"));
+ fputs(_("I guess it's a netblock name but I don't know where to"
+ " look it up.\n"), stdout);
return "whois.arin.net";
}
/* has dot and hypen and it's not in tld_serv[], WTF is it? */
if (verb)
- printf(_("I guess it's a domain but I don't know where to look it"
- " up.\n"));
+ fputs(_("I guess it's a domain but I don't know where to look it"
+ " up.\n"), stdout);
return NULL;
}
+const char *whereas(unsigned short asn, struct as_del aslist[])
+{
+ int i;
+
+ if (asn > 14335)
+ puts(_("Unknown AS number. Please upgrade this program."));
+ for (i = 0; aslist[i].serv; i++)
+ if (asn >= aslist[i].first && asn <= aslist[i].last)
+ return aslist[i].serv;
+ return "whois.arin.net";
+}
+
char *queryformat(const char *server, const char *flags, const char *query)
{
char *buf;
- int i;
+ int i, isripe = 0;
- buf = malloc(QUERYBUFSIZE);
- strcpy(buf, flags);
+ buf = malloc(QUERYBUFSIZE + 1); /* +1 is for ARIN AS queries */
+ //*buf = '\0';
for (i = 0; ripe_servers[i]; i++)
- if (strcmp(server, ripe_servers[i]) == 0)
- strcat(buf, VERSION " ");
- strcat(buf, query);
- if (strcmp(server, "whois.nic.ad.jp") == 0) {
+ if (strcmp(server, ripe_servers[i]) == 0) {
+ strcat(buf, "-V" IDSTRING " ");
+ isripe = 1;
+ break;
+ }
+ if (*flags != '\0') {
+ if (isripe && *flags != '\0')
+ puts(_("Warning: RIPE flags ignored for a traditional server."));
+ else
+ strcat(buf, flags);
+ }
+ if (!isripe && strcmp(server, "whois.arin.net") == 0 &&
+ strncasecmp(query, "AS", 2) == 0 &&
+ query[2] >= '0' && query[2] <= '9') {
+ sprintf(buf, "AS ");
+ strcat(buf, query + 2);
+ } else
+ strcat(buf, query);
+ if (!isripe && strcmp(server, "whois.nic.ad.jp") == 0) {
char *lang = getenv("LANG"); /* not a perfect check, but... */
if (lang && (strncmp(getenv("LANG"), "ja", 2) != 0))
strcat(buf, "/e"); /* ask for english text */
@@ -206,9 +240,9 @@ void do_query(const int sock, const char *query)
err_sys("write");
while (fgets(buf, 100, fi)) { /* XXX errors? */
#ifdef HIDE_DISCL
- if (hide == 1 &&
- strncmp(buf, DISCL_END, sizeof(DISCL_END) - 1) == 0) {
- hide = 2; /* stop hiding */
+ if (hide == 1) {
+ if (strncmp(buf, DISCL_END, sizeof(DISCL_END) - 1) == 0)
+ hide = 2; /* stop hiding */
continue;
}
if (hide == 0 &&
@@ -235,7 +269,7 @@ void do_query(const int sock, const char *query)
}
}
#endif
- printf("%s", buf);
+ fputs(buf, stdout);
}
#ifdef HIDE_DISCL
if (hide == 1)
@@ -267,7 +301,7 @@ const char *query_crsnic(const int sock, const char *query)
for (; *p != '\n' && *p != '\r'; *q++ = *p++); /* copy data */
*q = '\0';
}
- printf("%s", buf);
+ fputs(buf, stdout);
}
free(temp);
@@ -336,11 +370,12 @@ void sighandler(int signum)
err_quit(_("Interrupted by signal %d..."), signum);
}
+/* check if dom ends with tld */
int domcmp(const char *dom, const char *tld)
{
const char *p, *q;
- if (!(p = rindex(dom, *tld)))
+ if (!(p = strrchr(dom, *tld)))
return 0;
q = tld;
while (tolower(*p) == *q)
@@ -349,6 +384,7 @@ int domcmp(const char *dom, const char *tld)
return 0;
}
+/* check if dom ends with an element of tldlist[] */
int domfind(const char *dom, const char *tldlist[])
{
int i;
@@ -372,7 +408,7 @@ unsigned long myinet_aton(const char *s)
void usage(void)
{
- fprintf(stderr, _(
+ fputs(_(
"Usage: whois [OPTION]... OBJECT...\n\n"
"-a search all databases\n"
"-C first query CRSNIC to find GTLD registrar\n"
@@ -394,7 +430,7 @@ void usage(void)
"-v TYPE requests verbose template for object of TYPE\n"
"-V explain what is being done\n\n"
"Version " VERSION ". Please report bugs to <md@linux.it>.\n"
- ));
+ ), stderr);
exit(1);
}
diff --git a/whois.h b/whois.h
index 86e3556..0da289f 100644
--- a/whois.h
+++ b/whois.h
@@ -1,7 +1,3 @@
-/* Identification string */
-/* #define IDSTRING "-VMd" VERSION */
-#define IDSTRING "-VwC2.0"
-
/* Size of the buffer where the query is built */
#define QUERYBUFSIZE 1024
@@ -16,7 +12,6 @@
/* system features */
#ifdef linux
-# define HAVE_GNU_GETOPT
# define ENABLE_NLS
# if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
# define HAVE_GETADDRINFO
@@ -47,16 +42,9 @@
#endif
-/* If needed, disable GNU getopt "features" */
-#ifdef HAVE_GNU_GETOPT
-# define GETOPT(argc, argv, str) getopt((argc), (argv), "+" str)
-#else
-# define GETOPT(argc, argv, str) getopt((argc), (argv), (str))
-#endif
-
-
/* prototypes */
const char *whichwhois(const char *);
+const char *whereas(unsigned short, struct as_del []);
char *queryformat(const char *, const char *, const char *);
void do_query(const int, const char *);
const char *query_crsnic(const int, const char *);
@@ -71,3 +59,8 @@ int domfind(const char *, const char *[]);
void err_quit(const char *,...);
void err_sys(const char *,...);
+
+/* flags for RIPE-like servers */
+const char *ripeflags="acFLmMrRS";
+const char *ripeflagsp="gisTtv";
+