diff options
author | 2018-06-17 15:34:54 +0000 | |
---|---|---|
committer | 2018-06-17 15:34:54 +0000 | |
commit | ae6c7cf963c46177b513fa776019446ade41d0cf (patch) | |
tree | 46aa8c35bfe3d8a95834a908937e2f718a17a1fa | |
parent | use size_t (diff) | |
download | wireguard-openbsd-ae6c7cf963c46177b513fa776019446ade41d0cf.tar.xz wireguard-openbsd-ae6c7cf963c46177b513fa776019446ade41d0cf.zip |
Add heuristic for IPv6 addresses.
From Mikolaj Kucharski <mikolaj at kucharski.name>, thanks!
OK job, kn
-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))) |