From 29b1a3a9c33c93362bbb280b2517a5ae4f433db4 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Wed, 15 Oct 2014 15:07:23 +0200 Subject: [PATCH] Split nic_handles_list off tld_serv_list To be able to use in_domain() for tld_serv_list --- .gitignore | 1 + Makefile | 3 +++ data.h | 5 +++++ make_nic_handles.pl | 17 +++++++++++++++++ nic_handles_list | 22 ++++++++++++++++++++++ tld_serv_list | 35 ----------------------------------- whois.c | 6 ++++++ 7 files changed, 54 insertions(+), 35 deletions(-) create mode 100755 make_nic_handles.pl create mode 100644 nic_handles_list diff --git a/.gitignore b/.gitignore index dabbc22..f0f26c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *_del.h new_gtlds.h +nic_handles.h tld_serv.h servers_charset.h version.h diff --git a/Makefile b/Makefile index 8f1ca35..b26c0b8 100644 --- a/Makefile +++ b/Makefile @@ -87,6 +87,9 @@ ip6_del.h: ip6_del_list make_ip6_del.pl new_gtlds.h: new_gtlds_list make_new_gtlds.pl $(PERL) make_new_gtlds.pl < $< > $@ +nic_handles.h: nic_handles_list make_nic_handles.pl + $(PERL) make_nic_handles.pl < $< > $@ + tld_serv.h: tld_serv_list make_tld_serv.pl $(PERL) make_tld_serv.pl < $< > $@ diff --git a/data.h b/data.h index 797eaae..7ac4ede 100644 --- a/data.h +++ b/data.h @@ -159,6 +159,11 @@ const char *tld_serv[] = { NULL, NULL }; +const char *nic_handles_post[] = { +#include "nic_handles.h" + NULL, NULL +}; + #ifdef HAVE_ICONV struct server_charset { const char *name; diff --git a/make_nic_handles.pl b/make_nic_handles.pl new file mode 100755 index 0000000..6b031c2 --- /dev/null +++ b/make_nic_handles.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +while (<>) { + chomp; + s/#.*$//; + s/^\s+//; s/\s+$//; + next if /^$/; + + die "format error: $_" if not + (my ($a, $b) = /^(-\w+)\s+([\w\d\.:-]+)$/); + + print qq| "$a",\t"$b",\n|; +} + diff --git a/nic_handles_list b/nic_handles_list new file mode 100644 index 0000000..44e019b --- /dev/null +++ b/nic_handles_list @@ -0,0 +1,22 @@ +-arin whois.arin.net +-ripe whois.ripe.net +-mnt whois.ripe.net +-lacnic whois.lacnic.net +-afrinic whois.afrinic.net +-ap whois.apnic.net +-cznic whois.nic.cz +-dk whois.dk-hostmaster.dk +-il whois.isoc.org.il +-is whois.isnic.is +-kg whois.domain.kg +-coop whois.nic.coop +-frnic whois.nic.fr +-lrms whois.afilias.info +-metu whois.nic.tr +-nicat whois.nic.at +-nicci whois.nic.ci +-irnic whois.nic.ir +-norid whois.norid.no +-tel whois.nic.tel +-adnic whois.nic.org.uy +-sixxs whois.sixxs.net diff --git a/tld_serv_list b/tld_serv_list index 51fa1c6..8f6a50f 100644 --- a/tld_serv_list +++ b/tld_serv_list @@ -385,38 +385,3 @@ .xn--xkc2dl3a5ee0h whois.inregistry.net # India, Tamil AW .xn--yfro4i67o whois.sgnic.sg # Singapore, Chinese .xn--ygbi2ammx whois.pnina.ps # Palestinian Territory - --dom whois.networksolutions.com --org whois.networksolutions.com --hst whois.networksolutions.com --arin whois.arin.net --ripe whois.ripe.net --mnt whois.ripe.net --lacnic whois.lacnic.net --afrinic whois.afrinic.net --ap whois.apnic.net --cn whois.cnnic.cn --cz whois.nic.cz --dk whois.dk-hostmaster.dk --il whois.isoc.org.il --is whois.isnic.is --kg whois.domain.kg --ti whois.telstra.net --tw whois.twnic.net.tw --coop whois.nic.coop --frnic whois.nic.fr --gandi whois.gandi.net --kenic whois.kenic.or.ke --lrms whois.afilias.info --metu whois.nic.tr --nicat whois.nic.at --nicci whois.nic.ci --nicir whois.nic.ir --norid whois.norid.no --rotld whois.rotld.ro --sgnic whois.sgnic.sg --tel whois.nic.tel --uanic whois.ua --cunic whois.cunic.ua --uynic whois.nic.org.uy --sixxs whois.sixxs.net diff --git a/whois.c b/whois.c index 8b2183f..3345535 100644 --- a/whois.c +++ b/whois.c @@ -541,6 +541,12 @@ char *guess_server(const char *s) for (i = 0; nic_handles[i]; i += 2) if (strncaseeq(s, nic_handles[i], strlen(nic_handles[i]))) return strdup(nic_handles[i + 1]); + + /* search for strings at the end of the word */ + for (i = 0; nic_handles_post[i]; i += 2) + if (domcmp(s, nic_handles_post[i])) + return strdup(nic_handles_post[i + 1]); + /* it's probably a network name */ return strdup(""); }