Commit Graph

75 Commits

Author SHA1 Message Date
markj
59f784f7ea whois: Handle referrals to rwhois servers.
PR:		243862
Submitted by:	ben@desync.com
Differential Revision:	https://reviews.freebsd.org/D25156
2020-07-09 17:27:14 +00:00
pfg
872b698bd4 General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
imp
7e6cabd06e Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
fanf
aec30d9b8d More robust handling of whois referrals from RIRs.
An example problem case is 163.1.0.0 (University of Oxford)
which is in an APNIC ERX address range. Previously we assumed
that ARIN has the correct information for all ERX allocations,
but in this case ARIN refers back to APNIC, rather than referring
to RIPE. This caused whois to loop.

Whois will no longer loop back and forth forever between two RIRs
that don't have an answer, but instead try the other RIRs in turn.
2016-11-17 15:19:06 +00:00
fanf
10f1209022 Send whois queries for gov.uk names to JANET. 2016-05-25 13:09:06 +00:00
cem
8093b741c7 whois(1): Fix potential double-close and logic mistakes
Close the fd the poll error was detected on, rather than the last opened fd, to
fix the double-close.

Use -1 to make it explict which int variables no longer own socket file
descriptors.

Actually shrink, rather than grow, the poll timeout to match comment.

Reported by:	Coverity
CID:		1304860, 1305616
Sponsored by:	EMC / Isilon Storage Division
2016-05-11 18:03:51 +00:00
cem
56be1d347c whois(1): Pull out async multiple host connection code into a routine
This logic was added to the whois() function in r281959, but could easily be
its own routine.  In this case, I think the abstraction makes both functions
easier to reason about.

This precedes some Coverity-suggested cleanup.

Sponsored by:	EMC / Isilon Storage Division
2016-05-11 17:52:06 +00:00
fanf
3389187e4b 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.
2016-04-08 11:43:22 +00:00
fanf
b951056e8c Fix whois queries for ARIN AS numbers.
The ARIN whois server likes AS number queries to be in the form
"a 8075" rather than "as7085".
2016-03-31 12:13:01 +00:00
fanf
7e5d57d7f1 Fix a regression in the .de and .dk whois special cases
Ensure the special cases trigger whether we come via a referral
or via the -c option. Match host names case-insensitively.

Use the default character set supported by .de (UTF-8) since that
is more compatible with the modern world than ISO 8859-1. Persuade
them to give us a useful answer whether an internationalized
domain name is given in UTF-8 or in punycode.
2016-01-23 01:20:58 +00:00
fanf
d92f8a19a9 A lot of the cleverness in whois is no longer needed!
The IANA whois server has the right referral information for domain
names, IP addresses, and AS numbers, so whois does not need to be
able to choose servers itself (except for a few cases where referrals
do not work). We can delete a chunk of code, which is always fun.

This change improves the referral handling to be less sensitive to
all the various formats, and to allow multi-hop referral chains,
such as IANA -> registry -> registrar.

ARIN queries have the "+" flag added if no flags are present, so we
get full details if the query matches multiple objects. The Verisign
anti-spam logic is also now suppressed if the user provided a non-
trivial query string.

Uninformative rubric is now trimmed by default. The -S option
turns off trimming, and disables query fettling.

The -i option is back to its traditional pre-1999 hostname, since
whois.internic.net is more useful than whois.networksolutions.com.
Note that the old fallback/default server whois.crsnic.net is an
alias for whois.internic.net.

The manual is more informative about query syntax.
2016-01-23 00:28:18 +00:00
fanf
e270f2d00e Update whois synopsis and usage with new options 2016-01-22 19:06:43 +00:00
fanf
8ba35e7674 A few whois usability improvements
Look up AS numbers at ARIN.

Handle more referral formats.

Suppress spammy nameserver objects when querying the .com and .net
whois servers by explicitly querying for domain names by default.
2016-01-22 16:43:49 +00:00
delphij
790cec3cb6 Although the website [1] says US-ASCII is accepted, ISO-8859-1 seems to
be the only accepted character that is close enough to US-ASCII (and
this is also done on OpenBSD; the alternative would be to use UTF-8).

