1994-05-27 12:33:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1980, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef lint
|
2002-03-07 10:06:00 +00:00
|
|
|
static const char copyright[] =
|
1994-05-27 12:33:43 +00:00
|
|
|
"@(#) Copyright (c) 1980, 1993\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n";
|
|
|
|
#endif /* not lint */
|
|
|
|
|
2002-03-07 10:06:00 +00:00
|
|
|
#if 0
|
1994-05-27 12:33:43 +00:00
|
|
|
#ifndef lint
|
|
|
|
static char sccsid[] = "@(#)whois.c 8.1 (Berkeley) 6/6/93";
|
|
|
|
#endif /* not lint */
|
2002-02-03 07:35:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
1998-06-12 12:55:46 +00:00
|
|
|
#include <arpa/inet.h>
|
2001-05-28 21:37:29 +00:00
|
|
|
#include <ctype.h>
|
1997-08-26 11:16:08 +00:00
|
|
|
#include <err.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <netdb.h>
|
2001-07-20 16:44:44 +00:00
|
|
|
#include <stdarg.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <stdio.h>
|
1999-11-17 19:11:51 +00:00
|
|
|
#include <stdlib.h>
|
1997-08-26 11:16:08 +00:00
|
|
|
#include <string.h>
|
1998-02-19 19:07:50 +00:00
|
|
|
#include <sysexits.h>
|
1997-08-26 11:16:08 +00:00
|
|
|
#include <unistd.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2004-06-14 17:30:46 +00:00
|
|
|
#define ABUSEHOST "whois.abuse.net"
|
1999-11-17 19:11:51 +00:00
|
|
|
#define NICHOST "whois.crsnic.net"
|
1999-12-03 16:56:57 +00:00
|
|
|
#define INICHOST "whois.networksolutions.com"
|
1999-02-01 19:22:27 +00:00
|
|
|
#define DNICHOST "whois.nic.mil"
|
|
|
|
#define GNICHOST "whois.nic.gov"
|
1998-02-19 19:07:50 +00:00
|
|
|
#define ANICHOST "whois.arin.net"
|
2002-11-10 16:58:56 +00:00
|
|
|
#define LNICHOST "whois.lacnic.net"
|
2004-12-11 13:14:07 +00:00
|
|
|
#define KNICHOST "whois.krnic.net"
|
1998-02-19 19:07:50 +00:00
|
|
|
#define RNICHOST "whois.ripe.net"
|
|
|
|
#define PNICHOST "whois.apnic.net"
|
1999-11-17 19:11:51 +00:00
|
|
|
#define MNICHOST "whois.ra.net"
|
|
|
|
#define QNICHOST_TAIL ".whois-servers.net"
|
2001-12-08 21:22:42 +00:00
|
|
|
#define BNICHOST "whois.registro.br"
|
2003-03-25 17:00:03 +00:00
|
|
|
#define NORIDHOST "whois.norid.no"
|
2004-06-14 14:03:10 +00:00
|
|
|
#define IANAHOST "whois.iana.org"
|
2004-08-25 15:34:44 +00:00
|
|
|
#define GERMNICHOST "de.whois-servers.net"
|
2006-01-23 13:49:39 +00:00
|
|
|
#define FNICHOST "whois.afrinic.net"
|
2001-08-05 19:37:12 +00:00
|
|
|
#define DEFAULT_PORT "whois"
|
2001-06-22 01:52:37 +00:00
|
|
|
#define WHOIS_SERVER_ID "Whois Server: "
|
2003-01-31 21:57:10 +00:00
|
|
|
#define WHOIS_ORG_SERVER_ID "Registrant Street1:Whois Server:"
|
1994-05-27 12:33:43 +00:00
|
|
|
|
1999-11-17 19:11:51 +00:00
|
|
|
#define WHOIS_RECURSE 0x01
|
2001-10-12 17:39:36 +00:00
|
|
|
#define WHOIS_QUICK 0x02
|
|
|
|
|
|
|
|
#define ishost(h) (isalnum((unsigned char)h) || h == '.' || h == '-')
|
1999-11-17 19:11:51 +00:00
|
|
|
|
2006-01-23 13:49:39 +00:00
|
|
|
const char *ip_whois[] = { LNICHOST, RNICHOST, PNICHOST, BNICHOST,
|
|
|
|
FNICHOST, NULL };
|
2001-08-05 19:37:12 +00:00
|
|
|
const char *port = DEFAULT_PORT;
|
2001-06-27 23:06:47 +00:00
|
|
|
|
2001-07-17 20:40:41 +00:00
|
|
|
static char *choose_server(char *);
|
2001-07-20 16:44:44 +00:00
|
|
|
static struct addrinfo *gethostinfo(char const *host, int exit_on_error);
|
2002-02-04 02:12:49 +00:00
|
|
|
static void s_asprintf(char **ret, const char *format, ...) __printflike(2, 3);
|
2001-06-22 01:52:37 +00:00
|
|
|
static void usage(void);
|
2002-02-03 07:35:32 +00:00
|
|
|
static void whois(const char *, const char *, int);
|
1997-08-26 11:16:08 +00:00
|
|
|
|
|
|
|
int
|
2001-06-22 01:52:37 +00:00
|
|
|
main(int argc, char *argv[])
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-08-05 19:37:12 +00:00
|
|
|
const char *country, *host;
|
2001-06-22 01:52:37 +00:00
|
|
|
char *qnichost;
|
2001-07-20 16:44:44 +00:00
|
|
|
int ch, flags, use_qnichost;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
1996-04-23 06:01:10 +00:00
|
|
|
#ifdef SOCKS
|
|
|
|
SOCKSinit(argv[0]);
|
|
|
|
#endif
|
|
|
|
|
2001-08-05 19:37:12 +00:00
|
|
|
country = host = qnichost = NULL;
|
|
|
|
flags = use_qnichost = 0;
|
2006-01-23 13:49:39 +00:00
|
|
|
while ((ch = getopt(argc, argv, "aAbc:dfgh:iIklmp:QrR6")) != -1) {
|
2001-06-22 01:52:37 +00:00
|
|
|
switch (ch) {
|
1998-02-19 19:07:50 +00:00
|
|
|
case 'a':
|
|
|
|
host = ANICHOST;
|
|
|
|
break;
|
2001-08-05 19:37:12 +00:00
|
|
|
case 'A':
|
|
|
|
host = PNICHOST;
|
|
|
|
break;
|
2004-06-14 17:30:46 +00:00
|
|
|
case 'b':
|
|
|
|
host = ABUSEHOST;
|
|
|
|
break;
|
2001-08-05 19:37:12 +00:00
|
|
|
case 'c':
|
|
|
|
country = optarg;
|
2001-10-17 16:28:12 +00:00
|
|
|
break;
|
1998-02-19 19:07:50 +00:00
|
|
|
case 'd':
|
|
|
|
host = DNICHOST;
|
|
|
|
break;
|
2006-01-23 13:49:39 +00:00
|
|
|
case 'f':
|
|
|
|
host = FNICHOST;
|
|
|
|
break;
|
1999-02-01 19:22:27 +00:00
|
|
|
case 'g':
|
|
|
|
host = GNICHOST;
|
|
|
|
break;
|
1994-05-27 12:33:43 +00:00
|
|
|
case 'h':
|
|
|
|
host = optarg;
|
|
|
|
break;
|
1999-11-09 09:01:38 +00:00
|
|
|
case 'i':
|
|
|
|
host = INICHOST;
|
|
|
|
break;
|
2004-06-14 14:03:10 +00:00
|
|
|
case 'I':
|
|
|
|
host = IANAHOST;
|
|
|
|
break;
|
2004-12-11 13:14:07 +00:00
|
|
|
case 'k':
|
|
|
|
host = KNICHOST;
|
|
|
|
break;
|
2002-11-10 16:58:56 +00:00
|
|
|
case 'l':
|
|
|
|
host = LNICHOST;
|
|
|
|
break;
|
1999-11-17 19:11:51 +00:00
|
|
|
case 'm':
|
|
|
|
host = MNICHOST;
|
|
|
|
break;
|
1998-02-19 19:07:50 +00:00
|
|
|
case 'p':
|
2001-08-05 19:37:12 +00:00
|
|
|
port = optarg;
|
1998-02-19 19:07:50 +00:00
|
|
|
break;
|
1999-11-17 19:11:51 +00:00
|
|
|
case 'Q':
|
|
|
|
flags |= WHOIS_QUICK;
|
|
|
|
break;
|
1998-02-19 19:07:50 +00:00
|
|
|
case 'r':
|
|
|
|
host = RNICHOST;
|
|
|
|
break;
|
1999-02-02 01:49:14 +00:00
|
|
|
case 'R':
|
2001-08-05 19:37:12 +00:00
|
|
|
warnx("-R is deprecated; use '-c ru' instead");
|
|
|
|
country = "ru";
|
1999-02-02 01:49:14 +00:00
|
|
|
break;
|
2009-10-03 02:37:21 +00:00
|
|
|
/* Remove in FreeBSD 10 */
|
1999-12-05 22:43:36 +00:00
|
|
|
case '6':
|
2009-10-03 02:37:21 +00:00
|
|
|
errx(EX_USAGE,
|
|
|
|
"-6 is deprecated; use -[aAflr] instead");
|
1999-12-05 22:43:36 +00:00
|
|
|
break;
|
1994-05-27 12:33:43 +00:00
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
usage();
|
2001-06-22 01:52:37 +00:00
|
|
|
/* NOTREACHED */
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
1999-12-06 21:18:32 +00:00
|
|
|
}
|
1994-05-27 12:33:43 +00:00
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
2001-08-05 19:37:12 +00:00
|
|
|
if (!argc || (country != NULL && host != NULL))
|
1994-05-27 12:33:43 +00:00
|
|
|
usage();
|
|
|
|
|
1999-11-17 19:11:51 +00:00
|
|
|
/*
|
2001-08-05 19:37:12 +00:00
|
|
|
* If no host or country is specified determine the top level domain
|
|
|
|
* from the query. If the TLD is a number, query ARIN. Otherwise, use
|
2001-06-22 01:52:37 +00:00
|
|
|
* TLD.whois-server.net. If the domain does not contain '.', fall
|
|
|
|
* back to NICHOST.
|
1999-11-17 19:11:51 +00:00
|
|
|
*/
|
2001-08-05 19:37:12 +00:00
|
|
|
if (host == NULL && country == NULL) {
|
1999-11-17 19:11:51 +00:00
|
|
|
use_qnichost = 1;
|
|
|
|
host = NICHOST;
|
2001-06-22 01:52:37 +00:00
|
|
|
if (!(flags & WHOIS_QUICK))
|
2001-10-12 17:39:36 +00:00
|
|
|
flags |= WHOIS_RECURSE;
|
1999-11-17 19:11:51 +00:00
|
|
|
}
|
2002-02-03 07:35:32 +00:00
|
|
|
while (argc-- > 0) {
|
2001-08-05 19:37:12 +00:00
|
|
|
if (country != NULL) {
|
|
|
|
s_asprintf(&qnichost, "%s%s", country, QNICHOST_TAIL);
|
2002-02-03 07:35:32 +00:00
|
|
|
whois(*argv, qnichost, flags);
|
2001-10-17 16:28:12 +00:00
|
|
|
} else if (use_qnichost)
|
2001-07-20 16:44:44 +00:00
|
|
|
if ((qnichost = choose_server(*argv)) != NULL)
|
2002-02-03 07:35:32 +00:00
|
|
|
whois(*argv, qnichost, flags);
|
2001-07-20 16:44:44 +00:00
|
|
|
if (qnichost == NULL)
|
2002-02-03 07:35:32 +00:00
|
|
|
whois(*argv, host, flags);
|
2001-06-22 01:52:37 +00:00
|
|
|
free(qnichost);
|
|
|
|
qnichost = NULL;
|
2002-02-03 07:35:32 +00:00
|
|
|
argv++;
|
1999-11-17 19:11:51 +00:00
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2001-07-17 20:40:41 +00:00
|
|
|
/*
|
|
|
|
* This function will remove any trailing periods from domain, after which it
|
|
|
|
* returns a pointer to newly allocated memory containing the whois server to
|
|
|
|
* be queried, or a NULL if the correct server couldn't be determined. The
|
|
|
|
* caller must remember to free(3) the allocated memory.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
choose_server(char *domain)
|
|
|
|
{
|
|
|
|
char *pos, *retval;
|
|
|
|
|
|
|
|
for (pos = strchr(domain, '\0'); pos > domain && *--pos == '.';)
|
|
|
|
*pos = '\0';
|
|
|
|
if (*domain == '\0')
|
|
|
|
errx(EX_USAGE, "can't search for a null string");
|
2003-03-25 17:00:03 +00:00
|
|
|
if (strlen(domain) > sizeof("-NORID")-1 &&
|
|
|
|
strcasecmp(domain + strlen(domain) - sizeof("-NORID") + 1,
|
|
|
|
"-NORID") == 0) {
|
|
|
|
s_asprintf(&retval, "%s", NORIDHOST);
|
|
|
|
return (retval);
|
|
|
|
}
|
2001-07-17 20:40:41 +00:00
|
|
|
while (pos > domain && *pos != '.')
|
|
|
|
--pos;
|
2001-07-22 18:23:24 +00:00
|
|
|
if (pos <= domain)
|
|
|
|
return (NULL);
|
2001-07-20 16:44:44 +00:00
|
|
|
if (isdigit((unsigned char)*++pos))
|
|
|
|
s_asprintf(&retval, "%s", ANICHOST);
|
2003-06-29 23:56:31 +00:00
|
|
|
else
|
2001-07-20 16:44:44 +00:00
|
|
|
s_asprintf(&retval, "%s%s", pos, QNICHOST_TAIL);
|
2001-07-17 20:40:41 +00:00
|
|
|
return (retval);
|
|
|
|
}
|
|
|
|
|
2001-10-17 16:28:12 +00:00
|
|
|
static struct addrinfo *
|
2001-07-20 16:44:44 +00:00
|
|
|
gethostinfo(char const *host, int exit_on_error)
|
|
|
|
{
|
|
|
|
struct addrinfo hints, *res;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
hints.ai_flags = 0;
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
2001-08-05 19:37:12 +00:00
|
|
|
error = getaddrinfo(host, port, &hints, &res);
|
2001-07-20 16:44:44 +00:00
|
|
|
if (error) {
|
|
|
|
warnx("%s: %s", host, gai_strerror(error));
|
|
|
|
if (exit_on_error)
|
|
|
|
exit(EX_NOHOST);
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
return (res);
|
2001-10-17 16:28:12 +00:00
|
|
|
}
|
2001-07-20 16:44:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Wrapper for asprintf(3) that exits on error.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
s_asprintf(char **ret, const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, format);
|
|
|
|
if (vasprintf(ret, format, ap) == -1) {
|
|
|
|
va_end(ap);
|
|
|
|
err(EX_OSERR, "vasprintf()");
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
1999-11-17 19:11:51 +00:00
|
|
|
static void
|
2002-02-03 07:35:32 +00:00
|
|
|
whois(const char *query, const char *hostname, int flags)
|
1999-11-17 19:11:51 +00:00
|
|
|
{
|
|
|
|
FILE *sfi, *sfo;
|
2002-02-03 07:35:32 +00:00
|
|
|
struct addrinfo *hostres, *res;
|
2001-10-12 17:39:36 +00:00
|
|
|
char *buf, *host, *nhost, *p;
|
|
|
|
int i, s;
|
2002-09-18 07:51:46 +00:00
|
|
|
size_t c, len;
|
1999-11-17 19:11:51 +00:00
|
|
|
|
2005-05-29 15:49:53 +00:00
|
|
|
s = -1;
|
2002-02-03 07:35:32 +00:00
|
|
|
hostres = gethostinfo(hostname, 1);
|
|
|
|
for (res = hostres; res; res = res->ai_next) {
|
2001-06-01 13:43:20 +00:00
|
|
|
s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
2001-06-22 01:52:37 +00:00
|
|
|
if (s < 0)
|
2001-06-01 13:43:20 +00:00
|
|
|
continue;
|
2001-06-22 01:52:37 +00:00
|
|
|
if (connect(s, res->ai_addr, res->ai_addrlen) == 0)
|
2001-06-01 13:43:20 +00:00
|
|
|
break;
|
|
|
|
close(s);
|
1999-12-06 21:18:32 +00:00
|
|
|
}
|
2002-02-03 07:35:32 +00:00
|
|
|
freeaddrinfo(hostres);
|
2001-06-22 01:52:37 +00:00
|
|
|
if (res == NULL)
|
|
|
|
err(EX_OSERR, "connect()");
|
1998-02-19 19:07:50 +00:00
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
sfi = fdopen(s, "r");
|
|
|
|
sfo = fdopen(s, "w");
|
2001-06-22 01:52:37 +00:00
|
|
|
if (sfi == NULL || sfo == NULL)
|
|
|
|
err(EX_OSERR, "fdopen()");
|
2004-08-25 15:34:44 +00:00
|
|
|
if (strcmp(hostname, GERMNICHOST) == 0) {
|
|
|
|
fprintf(sfo, "-T dn,ace -C US-ASCII %s\r\n", query);
|
2007-01-19 08:13:17 +00:00
|
|
|
} else if (strcmp(hostname, "dk" QNICHOST_TAIL) == 0) {
|
|
|
|
fprintf(sfo, "--show-handles %s\r\n", query);
|
2004-08-25 15:34:44 +00:00
|
|
|
} else {
|
|
|
|
fprintf(sfo, "%s\r\n", query);
|
|
|
|
}
|
2001-06-22 01:52:37 +00:00
|
|
|
fflush(sfo);
|
1999-11-17 19:11:51 +00:00
|
|
|
nhost = NULL;
|
2001-06-22 01:52:37 +00:00
|
|
|
while ((buf = fgetln(sfi, &len)) != NULL) {
|
2001-10-12 17:39:36 +00:00
|
|
|
while (len > 0 && isspace((unsigned char)buf[len - 1]))
|
2001-06-22 01:52:37 +00:00
|
|
|
buf[--len] = '\0';
|
2001-10-12 17:39:36 +00:00
|
|
|
printf("%.*s\n", (int)len, buf);
|
1999-11-17 19:11:51 +00:00
|
|
|
|
2001-06-27 23:06:47 +00:00
|
|
|
if ((flags & WHOIS_RECURSE) && nhost == NULL) {
|
2001-10-12 17:39:36 +00:00
|
|
|
host = strnstr(buf, WHOIS_SERVER_ID, len);
|
|
|
|
if (host != NULL) {
|
|
|
|
host += sizeof(WHOIS_SERVER_ID) - 1;
|
|
|
|
for (p = host; p < buf + len; p++) {
|
|
|
|
if (!ishost(*p)) {
|
|
|
|
*p = '\0';
|
|
|
|
break;
|
|
|
|
}
|
2001-06-27 23:06:47 +00:00
|
|
|
}
|
2001-10-12 17:39:36 +00:00
|
|
|
s_asprintf(&nhost, "%.*s",
|
|
|
|
(int)(buf + len - host), host);
|
2003-02-24 17:10:32 +00:00
|
|
|
} else if ((host =
|
|
|
|
strnstr(buf, WHOIS_ORG_SERVER_ID, len)) != NULL) {
|
|
|
|
host += sizeof(WHOIS_ORG_SERVER_ID) - 1;
|
2003-01-31 21:57:10 +00:00
|
|
|
for (p = host; p < buf + len; p++) {
|
|
|
|
if (!ishost(*p)) {
|
|
|
|
*p = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s_asprintf(&nhost, "%.*s",
|
2003-02-24 17:10:32 +00:00
|
|
|
(int)(buf + len - host), host);
|
|
|
|
} else if (strcmp(hostname, ANICHOST) == 0) {
|
2002-09-18 07:51:46 +00:00
|
|
|
for (c = 0; c <= len; c++)
|
2007-04-14 14:32:48 +00:00
|
|
|
buf[c] = tolower((unsigned char)buf[c]);
|
2001-06-27 23:06:47 +00:00
|
|
|
for (i = 0; ip_whois[i] != NULL; i++) {
|
2001-10-12 17:39:36 +00:00
|
|
|
if (strnstr(buf, ip_whois[i], len) !=
|
|
|
|
NULL) {
|
|
|
|
s_asprintf(&nhost, "%s",
|
|
|
|
ip_whois[i]);
|
|
|
|
break;
|
|
|
|
}
|
2001-06-27 23:06:47 +00:00
|
|
|
}
|
1999-11-17 19:11:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-22 01:52:37 +00:00
|
|
|
if (nhost != NULL) {
|
2002-02-03 07:35:32 +00:00
|
|
|
whois(query, nhost, 0);
|
2001-06-22 01:52:37 +00:00
|
|
|
free(nhost);
|
1999-11-17 19:11:51 +00:00
|
|
|
}
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
1997-08-26 11:16:08 +00:00
|
|
|
static void
|
2001-06-22 01:52:37 +00:00
|
|
|
usage(void)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-06-22 01:52:37 +00:00
|
|
|
fprintf(stderr,
|
2006-01-23 13:49:39 +00:00
|
|
|
"usage: whois [-aAbdfgiIklmQrR6] [-c country-code | -h hostname] "
|
2001-08-05 19:37:12 +00:00
|
|
|
"[-p port] name ...\n");
|
1998-02-19 19:07:50 +00:00
|
|
|
exit(EX_USAGE);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|