diff options
| author | Dima Dorfman <dd@FreeBSD.org> | 2001-06-27 23:06:47 +0000 |
|---|---|---|
| committer | Dima Dorfman <dd@FreeBSD.org> | 2001-06-27 23:06:47 +0000 |
| commit | 40682bea9a452eccb2ae73cbfc9b206a33c23bf9 (patch) | |
| tree | b4f392be1dc278a9e43704c37ab140639d6e1974 | |
| parent | 54b442b0fa7bb194cd3feab5a5e71e8b72de9790 (diff) | |
Notes
| -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 debe3b156803..31dd5c17f383 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 d7508c902b19..ac2619b5c59a 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()"); + } } } |
