version 1.61, 2024/03/16 06:29:36 |
version 1.62, 2024/03/24 19:51:47 |
|
|
|
|
#define NICHOST "whois.crsnic.net" |
#define NICHOST "whois.crsnic.net" |
#define INICHOST "whois.internic.net" |
#define INICHOST "whois.internic.net" |
#define CNICHOST "whois.corenic.net" |
|
#define DNICHOST "whois.nic.mil" |
#define DNICHOST "whois.nic.mil" |
#define GNICHOST "whois.nic.gov" |
#define GNICHOST "whois.nic.gov" |
#define ANICHOST "whois.arin.net" |
#define ANICHOST "whois.arin.net" |
|
|
/* |
/* |
* If no country is specified determine the top level domain from the query. |
* 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 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 |
* If the domain does not contain '.', check to see if it is an ASN (starts |
* (starts with '!') or a CORE handle (COCO-[0-9]+ or COHO-[0-9]+) or an |
* with AS) or IPv6 address (contains ':'). |
* ASN (starts with AS) or IPv6 address (contains ':'). Fall back to |
* Fall back to NICHOST for the non-handle and non-IPv6 case. |
* NICHOST for the non-handle and non-IPv6 case. |
|
*/ |
*/ |
char * |
char * |
choose_server(const char *name, const char *country, char **tofree) |
choose_server(const char *name, const char *country, char **tofree) |
|
|
if (country != NULL) |
if (country != NULL) |
qhead = country; |
qhead = country; |
else if ((qhead = strrchr(name, '.')) == NULL) { |
else if ((qhead = strrchr(name, '.')) == NULL) { |
if (*name == '!') |
if ((strncasecmp(name, "AS", 2) == 0) && |
return (INICHOST); |
|
else if ((strncasecmp(name, "COCO-", 5) == 0 || |
|
strncasecmp(name, "COHO-", 5) == 0) && |
|
strtol(name + 5, &ep, 10) > 0 && *ep == '\0') |
|
return (CNICHOST); |
|
else if ((strncasecmp(name, "AS", 2) == 0) && |
|
strtol(name + 2, &ep, 10) > 0 && *ep == '\0') |
strtol(name + 2, &ep, 10) > 0 && *ep == '\0') |
return (MNICHOST); |
return (MNICHOST); |
else if (strchr(name, ':') != NULL) /* IPv6 address */ |
else if (strchr(name, ':') != NULL) /* IPv6 address */ |