From owner-svn-src-all@freebsd.org Fri Apr 8 11:43:24 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0A5B0B087CB; Fri, 8 Apr 2016 11:43:24 +0000 (UTC) (envelope-from fanf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B5B7619ED; Fri, 8 Apr 2016 11:43:23 +0000 (UTC) (envelope-from fanf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u38BhMoh094084; Fri, 8 Apr 2016 11:43:22 GMT (envelope-from fanf@FreeBSD.org) Received: (from fanf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u38BhMah094083; Fri, 8 Apr 2016 11:43:22 GMT (envelope-from fanf@FreeBSD.org) Message-Id: <201604081143.u38BhMah094083@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fanf set sender to fanf@FreeBSD.org using -f From: Tony Finch Date: Fri, 8 Apr 2016 11:43:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r297708 - head/usr.bin/whois X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2016 11:43:24 -0000 Author: fanf Date: Fri Apr 8 11:43:22 2016 New Revision: 297708 URL: https://svnweb.freebsd.org/changeset/base/297708 Log: Handle whois referrals between RIRs This is rather ugly, because the RIPE and APNIC whois servers do not provide referrals for address blocks that they do not manage. However ARIN is usually the right place or knows the right place so we try there. The particular instance which clued me in to this bug is U.Mich. 141.211.0.0/16 for which the referral chain should be IANA -> RIPE -> ARIN. RIPE's RDAP does provide useful redirects (for example try `curl -I http://rdap.db.ripe.net/ip/141.211.0.0) so maybe their whois server can be improved. AfriNIC's whois server gives more direct referrals, but they are designed to be human-readable. Ugly, but we can manage. The issue of referrals between RIRs is likely to become more important in the future whith the increasing number of cross-region IP address block transfers increases. Modified: head/usr.bin/whois/whois.c Modified: head/usr.bin/whois/whois.c ============================================================================== --- head/usr.bin/whois/whois.c Fri Apr 8 11:20:56 2016 (r297707) +++ head/usr.bin/whois/whois.c Fri Apr 8 11:43:22 2016 (r297708) @@ -114,9 +114,16 @@ static struct { WHOIS_REFERRAL("Whois Server:"), WHOIS_REFERRAL("Registrar WHOIS Server:"), /* corporatedomains.com */ WHOIS_REFERRAL("ReferralServer: whois://"), /* ARIN */ + WHOIS_REFERRAL("descr: region. Please query"), /* AfriNIC */ { NULL, 0 } }; +static const char *actually_arin[] = { + "netname: ERX-NETBLOCK\n", /* APNIC */ + "netname: NON-RIPE-NCC-MANAGED-ADDRESS-BLOCK\n", + NULL +}; + static const char *port = DEFAULT_PORT; static const char *choose_server(char *); @@ -469,6 +476,12 @@ done: (int)(p - host), host); break; } + for (i = 0; actually_arin[i] != NULL; i++) { + if (strncmp(buf, actually_arin[i], len) == 0) { + s_asprintf(&nhost, "%s", ANICHOST); + break; + } + } } /* Verisign etc. */ if (!(flags & WHOIS_SPAM_ME) &&