o Move APNIC flag from -p to -A. Since, -p is usually associated
with specifying a port. o Add the -p flag for specifying a port. (PR: 28790) This is useful for querying rwhois servers. Example: whois -h rwhois.exodus.net -p rwhois 216.136.180.0 o Add the -c flag which allows one to get the same whois server that would normally be determined if no arguments were specified. (Concept based on work by phantom, requested by ache) Example: whois -c ru TCNET-MNT-RIPN o Deprecate -R flag in favour of -c ru. PR: 28790 Reviewed by: -audit, ache, phantom
This commit is contained in:
parent
4c37b1678b
commit
ee03551b7f
@ -40,8 +40,9 @@
|
|||||||
.Nd "Internet domain name and network number directory service"
|
.Nd "Internet domain name and network number directory service"
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl adgimpQrR6
|
.Op Fl aAdgimQrR6
|
||||||
.Op Fl h Ar host
|
.Op Fl c Ar country-code | Fl h Ar host
|
||||||
|
.Op Fl p Ar port
|
||||||
.Ar name ...
|
.Ar name ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
@ -65,6 +66,17 @@ to the NIC handle:
|
|||||||
.Pp
|
.Pp
|
||||||
.Dl "$ whois -a foo3-ARIN"
|
.Dl "$ whois -a foo3-ARIN"
|
||||||
.Pp
|
.Pp
|
||||||
|
.It Fl A
|
||||||
|
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 c Ar country-code
|
||||||
|
This is the equivalent of using the
|
||||||
|
.Fl h
|
||||||
|
option with an argument of
|
||||||
|
.Qq Ar country-code Ns Li .whois-servers.net .
|
||||||
.It Fl d
|
.It Fl d
|
||||||
Use the US Department of Defense
|
Use the US Department of Defense
|
||||||
database.
|
database.
|
||||||
@ -139,12 +151,12 @@ Use the Route Arbiter Database
|
|||||||
database.
|
database.
|
||||||
It contains route policy specifications for a large
|
It contains route policy specifications for a large
|
||||||
number of operators' networks.
|
number of operators' networks.
|
||||||
.It Fl p
|
.It Fl p Ar port
|
||||||
Use the Asia/Pacific Network Information Center
|
Connect to the whois server on
|
||||||
.Pq Tn APNIC
|
.Ar port .
|
||||||
database.
|
If this option is not specified,
|
||||||
It contains network numbers used in East Asia, Australia,
|
.Nm
|
||||||
New Zealand, and the Pacific islands.
|
defaults to port 43.
|
||||||
.It Fl Q
|
.It Fl Q
|
||||||
Do a quick lookup.
|
Do a quick lookup.
|
||||||
This means that
|
This means that
|
||||||
@ -166,6 +178,11 @@ database.
|
|||||||
It contains network numbers and domain contact information
|
It contains network numbers and domain contact information
|
||||||
for subdomains of
|
for subdomains of
|
||||||
.Pa .RU .
|
.Pa .RU .
|
||||||
|
This option is deprecated; use the
|
||||||
|
.Fl c
|
||||||
|
option with an argument of
|
||||||
|
.Qq ru
|
||||||
|
instead.
|
||||||
.It Fl 6
|
.It Fl 6
|
||||||
Use the IPv6 Resource Center
|
Use the IPv6 Resource Center
|
||||||
.Pq Tn 6bone
|
.Pq Tn 6bone
|
||||||
|
@ -66,11 +66,10 @@ static const char rcsid[] =
|
|||||||
#define ANICHOST "whois.arin.net"
|
#define ANICHOST "whois.arin.net"
|
||||||
#define RNICHOST "whois.ripe.net"
|
#define RNICHOST "whois.ripe.net"
|
||||||
#define PNICHOST "whois.apnic.net"
|
#define PNICHOST "whois.apnic.net"
|
||||||
#define RUNICHOST "whois.ripn.net"
|
|
||||||
#define MNICHOST "whois.ra.net"
|
#define MNICHOST "whois.ra.net"
|
||||||
#define QNICHOST_TAIL ".whois-servers.net"
|
#define QNICHOST_TAIL ".whois-servers.net"
|
||||||
#define SNICHOST "whois.6bone.net"
|
#define SNICHOST "whois.6bone.net"
|
||||||
#define WHOIS_PORT 43
|
#define DEFAULT_PORT "whois"
|
||||||
#define WHOIS_SERVER_ID "Whois Server: "
|
#define WHOIS_SERVER_ID "Whois Server: "
|
||||||
#define NO_MATCH_ID "No match for \""
|
#define NO_MATCH_ID "No match for \""
|
||||||
|
|
||||||
@ -79,6 +78,7 @@ static const char rcsid[] =
|
|||||||
#define WHOIS_QUICK 0x04
|
#define WHOIS_QUICK 0x04
|
||||||
|
|
||||||
const char *ip_whois[] = { RNICHOST, PNICHOST, NULL };
|
const char *ip_whois[] = { RNICHOST, PNICHOST, NULL };
|
||||||
|
const char *port = DEFAULT_PORT;
|
||||||
|
|
||||||
static char *choose_server(char *);
|
static char *choose_server(char *);
|
||||||
static struct addrinfo *gethostinfo(char const *host, int exit_on_error);
|
static struct addrinfo *gethostinfo(char const *host, int exit_on_error);
|
||||||
@ -90,7 +90,7 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct addrinfo *res;
|
struct addrinfo *res;
|
||||||
const char *host;
|
const char *country, *host;
|
||||||
char *qnichost;
|
char *qnichost;
|
||||||
int ch, flags, use_qnichost;
|
int ch, flags, use_qnichost;
|
||||||
|
|
||||||
@ -98,15 +98,19 @@ main(int argc, char *argv[])
|
|||||||
SOCKSinit(argv[0]);
|
SOCKSinit(argv[0]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
host = NULL;
|
country = host = qnichost = NULL;
|
||||||
qnichost = NULL;
|
flags = use_qnichost = 0;
|
||||||
flags = 0;
|
while ((ch = getopt(argc, argv, "aAc:dgh:imp:QrR6")) != -1) {
|
||||||
use_qnichost = 0;
|
|
||||||
while ((ch = getopt(argc, argv, "adgh:impQrR6")) != -1) {
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
host = ANICHOST;
|
host = ANICHOST;
|
||||||
break;
|
break;
|
||||||
|
case 'A':
|
||||||
|
host = PNICHOST;
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
country = optarg;
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
host = DNICHOST;
|
host = DNICHOST;
|
||||||
break;
|
break;
|
||||||
@ -123,7 +127,7 @@ main(int argc, char *argv[])
|
|||||||
host = MNICHOST;
|
host = MNICHOST;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
host = PNICHOST;
|
port = optarg;
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
case 'Q':
|
||||||
flags |= WHOIS_QUICK;
|
flags |= WHOIS_QUICK;
|
||||||
@ -132,7 +136,8 @@ main(int argc, char *argv[])
|
|||||||
host = RNICHOST;
|
host = RNICHOST;
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
host = RUNICHOST;
|
warnx("-R is deprecated; use '-c ru' instead");
|
||||||
|
country = "ru";
|
||||||
break;
|
break;
|
||||||
case '6':
|
case '6':
|
||||||
host = SNICHOST;
|
host = SNICHOST;
|
||||||
@ -146,23 +151,26 @@ main(int argc, char *argv[])
|
|||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (!argc)
|
if (!argc || (country != NULL && host != NULL))
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If no nic host is specified determine the top level domain from
|
* If no host or country is specified determine the top level domain
|
||||||
* the query. If the TLD is a number, query ARIN. Otherwise, use
|
* from the query. If the TLD is a number, query ARIN. Otherwise, use
|
||||||
* TLD.whois-server.net. If the domain does not contain '.', fall
|
* TLD.whois-server.net. If the domain does not contain '.', fall
|
||||||
* back to NICHOST.
|
* back to NICHOST.
|
||||||
*/
|
*/
|
||||||
if (host == NULL) {
|
if (host == NULL && country == NULL) {
|
||||||
use_qnichost = 1;
|
use_qnichost = 1;
|
||||||
host = NICHOST;
|
host = NICHOST;
|
||||||
if (!(flags & WHOIS_QUICK))
|
if (!(flags & WHOIS_QUICK))
|
||||||
flags |= WHOIS_INIC_FALLBACK | WHOIS_RECURSE;
|
flags |= WHOIS_INIC_FALLBACK | WHOIS_RECURSE;
|
||||||
}
|
}
|
||||||
while (argc--) {
|
while (argc--) {
|
||||||
if (use_qnichost)
|
if (country != NULL) {
|
||||||
|
s_asprintf(&qnichost, "%s%s", country, QNICHOST_TAIL);
|
||||||
|
res = gethostinfo(qnichost, 1);
|
||||||
|
} else if (use_qnichost)
|
||||||
if ((qnichost = choose_server(*argv)) != NULL)
|
if ((qnichost = choose_server(*argv)) != NULL)
|
||||||
res = gethostinfo(qnichost, 1);
|
res = gethostinfo(qnichost, 1);
|
||||||
if (qnichost == NULL)
|
if (qnichost == NULL)
|
||||||
@ -212,7 +220,7 @@ gethostinfo(char const *host, int exit_on_error)
|
|||||||
hints.ai_flags = 0;
|
hints.ai_flags = 0;
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
error = getaddrinfo(host, "whois", &hints, &res);
|
error = getaddrinfo(host, port, &hints, &res);
|
||||||
if (error) {
|
if (error) {
|
||||||
warnx("%s: %s", host, gai_strerror(error));
|
warnx("%s: %s", host, gai_strerror(error));
|
||||||
if (exit_on_error)
|
if (exit_on_error)
|
||||||
@ -319,6 +327,7 @@ static void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: whois [-adgimpQrR6] [-h hostname] name ...\n");
|
"usage: whois [-adgimpQrR6] [-c country-code | -h hostname] "
|
||||||
|
"[-p port] name ...\n");
|
||||||
exit(EX_USAGE);
|
exit(EX_USAGE);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user