From jabley@noc.clix.net.nz Sat Oct  2 16:41:30 1999
Return-Path: <jabley@noc.clix.net.nz>
Received: from noc.clix.net.nz (noc.clix.net.nz [203.167.224.28])
	by hub.freebsd.org (Postfix) with ESMTP id 50C6715436
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  2 Oct 1999 16:40:45 -0700 (PDT)
	(envelope-from jabley@noc.clix.net.nz)
Received: (from jabley@localhost)
	by noc.clix.net.nz (8.8.8/8.8.8) id MAA03133;
	Sun, 3 Oct 1999 12:40:44 +1300 (NZDT)
	(envelope-from jabley)
Message-Id: <199910022340.MAA03133@noc.clix.net.nz>
Date: Sun, 3 Oct 1999 12:40:44 +1300 (NZDT)
From: Joe Abley <jabley@noc.clix.net.nz>
Reply-To: jabley@patho.gen.nz
To: FreeBSD-gnats-submit@freebsd.org
Subject: minor enhancements to whois(1)
X-Send-Pr-Version: 3.2

>Number:         14095
>Category:       bin
>Synopsis:       Add some (cosmetic) functionality to whois(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct  2 16:50:01 PDT 1999
>Closed-Date:    Sun Dec 5 13:29:18 PST 1999
>Last-Modified:  Sun Dec  5 13:32:06 PST 1999
>Originator:     Joe Abley
>Release:        current
>Organization:
Ballistic Shoe-Shine, Inc
>Environment:

N/A

>Description:

Adds two new switches to whois(1). From revised man page:

     -m      Use the Route Arbiter Database (RADB) database. It contains route
             policy specifications for a large number of operators' networks.

     -q      Construct the name of a whois server to use from the top-level
             domain (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.

The -m switch follows the existing -a, -d, -g, -p, -r and -R switches.

The -q switch allows the user to be more stupid in selecting a whois
server. For example, whois -q patho.gen.nz, whois -q nasa.gov,
whois -q microsoft.com and whois -q demon.co.uk all produce meaningful
results.

>How-To-Repeat:

N/A

>Fix:
	
Apply the following sterile dressing, stir gently and bake for six hours.


diff -c whois/whois.1 whois.new/whois.1
*** whois/whois.1	Sat Aug 28 12:17:00 1999
--- whois.new/whois.1	Sun Oct  3 12:34:37 1999
***************
*** 70,80 ****
--- 70,91 ----
  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/whois.c whois.new/whois.c
*** whois/whois.c	Sat Aug 28 12:17:00 1999
--- whois.new/whois.c	Sun Oct  3 12:17:14 1999
***************
*** 63,68 ****
--- 63,70 ----
  #define	RNICHOST	"whois.ripe.net"
  #define	PNICHOST	"whois.apnic.net"
  #define RUNICHOST       "whois.ripn.net"
+ #define MNICHOST	"whois.ra.net"
+ #define	QNICHOST_TAIL	".whois-servers.net"
  #define	WHOIS_PORT	43
  
  static void usage __P((void));
***************
*** 79,91 ****
  	struct servent *sp;
  	int s;
  	char *host;
  
  #ifdef	SOCKS
  	SOCKSinit(argv[0]);
  #endif
  
  	host = NICHOST;
! 	while ((ch = getopt(argc, argv, "adgh:prR")) != -1)
  		switch((char)ch) {
  		case 'a':
  			host = ANICHOST;
--- 81,97 ----
  	struct servent *sp;
  	int s;
  	char *host;
+ 	char *qnichost;
+ 	int use_qnichost;
+ 	int i, j;
  
  #ifdef	SOCKS
  	SOCKSinit(argv[0]);
  #endif
  
  	host = NICHOST;
! 	use_qnichost = 0;
! 	while ((ch = getopt(argc, argv, "adgh:mpqrR")) != -1)
  		switch((char)ch) {
  		case 'a':
  			host = ANICHOST;
***************
*** 99,107 ****
--- 105,119 ----
  		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;
***************
*** 118,123 ****
--- 130,151 ----
  	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");
***************
*** 159,164 ****
  static void
  usage()
  {
! 	fprintf(stderr, "usage: whois [-adgprR] [-h hostname] name ...\n");
  	exit(EX_USAGE);
  }
--- 187,192 ----
  static void
  usage()
  {
! 	fprintf(stderr, "usage: whois [-adgmpqrR] [-h hostname] name ...\n");
  	exit(EX_USAGE);
  }

>Release-Note:
>Audit-Trail:

From: Chris Costello <chris@calldei.com>
To: jabley@patho.gen.nz
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/14095: minor enhancements to whois(1)
Date: Sat, 02 Oct 1999 20:02:15 -0500

 On Sun, Oct 03, 1999, Joe Abley wrote:
 > The -m switch follows the existing -a, -d, -g, -p, -r and -R switches.
 
    If more and more countries keep setting up whois hosts,
 whois(1) is going to have more switches than ls(1)!
 
 -- 
 |Chris Costello <chris@calldei.com>
 |The best packed information most resembles random noise.
 `--------------------------------------------------------
 

From: Joe Abley <jabley@patho.gen.nz>
To: Chris Costello <chris@calldei.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/14095: minor enhancements to whois(1)
Date: Sun, 3 Oct 1999 14:05:23 +1300

 On Sat, Oct 02, 1999 at 08:02:15PM -0500, Chris Costello wrote:
 > On Sun, Oct 03, 1999, Joe Abley wrote:
 > > The -m switch follows the existing -a, -d, -g, -p, -r and -R switches.
 > 
 >    If more and more countries keep setting up whois hosts,
 > whois(1) is going to have more switches than ls(1)!
 
 Aah, but my next plan was to submit a patch to remove -R and make
 -q the default. Then we never need any more :)
 
 
 Joe
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: Joe Abley <jabley@patho.gen.nz>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/14095: Cosmetic changes to whois(1) 
Date: Mon, 04 Oct 1999 11:54:19 +0200

 On Sun, 03 Oct 1999 12:56:27 +1300, Joe Abley wrote:
 
 > 1. Added -m option, which selects whois.ra.net as the whois server.
 
 If this doesn't achieve anything other than ``-h whois.ra.net'', I
 wouldn't add it.
 
 > 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
 
 I'd use something other than -q. Presumably you chose -q for "query",
 but that's pretty general, given the scope of the propgram. :-)  The -q
 option is often used for quiet. How about -n or -z?
 
 Ciao,
 Sheldon.
 

From: Joe Abley <jabley@patho.gen.nz>
To: Sheldon Hearn <sheldonh@uunet.co.za>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/14095: Cosmetic changes to whois(1)
Date: Mon, 4 Oct 1999 22:57:51 +1300

 On Mon, Oct 04, 1999 at 11:54:19AM +0200, Sheldon Hearn wrote:
 > 
 > 
 > On Sun, 03 Oct 1999 12:56:27 +1300, Joe Abley wrote:
 > 
 > > 1. Added -m option, which selects whois.ra.net as the whois server.
 > 
 > If this doesn't achieve anything other than ``-h whois.ra.net'', I
 > wouldn't add it.
 
 Why were -r, -p, -a and -R added, in that case? I notice particularly
 that -R is a recent addition.
 
 > > 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
 > 
 > I'd use something other than -q. Presumably you chose -q for "query",
 > but that's pretty general, given the scope of the propgram. :-)  The -q
 > option is often used for quiet. How about -n or -z?
 
 I used q for "quick" in the sense that you don't need to think about
 which whois server you're using. Since Theo rolled this patch straight
 into OpenBSD, it also now has the attraction of being consistent
 with another OS :)
 
 
 Joe
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: Joe Abley <jabley@patho.gen.nz>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/14095: Cosmetic changes to whois(1) 
Date: Mon, 04 Oct 1999 12:03:49 +0200

 On Mon, 04 Oct 1999 22:57:51 +1300, Joe Abley wrote:
 
 > Why were -r, -p, -a and -R added, in that case? I notice particularly
 > that -R is a recent addition.
 > 
 > I used q for "quick" in the sense that you don't need to think about
 > which whois server you're using. Since Theo rolled this patch straight
 > into OpenBSD, it also now has the attraction of being consistent
 > with another OS :)
 
 Hmmm, you've thought about both points more than I have. :-)
 
 Ciao,
 Sheldon.
 

From: Joe Abley <jabley@patho.gen.nz>
To: Sheldon Hearn <sheldonh@uunet.co.za>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/14095: Cosmetic changes to whois(1)
Date: Mon, 4 Oct 1999 23:10:04 +1300

 On Mon, Oct 04, 1999 at 12:03:49PM +0200, Sheldon Hearn wrote:
 > 
 > 
 > On Mon, 04 Oct 1999 22:57:51 +1300, Joe Abley wrote:
 > 
 > > Why were -r, -p, -a and -R added, in that case? I notice particularly
 > > that -R is a recent addition.
 > > 
 > > I used q for "quick" in the sense that you don't need to think about
 > > which whois server you're using. Since Theo rolled this patch straight
 > > into OpenBSD, it also now has the attraction of being consistent
 > > with another OS :)
 > 
 > Hmmm, you've thought about both points more than I have. :-)
 
 There are a couple of improvements I am planning, namely:
 
 1. "whois -q demon.co.uk pipex.com uunet.ca" as a single incantation
 ought to return sensible information for all three domains, by making
 multiple queries. The patch I previously submitted will abandon the
 spirit of "-q" in this case, and pass the entire string to the
 default whois server (which is a waste of time).
 
 2. net.au and (!net).au have different whois servers. The ultradns
 people have thought about this, and net.au.whois-servers.net and
 au.whois-servers.net are CNAMEs for different whois servers. Some
 kind of sensible recursive lookup is in order to ensure that the
 second (etc) level domain isn't relevant in selecting a whois server.
 
 Still, the feedback on the -q option in general has been very
 positive. Thanks to those tried it out :)
 
 
 Joe
 (on an unexpected crusade to strain the whois soup)
 
 
State-Changed-From-To: open->closed 
State-Changed-By: joe 
State-Changed-When: Sun Dec 5 13:29:18 PST 1999 
State-Changed-Why:  
This functionality has been added to -current by ache in recent weeks. 
Use the '-m' to lookup against RADB. 
Default lookup is to use .whois-server.net to determine which whois server 
to use for general lookups. 
>Unformatted:
