diff options
-rw-r--r-- | usr.bin/whois/whois.1 | 9 | ||||
-rw-r--r-- | usr.bin/whois/whois.c | 28 |
2 files changed, 29 insertions, 8 deletions
diff --git a/usr.bin/whois/whois.1 b/usr.bin/whois/whois.1 index debe3b1..31dd5c1 100644 --- a/usr.bin/whois/whois.1 +++ b/usr.bin/whois/whois.1 @@ -91,6 +91,15 @@ In the event that an IP address is specified, the whois server will default to the American Registry for Internet Numbers .Pq Tn ARIN . +If a query to +.Tn ARIN +references +.Tn APNIC +or +.Tn RIPE , +that server will be queried also, provided that the +.Fl Q +option is not specified. .Pp If no required .Pa whois-servers.net diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c index d7508c9..ac2619b 100644 --- a/usr.bin/whois/whois.c +++ b/usr.bin/whois/whois.c @@ -77,6 +77,8 @@ static const char rcsid[] = #define WHOIS_INIC_FALLBACK 0x02 #define WHOIS_QUICK 0x04 +const char *ip_whois[] = { RNICHOST, PNICHOST, NULL }; + static void usage(void); static void whois(char *, struct addrinfo *, int); @@ -208,7 +210,7 @@ whois(char *name, struct addrinfo *res, int flags) FILE *sfi, *sfo; struct addrinfo hints, *res2; char *buf, *nhost, *p; - int nomatch, error, s; + int i, nomatch, error, s; size_t len; for (; res; res = res->ai_next) { @@ -234,13 +236,23 @@ whois(char *name, struct addrinfo *res, int flags) while (len && isspace(buf[len - 1])) buf[--len] = '\0'; - if ((flags & WHOIS_RECURSE) && nhost == NULL && - (p = strstr(buf, WHOIS_SERVER_ID)) != NULL) { - p += sizeof(WHOIS_SERVER_ID) - 1; - if ((len = strcspn(p, " \t\n\r")) != 0) { - asprintf(&nhost, "%s", p); - if (nhost == NULL) - err(1, "asprintf()"); + if ((flags & WHOIS_RECURSE) && nhost == NULL) { + p = strstr(buf, WHOIS_SERVER_ID); + if (p != NULL) { + p += sizeof(WHOIS_SERVER_ID) - 1; + if ((len = strcspn(p, " \t\n\r")) != 0) { + asprintf(&nhost, "%s", p); + if (nhost == NULL) + err(1, "asprintf()"); + } + } else { + for (i = 0; ip_whois[i] != NULL; i++) { + if (strstr(buf, ip_whois[i]) == NULL) + continue; + nhost = strdup(ip_whois[i]); + if (nhost == NULL) + err(1, "strdup()"); + } } } |