diff options
author | 2002-12-19 21:34:28 +0000 | |
---|---|---|
committer | 2002-12-19 21:34:28 +0000 | |
commit | 8fe319cb282feaeab32be0da6fb8084ce19febb9 (patch) | |
tree | e49969899068119174feb915eb23634a7cedf076 | |
parent | add dsiz and ssiz to accompany tsiz; millert@ ok (diff) | |
download | wireguard-openbsd-8fe319cb282feaeab32be0da6fb8084ce19febb9.tar.xz wireguard-openbsd-8fe319cb282feaeab32be0da6fb8084ce19febb9.zip |
Recognize CORENIC handles and use CNICHOST like we do VNICHOST ones.
By request and based on a diff from Henning Brauer
-rw-r--r-- | usr.bin/whois/whois.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c index 0ee4d6f7e18..99b81f92808 100644 --- a/usr.bin/whois/whois.c +++ b/usr.bin/whois/whois.c @@ -1,4 +1,4 @@ -/* $OpenBSD: whois.c,v 1.18 2002/12/19 20:37:24 millert Exp $ */ +/* $OpenBSD: whois.c,v 1.19 2002/12/19 21:34:28 millert Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)whois.c 8.1 (Berkeley) 6/6/93"; #else -static const char rcsid[] = "$OpenBSD: whois.c,v 1.18 2002/12/19 20:37:24 millert Exp $"; +static const char rcsid[] = "$OpenBSD: whois.c,v 1.19 2002/12/19 21:34:28 millert Exp $"; #endif #endif /* not lint */ @@ -63,6 +63,7 @@ static const char rcsid[] = "$OpenBSD: whois.c,v 1.18 2002/12/19 20:37:24 miller #define NICHOST "whois.crsnic.net" #define INICHOST "whois.internic.net" +#define CNICHOST "whois.corenic.net" #define DNICHOST "whois.nic.mil" #define GNICHOST "whois.nic.gov" #define ANICHOST "whois.arin.net" @@ -259,22 +260,31 @@ whois(const char *name, const char *server, int flags) /* * If no country is specified determine the top level domain from the query. - * If the TLD is a number, query ARIN. Otherwise, use TLD.whois-server.net. - * If the domain does not contain '.', fall back to NICHOST (or VNICHOST - * if name is a handle that starts with a '!'). + * If the TLD is a number, query ARIN, otherwise, use TLD.whois-server.net. + * If the domain does not contain '.', check to see if it is an NSI handle + * (starts with '!') or a CORE handle (COCO-[0-9]+ or COHO-[0-9]+). + * Fall back to NICHOST for the non-handle case. */ static char * choose_server(const char *name, const char *country) { static char *server; const char *qhead; + char *ep; size_t len; if (country != NULL) qhead = country; - else if ((qhead = strrchr(name, '.')) == NULL) - return (*name == '!' ? VNICHOST : NICHOST); - else if (isdigit(*(++qhead))) + else if ((qhead = strrchr(name, '.')) == NULL) { + if (*name == '!') + return (VNICHOST); + else if ((strncasecmp(name, "COCO-", 5) == 0 || + strncasecmp(name, "COHO-", 5) == 0) && + strtol(name + 5, &ep, 10) > 0 && *ep == '\0') + return (CNICHOST); + else + return (NICHOST); + } else if (isdigit(*(++qhead))) return (ANICHOST); len = strlen(qhead) + sizeof(QNICHOST_TAIL); if ((server = realloc(server, len)) == NULL) |