View | Details | Raw Unified | Return to bug 28426
Collapse All | Expand All

(-)whois/whois.1 (-6 / +14 lines)
Lines 80-86 Link Here
80
.Pp
80
.Pp
81
By default
81
By default
82
.Nm
82
.Nm
83
construct the name of a whois server to use from the top-level domain
83
constructs the name of a whois server to use from the top-level domain
84
.Pq Tn TLD
84
.Pq Tn TLD
85
of the supplied (single) argument, and appending
85
of the supplied (single) argument, and appending
86
.Qq Li .whois-servers.net .
86
.Qq Li .whois-servers.net .
Lines 91-102 Link Here
91
address is specified, the whois server will default to the American
91
address is specified, the whois server will default to the American
92
Registry for Internet Numbers
92
Registry for Internet Numbers
93
.Pq Tn ARIN .
93
.Pq Tn ARIN .
94
If a query to
95
.Tn ARIN
96
references
97
.Tn APNIC
98
or
99
.Tn RIPE ,
100
that server will be query also, provided that the
101
.Fl Q
102
option isn't specified.
94
.Pp
103
.Pp
95
If no required
104
If the query isn't a domain or IP address,
96
.Pa whois-servers.net
105
.Nm
97
subdomain found, fallback to
106
will fallback to
98
.Pa whois.crsnic.net
107
.Pa whois.crsnic.net .
99
provided.
100
.It Fl i
108
.It Fl i
101
Use the Network Solutions Registry for Internet Numbers
109
Use the Network Solutions Registry for Internet Numbers
102
.Pq Pa whois.networksolutions.com
110
.Pq Pa whois.networksolutions.com
(-)whois/whois.c (-8 / +20 lines)
Lines 77-82 Link Here
77
#define WHOIS_INIC_FALLBACK	0x02
77
#define WHOIS_INIC_FALLBACK	0x02
78
#define WHOIS_QUICK		0x04
78
#define WHOIS_QUICK		0x04
79
79
80
const char *ip_whois[] = { RNICHOST, PNICHOST, NULL };
81
80
static void usage(void);
82
static void usage(void);
81
static void whois(char *, struct addrinfo *, int);
83
static void whois(char *, struct addrinfo *, int);
82
84
Lines 208-214 Link Here
208
	FILE *sfi, *sfo;
210
	FILE *sfi, *sfo;
209
	struct addrinfo hints, *res2;
211
	struct addrinfo hints, *res2;
210
	char *buf, *nhost, *p;
212
	char *buf, *nhost, *p;
211
	int nomatch, error, s;
213
	int i, nomatch, error, s;
212
	size_t len;
214
	size_t len;
213
215
214
	for (; res; res = res->ai_next) {
216
	for (; res; res = res->ai_next) {
Lines 234-246 Link Here
234
		while (len && isspace(buf[len - 1]))
236
		while (len && isspace(buf[len - 1]))
235
			buf[--len] = '\0';
237
			buf[--len] = '\0';
236
238
237
		if ((flags & WHOIS_RECURSE) && nhost == NULL &&
239
		if ((flags & WHOIS_RECURSE) && nhost == NULL) {
238
		    (p = strstr(buf, WHOIS_SERVER_ID)) != NULL) {
240
			p = strstr(buf, WHOIS_SERVER_ID);
239
			p += sizeof(WHOIS_SERVER_ID) - 1;
241
			if (p != NULL) {
240
			if ((len = strcspn(p, " \t\n\r")) != 0) {
242
				p += sizeof(WHOIS_SERVER_ID) - 1;
241
				asprintf(&nhost, "%s", p);
243
				if ((len = strcspn(p, " \t\n\r")) != 0) {
242
				if (nhost == NULL)
244
					asprintf(&nhost, "%s", p);
243
					err(1, "asprintf()");
245
					if (nhost == NULL)
246
						err(1, "asprintf()");
247
				}
248
			} else {
249
				for (i = 0; ip_whois[i] != NULL; i++) {
250
					if (strstr(buf, ip_whois[i]) == NULL)
251
						continue;
252
					nhost = strdup(ip_whois[i]);
253
					if (nhost == NULL)
254
						err(1, "strdup()");
255
				}
244
			}
256
			}
245
		}
257
		}

Return to bug 28426