diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2018-06-17 15:34:55 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2018-06-17 15:34:55 +0000 |
commit | c4827dbec6fb7dc217a25b3ee350d066bef9e0c6 (patch) | |
tree | 3a40d8479690895b8125b61ccd157a5f70c7c92d /usr.bin/whois/whois.c | |
parent | 3cae3ec11d739ccd352f7c35f492264a68354d60 (diff) |
Add heuristic for IPv6 addresses.
From Mikolaj Kucharski <mikolaj at kucharski.name>, thanks!
OK job, kn
Diffstat (limited to 'usr.bin/whois/whois.c')
-rw-r--r-- | usr.bin/whois/whois.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c index 177dc5228fa..fe1fa224a66 100644 --- a/usr.bin/whois/whois.c +++ b/usr.bin/whois/whois.c @@ -1,4 +1,4 @@ -/* $OpenBSD: whois.c,v 1.56 2017/07/26 15:48:38 sthen Exp $ */ +/* $OpenBSD: whois.c,v 1.57 2018/06/17 15:34:54 florian Exp $ */ /* * Copyright (c) 1980, 1993 @@ -278,7 +278,8 @@ whois(const char *query, const char *server, const char *port, int flags) * 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]+) or an - * ASN (starts with AS). Fall back to NICHOST for the non-handle case. + * ASN (starts with AS) or IPv6 address (contains ':'). Fall back to + * NICHOST for the non-handle and non-IPv6 case. */ char * choose_server(const char *name, const char *country, char **tofree) @@ -305,6 +306,8 @@ choose_server(const char *name, const char *country, char **tofree) else if ((strncasecmp(name, "AS", 2) == 0) && strtol(name + 2, &ep, 10) > 0 && *ep == '\0') return (MNICHOST); + else if (strchr(name, ':') != NULL) /* IPv6 address */ + return (ANICHOST); else return (NICHOST); } else if (isdigit((unsigned char)*(++qhead))) |