[1] http://www.denic.de/en/domains/technik/denic_whois-server/index.html

MFC after:	2 weeks
2015-08-23 08:22:00 +00:00
fanf
2f34b1414e whois: add an option to query the PeeringDB 2015-05-14 11:37:36 +00:00
fanf
961e7533e1 whois: alphabetize whois server list 2015-05-14 10:33:51 +00:00
fanf
18c4720eef whois: do not clobber command-line flags when tweaking O_NONBLOCK
This can make whois fail to follow referrals when it should.
The bug was introduced in r281959.
2015-05-14 10:33:33 +00:00
fanf
8fd803db87 whois: try whois.nic.TLD if TLD.whois-servers.net does not exist
Based on an idea from OpenBSD.
2015-05-14 10:33:01 +00:00
fanf
da775e97f7 whois: check WHOIS_SERVER as well as RA_SERVER environment variables
WHOIS_SERVER is used by Debian's whois client.
2015-05-14 10:32:35 +00:00
fanf
426168849a whois: code cleanup
Remove deprecated options.

Use pedantically correct types.
2015-05-14 10:32:05 +00:00
fanf
1e9ac2722e whois: special case certain query suffixes
This extends the existing support for -NORID handles
to include -NICAT, -ARIN, and -RIPE handles.

The suffix machinery is also used to work around a problem with
lack of referrals from the Nominet server for .uk: names under
.ac.uk need to be queried directly at JANET's whois server.
2015-05-14 10:31:37 +00:00
delphij
f07d7ffd84 Try alternate addresses more agressively.
Attempt to connect to alternate addresses if the connect doesn't
succeed in 180ms, and cut wait time between connection attempts
in half for each additional, if no connection was established.

Take the first connection to succeed and close the others.

This makes whois more responsive when e.g. IPv6 service took long
time or fail to respond.

PR:		158125
Submitted by:	Mark Andrews <marka isc org> (with changes from me)
MFC after:	2 weeks
2015-04-25 00:51:44 +00:00
ume
0c85b38216 Introduce $RA_SERVER to set default whois server.
Requested by:	nork
Reviewed by:	nork
MFC after:	1 week
2014-06-25 15:39:08 +00:00
kevlo
27b04cbc6f The whois() function is called in a loop so make sure we close the
socket to the whois server before returning.

Obtained from:	OpenBSD
2014-01-04 15:51:52 +00:00
ed
dc00e03576 Mark global functions and/or variables in whois(1) static where possible.
This allows compilers and static analyzers to more thorough analysis.
2011-11-06 18:50:33 +00:00
joel
29af67e52c Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with:	imp, rwatson
2010-12-11 08:32:16 +00:00
edwin
ee2386e553 Make whois capable of searching for IPv6 addresses just like it can
do for IPv4 addresses without having to explicetly specify that the
ARIN server should be used to get the initial information

PR:		bin/128725
Submitted by:	"Matt D. Harris" <mdh_lists@yahoo.com>
MFC after:	1 week
2010-01-14 10:56:54 +00:00
edwin
ea698e4843 Remove -d option, whois.nic.mil doesn't exist anymore.
PR:		bin/142507
Submitted by:	Dan Mahoney <danm@prime.gushi.org>
MFC after:	1 week
2010-01-14 10:40:54 +00:00
dougb
e0ede152d0 The 6bone was decommissioned on 6/6/06, so remove references to it. 2009-10-03 02:37:21 +00:00
ache
1104f500b1 Use proper type cast for ctype macro 2007-04-14 14:32:48 +00:00
phk
53becc06fe Make DK-HOSTMASTER show contact info for .dk domains.
Submitted by:	Søren Hansen <shan@soeren-hansen.dk>
2007-01-19 08:13:17 +00:00
jhay
8873885f5e Add AfriNIC as a RIR.
PR:		80421
Submitted by:	Adrian Frith <adrian at frith.homelinux.org>
MFC after:	6 days
2006-01-23 13:49:39 +00:00
charnier
45f96a1a02 Reduce compiler warning: variable might be used uninitialized, by giving
an initial value.
2005-05-29 15:49:53 +00:00
ceri
d0eb6b1f7e Add a -k flag for querying whois.krnic.net (the National Internet
Development Agency of Korea) which hold details of IP address
allocations within Korea.

Approved by:	bms
2004-12-11 13:14:07 +00:00
mbr
17cdeacd68 Add special case for the german whois nameserver. Without the
'-T dn,ace -C US-ASCII' option one does only get:

$ whois nic.de

domain:    nic.de
status:    connect

More information available on:

http://www.denic.de/en/domains/technik/denic_whois-server/index.html

MFC:	3 days
2004-08-25 15:34:44 +00:00
bms
a425dc3a68 Add -b to usage.
Pointed out by:	ceri
Pointy hat to:	bms
2004-06-14 19:29:37 +00:00
bms
1598e7b423 Add whois.abuse.net to whois(1).
Submitted by:	ceri (with cleanups)
2004-06-14 17:30:46 +00:00
bms
d01943f8ff Add whois.iana.org to the whois(1) utility, under the -I option.
PR:		bin/48914
Submitted by:	James Raftery
2004-06-14 14:03:10 +00:00
ache
2973509c1f Back out .SU workaround - people at whois-servers.net set up
su.whois-servers.net
2003-06-29 23:56:31 +00:00
ache
d847b7379e While there is no su.whois-servers.net, use fallback to
ru.whois-servers.net for su domain or country
2003-06-24 15:08:24 +00:00
eivind
0eaa0a5cbf Add support for identifying NORID (norwegian top level registry) handles.
Reviewed by:	mike (with slight changes based on feedback afterwards)
2003-03-25 17:00:03 +00:00
mike
16b05986d0 Fix style bugs in previous commit. 2003-02-24 17:10:32 +00:00
roberto
63438f7ba7 The newly appointed .org registrar has a pecular output format so
whois doesn't follow the link to the authoritative registrar. Fix it.

PR:             bin/47770
Submitted by:   Alain Thivillon <at@rominet.net>
MFC after:	    7 days
2003-01-31 21:57:10 +00:00
mike
4ae3d74b87 Add support for the Latin American and Caribbean IP address Regional
Registry (LACNIC) with the -l option and support for recursive IP
address searches.

PR:		44448
Submitted by:	David Wolfskill <david@catwhisker.org>
MFC after:	1 week
2002-11-10 16:58:56 +00:00
mike
705073e549 ARIN has annoyingly started using caps when referencing
whois.apnic.net.  To properly receive hints for recursive IP searches,
we convert a buffer to lowercase before searching for magic words.

PR:		42834
Submitted by:	Andre Albsmeier <andre.albsmeier@mchp.siemens.de> (mostly)
X-MFC-After:	re approval
2002-09-18 07:51:46 +00:00
mike
4232c22913 Leave the `copyright' variable exposed, since the main purpose of it
is to put a copyright in the object file.

Submitted by:	bde
2002-03-07 10:06:00 +00:00
kris
b2cbfe0830 Mark a function as __printflike()
MFC after:	1 week
2002-02-04 02:12:49 +00:00
mike
c41b30278b Use new ID scheme.
Fix a bug that caused .br domains to be queried twice, by only
recursively following ARIN referrals when querying ARIN.

PR:		34291
MFC after:	7 days
2002-02-03 07:35:32 +00:00
mike
d43f783040 Add support for Brazilian IP Addresses. Example `whois 200.236.70.0'.
PR:	30676
2001-12-08 21:22:42 +00:00
mike
3997cf6e35 Remove some EOL whitespace. Update usage() to current reality. 2001-10-17 16:28:12 +00:00