From 8ccab2cb13c178bd487acd9566d9e38ee0ffbb30 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Wed, 15 Oct 2014 20:38:10 +0200 Subject: [PATCH] Ask whois.iana.org about TLDs Recognize as a TLD any string without dots present in tld_serv_list and new_gtlds_list. --- whois.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/whois.c b/whois.c index 7cb54bc..125db8e 100644 --- a/whois.c +++ b/whois.c @@ -496,6 +496,15 @@ char *guess_server(const char *s) /* no dot and no hyphen means it's a NSI NIC handle or ASN (?) */ if (!strpbrk(s, ".-")) { + /* if it is a TLD or a new gTLD then ask IANA */ + for (i = 0; tld_serv[i]; i += 2) + if (strcaseeq(s, tld_serv[i])) + return strdup("whois.iana.org"); + + for (i = 0; new_gtlds[i]; i++) + if (strcaseeq(s, new_gtlds[i])) + return strdup("whois.iana.org"); + if (strncaseeq(s, "as", 2) && /* it's an AS */ (isasciidigit(s[2]) || s[2] == ' ')) return strdup(whereas(atol(s + 2)));