Ruby Whois 3.0

Whois is an intelligent — pure Ruby — WHOIS client and parser. It provides a flexible and programmable API to query WHOIS servers and look up IP, TLD, and domain WHOIS information. This library was developed to power RoboWhois, RoboDomain and, more recently, DNSimple.

Let's keep this announcement short and simple: Whois 3.0 has been released today!

Developers tend to assign fancy names to major releases, so I will. For the purpose of this article, I'll call this release Whois 3.


Whois 3 is the result of about 6 month of work. It contains several improvements in addition to an incredible amount of tweaks and updates. If you don't believe me, you can have a look at the CHANGELOG and you'll immediately realize that the Release 3.0 counts more than 50 entries.

The most notable change that will probably affect a few users is the minimum Ruby requirement. Whois 3 no longer supports Ruby 1.8.7 and the minumum Ruby version is now Ruby 1.9.2. With Ruby 2.0 released, it's time to move forward.

Query Handler

One of the most important features is the introduction of the query handler.

# => Whois::Server::SocketHandler

The query handler is responsible for the low-level connection between the library and the external WHOIS source. The default query handler, as the class name suggests, is a socket-based handler. It opens a connection to the specified server, writes a query and reads a response that in most cases is the final WHOIS record.

So far so good. But what if you want to use a proxy? Or if you want to be able to use an async socket connection? Before Whois 3 the only way was to monkey patch the library. Today, you simply need to write your own handler and configure the library to use it.

class MyHandler
  def call(query, *args)
  # ...

Whois::Server::Adapters::Base.query_handler = MyHandler

# This request will use your custom handler
Whois.whois "..."

Another good case is a Test handler to be used in a test environment. A Test handler would be a simple and effective replacement for all the stubs and mocks across our application spec suite. Also, it will ensure no real socket connection is performed outside our application when our test suite is running.

Non-Deep querying

The support for Non-Deep queries is another long awaited feature. You can now skip deep queries for thin providers passing the :referral => false option.

c = false)
c.lookup ""

The option also works in the command line.

$ ruby-whois --no-referral


Whois 3 was made possible by the contributions of several contributors and reporters. I would also thank you DNSimple for sponsoring the development of the library.