New in Whois: #nameservers are now Nameserver

It's time for another update on Ruby Whois library. Let's talk about name servers.

The most part of WHOIS servers follow the "convention" to include the name server list of a domain in the WHOIS record.

A name server is represented by a DNS name, which is a string.

The DNS name resolves to an IPv4 IP address. => =>

Optionally, the DNS name can resolve to an IPv6 IP address.git => 2001:660:3003:2::4:1 => 2001:660:3005:1::1:2

Each WHOIS server arbitrary choses the amount of information to store and return in a WHOIS record. Some registries returns only the DNS name, other registries include IP addresses as well.

In the current WHOIS version, the list of name servers is accessible through the #nameservers property.

r = Whois.query ""
# => ["", ""]

The method returns an Array of String. This is a lossy implementation because it completely ignores the IPv4 and IPv6 details.

The new Whois version solves this problem by introducing a new Whois::Answer::Nameserver object. This object is a Struct composed by three attributes: name, ipv4 and ipv6.

ns =
    :name => "",
    :ipv4 => "",
    :ipv6 => "2001:660:3003:2::4:1"
# => ""
# => ""
# => "2001:660:3003:2::4:1"

In the new Whois version, the #nameservers implementation has been changed to return an array of Nameserver instead of a simple String.

r = Whois.query ""
# => [
#     #<struct Whois::Answer::Nameserver name="", ipv4="", ipv6="2001:660:3003:2::4:1">,
#     #<struct Whois::Answer::Nameserver name="", ipv4="", ipv6="2001:660:3005:1::1:2">,
#     ...
#    ]

It's important to know that this change can break backwards compatibility. In order to minimize the impact, Nameserver#to_s returns the String value of the name attribute. => "", :ipv4 => "").to_s
# => ""