[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Minor (cosmetic) modifications to whois(1)



I've just made two very minor (cosmetic) modifications to whois(1):

1. Added -m option, which selects whois.ra.net as the whois server.
This server publishes routing policy for a large number of network
operators, and is currently run by Merit (see www.ra.net for more
details).

2. Added -q option, which constructs a whois server to use based on
the TLD of the (single) argument, with ".whois-servers.net" appended.
The whois-servers.net zone is run by the people at ultradns.com.
This allows, for example, queries like

  whois -q patho.gen.nz
  whois -q microsoft.com
  whois -q nasa.gov
  whois -q nic.fr
  whois -q demon.co.uk

to all provide meaningful output without having to worry about different
whois switches for different registries.

Small, simple patch included below.

Comments welcome :)


Joe

diff -c whois.original/whois.1 whois/whois.1
*** whois.original/whois.1	Sat Jun  5 05:59:00 1999
--- whois/whois.1	Sun Oct  3 13:04:57 1999
***************
*** 69,79 ****
--- 69,90 ----
  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 -c whois.original/whois.c whois/whois.c
*** whois.original/whois.c	Tue Aug 17 05:43:00 1999
--- whois/whois.c	Sun Oct  3 13:03:19 1999
***************
*** 64,69 ****
--- 64,71 ----
  #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,90 ****
  	struct servent *sp;
  	int s;
  	char *host;
  
  	host = NICHOST;
! 	while ((ch = getopt(argc, argv, "adh:pr")) != -1)
  		switch((char)ch) {
  		case 'a':
  			host = ANICHOST;
--- 84,96 ----
  	struct servent *sp;
  	int s;
  	char *host;
+ 	char *qnichost;
+ 	int use_qnichost;
+ 	int i, j;
  
  	host = NICHOST;
! 	use_qnichost = 0;
! 	while ((ch = getopt(argc, argv, "adh:pmqr")) != -1)
  		switch((char)ch) {
  		case 'a':
  			host = ANICHOST;
***************
*** 95,103 ****
--- 101,115 ----
  		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,116 ****
--- 123,144 ----
  	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) {
+ 					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,157 ****
  static void
  usage()
  {
! 	(void)fprintf(stderr, "usage: whois [-adpr] [-h hostname] name ...\n");
  	exit(EX_USAGE);
  }
--- 180,185 ----
  static void
  usage()
  {
! 	(void)fprintf(stderr, "usage: whois [-admpqr] [-h hostname] name ...\n");
  	exit(EX_USAGE);
  }