summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-10-03 00:42:35 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-10-03 00:42:35 +0000
commite98547b835d0f797b54762e376ec2d8120b968bc (patch)
tree7a4f60471c124858e8fb1cd5b99c2d1c9d62e853
parent725009e352f4cf0c5730141a5674a8ba93919698 (diff)
whois-servers.net and whois.ra.net support; jabley@patho.gen.nz
-rw-r--r--usr.bin/whois/whois.113
-rw-r--r--usr.bin/whois/whois.c36
2 files changed, 44 insertions, 5 deletions
diff --git a/usr.bin/whois/whois.1 b/usr.bin/whois/whois.1
index b6926b30ea8..9b3ef1036d2 100644
--- a/usr.bin/whois/whois.1
+++ b/usr.bin/whois/whois.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: whois.1,v 1.5 1999/06/05 01:21:51 aaron Exp $
+.\" $OpenBSD: whois.1,v 1.6 1999/10/03 00:42:34 deraadt Exp $
.\" $NetBSD: whois.1,v 1.5 1995/08/31 21:51:32 jtc Exp $
.\"
.\" Copyright (c) 1985, 1990, 1993
@@ -69,11 +69,22 @@ database. It contains points of contact for subdomains of
Use the specified host instead of the default NIC
(whois.internic.net).
Either a host name or an IP address may be specified.
+.It Fl m
+Use the Route Arbiter Database
+.Pq Tn RADB
+database. It contains route policy specifications for a large
+number of operators' networks.
.It Fl p
Use the Asia/Pacific Network Information Center
.Pq Tn APNIC
database. It contains network numbers used in East Asia, Australia,
New Zealand, and the Pacific islands.
+.It Fl q
+Construct the name of a whois server to use from the top-level domain
+.Pq Tn TLD
+of the supplied (single) argument, and appending ".whois-servers.net".
+This effectively allows a suitable whois server to be selected
+automatically for a large number of TLDs.
.It Fl r
Use the R\(aaeseaux IP Europ\(aaeens
.Pq Tn RIPE
diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c
index e59c1f88a36..fad5f9e58ca 100644
--- a/usr.bin/whois/whois.c
+++ b/usr.bin/whois/whois.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: whois.c,v 1.5 1999/08/16 20:24:36 art Exp $ */
+/* $OpenBSD: whois.c,v 1.6 1999/10/03 00:42:34 deraadt Exp $ */
/* $NetBSD: whois.c,v 1.5 1994/11/14 05:13:25 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)whois.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: whois.c,v 1.5 1999/08/16 20:24:36 art Exp $";
+static char rcsid[] = "$OpenBSD: whois.c,v 1.6 1999/10/03 00:42:34 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -64,6 +64,8 @@ static char rcsid[] = "$OpenBSD: whois.c,v 1.5 1999/08/16 20:24:36 art Exp $";
#define ANICHOST "whois.arin.net"
#define RNICHOST "whois.ripe.net"
#define PNICHOST "whois.apnic.net"
+#define MNICHOST "whois.ra.net"
+#define QNICHOST_TAIL ".whois-servers.net"
#define WHOIS_PORT 43
static void usage();
@@ -82,9 +84,13 @@ main(argc, argv)
struct servent *sp;
int s;
char *host;
+ char *qnichost;
+ int use_qnichost;
+ int i, j;
host = NICHOST;
- while ((ch = getopt(argc, argv, "adh:pr")) != -1)
+ use_qnichost = 0;
+ while ((ch = getopt(argc, argv, "adh:pmqr")) != -1)
switch((char)ch) {
case 'a':
host = ANICHOST;
@@ -95,9 +101,15 @@ main(argc, argv)
case 'h':
host = optarg;
break;
+ case 'm':
+ host = MNICHOST;
+ break;
case 'p':
host = PNICHOST;
break;
+ case 'q':
+ use_qnichost = 1;
+ break;
case 'r':
host = RNICHOST;
break;
@@ -111,6 +123,22 @@ main(argc, argv)
if (!argc)
usage();
+ if (use_qnichost != 0) {
+ if (argc == 1) {
+ for (i = j = 0; (*argv)[i]; i++)
+ if ((*argv)[i] == '.') j = i;
+ if (j != 0) {
+ qnichost = (char *) calloc(i - j + 1 + \
+ strlen(QNICHOST_TAIL), sizeof(char));
+ if (!qnichost)
+ err(1, "malloc");
+ strcpy(qnichost, *argv + j + 1);
+ strcat(qnichost, QNICHOST_TAIL);
+ host = qnichost;
+ }
+ }
+ }
+
s = socket(PF_INET, SOCK_STREAM, 0);
if (s < 0)
err(EX_OSERR, "socket");
@@ -152,6 +180,6 @@ main(argc, argv)
static void
usage()
{
- (void)fprintf(stderr, "usage: whois [-adpr] [-h hostname] name ...\n");
+ (void)fprintf(stderr, "usage: whois [-admpqr] [-h hostname] name ...\n");
exit(EX_USAGE);
}