Giter VIP home page Giter VIP logo

whois's Introduction

Whois is an intelligent — pure Ruby — WHOIS client and parser.

This library was extracted from RoboWhois and RoboDomain, and it's now in use at DNSimple. It has been performing queries in production since July 2009.

Build Status

Donate a coffee

Whois is free software, but it requires a lot of coffee to write, test, and distribute it. You can support the development by donating a coffee.

Any amount is greatly appreciated.

Features

  • Ability to lookup WHOIS record for IPv4, IPv6, TLDs, and ICANN new gTLDs
  • Ability to parse WHOIS responses (via the whois-parser library)
  • Flexible and extensible interface (e.g. You can define custom servers on the fly)
  • Object oriented design, featuring 10 different design patterns
  • Pure Ruby library, without any external dependency other than Ruby itself
  • Successfully tested against different Ruby implementations, including Ruby and JRuby

Whois and Whois parser

Starting from version 4, WHOIS parser component is available in a separate repository called whois-parser, and released as a separate gem called whois-parser.

This repository contains the core whois library, that includes the WHOIS client, the server definitions and all the features required to perform WHOIS queries and obtain the WHOIS record.

Requirements

  • Ruby >= 3.0

For older versions of Ruby, see the CHANGELOG.

Installation

You can install the gem manually:

gem install whois

Or use Bundler and define it as a dependency in your Gemfile:

gem 'whois'

To use the WHOIS parser component you need to install the whois-parser gem:

gem install whois-parser
gem 'whois-parser'

The whois-parser gem already depends on the whois gem. If you install whois-parser, whois will be installed as well and it will also be automatically required when you require 'whois-parser'.

If you are upgrading to 4.0, see 4.0-Upgrade.md.

Getting Started

This section covers only the essentials for getting started with the Whois library. The documentation provides a more accurate explanation including tutorials, more examples and technical details about the client/server/record/parser architecture.

Querying a WHOIS

Whois provides the ability to get WHOIS information for TLD, domain names, IPv4 and IPv6 addresses. The client is smart enough to guess the best WHOIS server according to given query, send the request and return the response.

Check out the following examples:

# Domain WHOIS
whois = Whois::Client.new
whois.lookup("google.com")
# => #<Whois::Record>

# TLD WHOIS
whois = Whois::Client.new
whois.lookup(".com")
# => #<Whois::Record>

# IPv4 WHOIS
whois = Whois::Client.new
whois.lookup("74.125.67.100")
# => #<Whois::Record>

# IPv6 WHOIS
whois = Whois::Client.new
whois.lookup("2001:db8::1428:57ab")
# => #<Whois::Record>

The query method is stateless. For this reason, you can safely re-use the same client instance for multiple queries.

whois = Whois::Client.new
whois.lookup("google.com")
whois.lookup(".com")
whois.lookup("74.125.67.100")
whois.lookup("2001:db8::1428:57ab")
whois.lookup("google.it")

If you just need a WHOIS response and you don't care about a full control of the WHOIS client, the Whois module provides an all-in-one method called Whois.whois. This is the simplest way to send a WHOIS request.

Whois.whois("google.com")
# => #<Whois::Record>

Did I mention you can even use blocks?

Whois::Client.new do |w|
  w.lookup("google.com")
  w.lookup(".com")
  w.lookup("74.125.67.100")
  w.lookup("2001:db8::1428:57ab")
  w.lookup("google.it")
end

Consuming the Record

Any WHOIS query returns a Whois::Record. This object looks like a String, but it's way more powerful.

Whois::Record encapsulates a WHOIS record and provides the ability to parse the WHOIS response programmatically, when the whois-parser gem is installed and loaded.

require 'whois-parser'

record = Whois.whois("google.it")
# => #<Whois::Record>

parser = record.parser
# => #<Whois::Parser>

parser.available?
# => false
parser.registered?
# => true

parser.created_on
# => Fri Dec 10 00:00:00 +0100 1999

tech = parser.technical_contacts.first
# => #<Whois::Record::Contact>
tech.id
# => "TS7016-ITNIC"
tech.name
# => "Technical Services"

parser.nameservers.each do |nameserver|
  puts nameserver
end

This feature is made possible by the Whois record parsers. Unfortunately, due to the lack of a global standard, each WHOIS server requires a specific parser. For this reason, the library doesn't support all existing WHOIS servers.

If you create a new parser, please consider releasing it to the public so that it can be included in a next version.

Timeout

By default, each query run though the client has a timeout value of 5 seconds. If the execution exceeds the timeout limit, the client raises a Timeout::Error exception.

Of course, you can customize the timeout value setting a different value. If timeout is nil, the client will wait until the response is sent back from the server or the process is killed. Don't disable the timeout unless you really know what you are doing!

whois = Whois::Client.new(:timeout => 10)
whois.timeout # => 10
whois.timeout = 5
whois.timeout # => 5

whois.lookup("google.com")

Credits

Whois was created and is maintained by Simone Carletti. Many improvements and bugfixes were contributed by the open source community.

Contributing

Direct questions and discussions to Stack Overflow.

Pull requests are very welcome! Please include spec and/or feature coverage for every patch, and create a topic branch for every separate change you make.

Report issues or feature requests to GitHub Issues.

More Information

Versioning

Whois uses Semantic Versioning 2.0.0

License

Copyright (c) 2009-2022 Simone Carletti. This is Free Software distributed under the MIT license.

whois's People

Contributors

aadlani avatar alexaitken avatar axic avatar case avatar casperisfine avatar cu39 avatar delwyn avatar dependabot-preview[bot] avatar dependabot[bot] avatar dergutemoritz avatar donthorp avatar ezkl avatar geoffgarside avatar gromnsk avatar huyphan avatar justincampbell avatar kliuchnikau avatar ledowong avatar linrock avatar mat813 avatar rorymckinley avatar semaperepelitsa avatar sheldonh avatar sherwind avatar takama avatar tanelj avatar turadg avatar uko avatar veszig avatar weppos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

whois's Issues

Handle response format changes noisily

I just noticed that the DENIC changed its response format by wondering why a certain domain got returned as unavailable (nil). Thanks for the quick update of the respective parser, Simone! However, to handle situations like this, it might make more sense to fail more noisily than just returning nil. Maybe by raising exceptions? What do you think?

Support for informative queries

$ whois -h whois.internic.net help

Whois Server Version 2.0

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
<WHOIS help>
Select a sub-topic for help; '?' (with no RETURN) for a list of options;
RETURN key to return to WHOIS.


<OVERVIEW>
WHOIS is used to look up records in the registry database.  Whois can provide
information about domains, nameservers, and registrars.

...

#valid? / #invalid? parser methods

Migrated from http://code.simonecarletti.com/issues/430

Some domain names applies some specific rules to domain names.
It means, the domain can be formally valid but effectively not compliant to authority requirements.

u34jedzcq.uk

Error for "u34jedzcq.uk".

This domain cannot be registered because it contravenes the Nominet UK
naming rules.  The reason is:
  the domain name contains too few parts.

WHOIS lookup made at 20:30:27 08-Jan-2010

It would be nice to be able to detect whether the domain is valid or not.

NoMethodError for js.hu

$ a = Whois.query "js.hu"
$ a.registrant

NoMethodError: private method `split' called for nil:NilClass
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p248/gems/whois-1.0.2/lib/whois/answer/parser/whois.nic.hu.rb:85:in `registrant'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p248/gems/whois-1.0.2/lib/whois/answer/parser.rb:82:in `send'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p248/gems/whois-1.0.2/lib/whois/answer/parser.rb:82:in `delegate_to_parsers'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p248/gems/whois-1.0.2/lib/whois/answer/parser.rb:68:in `method_missing'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p248/gems/whois-1.0.2/lib/whois/answer.rb:145:in `registrant'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p248/gems/whois-1.0.2/lib/whois/answer.rb:143:in `send'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p248/gems/whois-1.0.2/lib/whois/answer.rb:143:in `method_missing'
    from (irb):5

Quarantine status

Some registries imposes a N-days quarantine status to protect registrants from invalid cancellations.

Quarantine is a system under which, for forty days, a cancelled .nl domain name is not available for re-registration by anyone except the original registrant. This is the period recommended by RIPE as sufficient to ensure that the domain is no longer listed anywhere in the DNS network. The purpose of quarantine is to protect registrants against disproportionate consequences in the event of mistaken cancellation. Quarantine is a sort of after-care, which is of benefit mainly to the registrant, but also to the registrar.
https://www.sidn.nl/en/faq/nl-domain-names/

The same applies for .EU domains.

A .eu domain name spends 40 days in quarantine once it has been deleted. This means that while the domain name is not available to the general public to register, it is also no longer in the possession of its former owner. The new “quarantined” status of the name is reflected in the WHOIS database and the date of its release is also published so that other parties having an interest in the name know when they can attempt to register it again.
http://faq.domainmonster.com/domains/eu/quarantine/

More information:

.nl domains and quarantine status

http://groups.google.com/group/ruby-whois/browse_thread/thread/e9e30acd6b71c998

Hello,
I noticed that Ruby-Whois detected lots of .NL-domains as "available"
that actually are not. Example:

whoistest.rb:

require "rubygems" 
require "whois" 
whoisClient = Whois::Client.new(:timeout => 60) 
whois = whoisClient.query("martijn-webdesign.nl") 
puts whois 
puts whois.registered? ? "registered" : "not registered" 
puts whois.available? ? "available" : "not available" 

Result:

Domain name: martijn-webdesign.nl 
Status:      in quarantine 
Last registrar: 
   Fastware B.V. 
   Auvergnestraat 4 
   4611LN BERGEN OP ZOOM 
   Netherlands 
Date out of quarantine: 2010-10-02 
Record maintained: NL Domain Registry 
Copyright notice 
[...] 
not registered 
available 

Maybe it´s a bug of the .NL-Parser?

Additional domain statuses

Migrated from http://code.simonecarletti.com/issues/321

Right now the library supports available and registered statuses.
However, a domain can be reserved but not registered.

Consider to support the following statuses:

  • available - domain not registered and available for registration
  • registered - domain registered and not available for registration
  • reserved - domain not registered but reserved and not available for registration (786a8ec)
  • inactive - domain registered and no active nameservers ref.
  • quarantine | redemption | expired (e2d15a8, 59a0d1c, 891675e) - #33
  • suspended -

ARIN => RIPE ReferralServer is not detected

From http://groups.google.com/group/ruby-whois/browse_thread/thread/3b5332335801c906

The point is when querying an ip as I described, the whois.arin.net
server responds first and send you to RIPE using this field:
"ReferralServer: whois://whois.ripe.net:43". Debian whois cli
understands this and go on with the next whois server. But when i use
the ruby whois my parser "whois.ripe.net.rb" is not called at all.

I found this issue with this ip: 130.66.76.222

whois.denic.de parser returns nameservers in a bad format

a = Whois.query "google.de"
a.nameservers
# => ["ns1.google.com", "ns2.google.com", "ns3.google.com", "ns4.google.com"]

a = Whois.query "prodns.de"
a.nameservers
# => ["ns1.prodns.de 213.160.64.75", "ns2.prodns.de 213.160.65.75", "ns3.prodns.de 83.133.190.12"]

to_time method issue with Ruby 1.9.1_p376 and whois > 1.1.3

I've got this error with whois > 1.1.3 using Ruby 1.9.1_p376 :

/usr/lib64/ruby19/gems/1.9.1/gems/whois-1.1.6/lib/core_ext.rb:27:in `remove_method': method `to_time' not defined in DateTime (NameError)
        from /usr/lib64/ruby19/gems/1.9.1/gems/whois-1.1.6/lib/core_ext.rb:27:in `'
        from /usr/lib64/ruby19/gems/1.9.1/gems/whois-1.1.6/lib/core_ext.rb:24:in `'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `block in require'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
        from /usr/lib64/ruby19/gems/1.9.1/gems/whois-1.1.6/lib/whois.rb:17:in `'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `block in require'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
        from /usr/lib64/ruby19/gems/1.9.1/gems/rails-2.3.8/lib/rails/gem_dependency.rb:215:in `load'
        from /usr/lib64/ruby19/gems/1.9.1/gems/rails-2.3.8/lib/initializer.rb:307:in `block in load_gems'
        from /usr/lib64/ruby19/gems/1.9.1/gems/rails-2.3.8/lib/initializer.rb:307:in `each'
        from /usr/lib64/ruby19/gems/1.9.1/gems/rails-2.3.8/lib/initializer.rb:307:in `load_gems'
        from /usr/lib64/ruby19/gems/1.9.1/gems/rails-2.3.8/lib/initializer.rb:164:in `process'
        from /usr/lib64/ruby19/gems/1.9.1/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
        from /home/kochka/meeting-engine-admin/config/environment.rb:12:in `'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `block in require'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
        from /usr/lib64/ruby19/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
        from /usr/lib64/ruby19/gems/1.9.1/gems/rails-2.3.8/lib/commands/server.rb:84:in `'
        from script/server:3:in `require'
        from script/server:3:in `'

korean and japanese addresses

Posted on behalf of Stan Wiechers.
http://groups.google.com/group/ruby-whois/browse_thread/thread/de2df45efda4ee78?hl=en_US

We have had trouble getting results for certain Korean and Japanese
addresses. Take the addresses below as example, when I run a query on
it a get a lot of garbled characters.

Korea: 222.96.17.158
Japan: 218.43.43.43

What can I do to get readable whois answer for those address types?
They work perfectly fine with my OS X whois command line tool.

WHOIS query for set.tv crashes

$ ruby-whois set.tv
/Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:126:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:126:in `open'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:126:in `ask_the_socket'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/verisign.rb:28:in `request'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:85:in `query'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:109:in `with_buffer'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:84:in `query'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/client.rb:79:in `query'
    from /Users/weppos/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/timeout.rb:62:in `timeout'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/client.rb:77:in `query'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/ruby-whois:52
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/bin/ruby-whois:19:in `load'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/bin/ruby-whois:19

Status property behaves differently depending on the current parser

Migrated from http://code.simonecarletti.com/issues/343

The status property currently return mixed values. Some parsers return a string, others a symbol ad others an array.
Also, the value is not normalized and current implementation makes the property pointless.

>> Whois.query("google.it").status
=> :"grace-period" 

>> Whois.query("google.com").status
=> ["clientDeleteProhibited", "clientTransferProhibited", "clientUpdateProhibited", "serverDeleteProhibited", "serverTransferProhibited", "serverUpdateProhibited"]

>> Whois.query("google.de").status
=> "connect"

Most common status values

  • available - domain not registered and available for registration
  • registered - domain registered and not available for registration
  • unavailable - domain not registered and not available for registration (786a8ec)
  • reserved - the domain is registered and reserved.
  • inactive - domain registered and no active nameservers ref
  • redemption (e2d15a8, 59a0d1c, 891675e, GH-33)
  • expired - after redemption
  • suspended - the domain was suspended by the registry, normally in response of a violation
  • invalid - (or error?) normally this is the result of an invalid query or request

whois.nic.dm doesn't work

$ ruby-whois google.dm
/Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/../lib/whois/server/adapters/base.rb:126:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/../lib/whois/server/adapters/base.rb:126:in `open'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/../lib/whois/server/adapters/base.rb:126:in `ask_the_socket'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/../lib/whois/server/adapters/base.rb:120:in `query_the_socket'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/../lib/whois/server/adapters/standard.rb:34:in `request'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/../lib/whois/server/adapters/base.rb:85:in `query'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/../lib/whois/server/adapters/base.rb:109:in `with_buffer'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/../lib/whois/server/adapters/base.rb:84:in `query'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/../lib/whois/client.rb:79:in `query'
    from /Users/weppos/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/timeout.rb:62:in `timeout'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/../lib/whois/client.rb:77:in `query'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.8/bin/ruby-whois:52
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/bin/ruby-whois:19:in `load'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/bin/ruby-whois:19

whois 1.0.12 fails to parse answers from ARIN.

I tested Whois 1.0.12 on Ruby 1.8.7 and 1.9.1, but I could not get it to parse the results returned for common IP Addresses such as for www.example.com (192.0.32.10).

require 'whois'

w = Whois::Client.new
answer = w.query('192.0.32.10')
# => "\nOrgName:    ICANN \nOrgID:      ICANN\nAddress:    4676 Admiralty Way\nAddress:    Suite 330\nCity:       Marina del Rey\nStateProv:  CA\nPostalCode: 90292\nCountry:    US\n\nNetRange:   192.0.32.0 - 192.0.47.255 \nCIDR:       192.0.32.0/20 \nOriginAS:   AS26711\nNetName:    ICANN-MDR\nNetHandle:  NET-192-0-32-0-1\nParent:     NET-192-0-0-0-0\nNetType:    Direct Assignment\nNameServer: A.IANA-SERVERS.NET\nNameServer: B.IANA-SERVERS.ORG\nNameServer: C.IANA-SERVERS.NET\nNameServer: D.IANA-SERVERS.NET\nNameServer: NS.ICANN.ORG\nComment:    \nRegDate:    2009-06-29\nUpdated:    2010-02-09\n\nOrgTechHandle: JAB349-ARIN\nOrgTechName:   Abley, Joe \nOrgTechPhone:  +1-310-578-8673\nOrgTechEmail:  [email protected]\n\nOrgTechHandle: MAK93-ARIN\nOrgTechName:   AKCIN, Mehmet \nOrgTechPhone:  +1-310-823-9358\nOrgTechEmail:  [email protected]\n\nOrgTechHandle: DCL131-ARIN\nOrgTechName:   Closson, David \nOrgTechPhone:  +1-310-578-8670\nOrgTechEmail:  [email protected]\n\nOrgTechHandle: DSO63-ARIN\nOrgTechName:   Soltero, David \nOrgTechPhone:  +1-310-301-3890\nOrgTechEmail:  [email protected]\n\n# ARIN WHOIS database, last updated 2010-04-27 20:00\n# Enter ? for additional hints on searching ARIN's WHOIS database.\n#\n# ARIN WHOIS data and services are subject to the Terms of Use\n# available at https://www.arin.net/whois_tou.html\n" 
answer.properties
# => {:status=>nil, :referral_url=>nil, :admin=>nil, :domain=>nil, :created_on=>nil, :technical=>nil, :updated_on=>nil, :nameservers=>nil, :disclaimer=>nil, :expires_on=>nil, :domain_id=>nil, :registrar=>nil, :referral_whois=>nil, :registrant=>nil, :registered?=>nil, :available?=>nil}

get netname

An interface to this functionality would be nice

$ whois 77.67.19.144 | grep netname
netname: AKAMAI-TINET
$ whois 85.25.0.24 | grep netname
netname: INTERGENIA-1

Intelligent error detection

$ ruby-whois hosteurope.de
% Error: 55000000013 Invalid charset for response

Some WHOIS responses contain an error message. The parser could be able to detect them and raise an exception.

Connection reset/time out

I am getting this error after getting whois info for around 20-30 random domains (consist mainly of .com and .net):

/home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/whois-1.3.9/lib/whois/server/adapters/base.rb:128:in `read': Connection reset by peer (Errno::ECONNRESET)
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/whois-1.3.9/lib/whois/server/adapters/base.rb:128:in `ask_the_socket'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/whois-1.3.9/lib/whois/server/adapters/pir.rb:24:in `request'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/whois-1.3.9/lib/whois/server/adapters/base.rb:85:in `block in query'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/whois-1.3.9/lib/whois/server/adapters/base.rb:109:in `with_buffer'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/whois-1.3.9/lib/whois/server/adapters/base.rb:84:in `query'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/whois-1.3.9/lib/whois/client.rb:79:in `block in query'
    from /home/lamnk/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/timeout.rb:57:in `timeout'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/whois-1.3.9/lib/whois/client.rb:77:in `query'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/whois-1.3.9/lib/whois.rb:54:in `query'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/whois-1.3.9/lib/whois.rb:130:in `whois'
    from dict_vi_en.rb:51:in `block (2 levels) in <main>'
    from dict_vi_en.rb:49:in `each'
    from dict_vi_en.rb:49:in `block in <main>'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/adapters/mysql.rb:427:in `yield_rows'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/adapters/mysql.rb:344:in `block in fetch_rows'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/adapters/mysql.rb:165:in `_execute'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/adapters/mysql.rb:147:in `block in execute'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/connection_pool/threaded.rb:84:in `hold'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/database/connecting.rb:224:in `synchronize'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/adapters/mysql.rb:147:in `execute'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/dataset/actions.rb:541:in `execute'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/adapters/mysql.rb:403:in `execute'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/adapters/mysql.rb:329:in `fetch_rows'
    from /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/sequel-3.16.0/lib/sequel/dataset/actions.rb:123:in `each'
    from dict_vi_en.rb:48:in `<main>'

Is it because of the whois servers limiting automated queries ?

NicWhoisIt parser can't handle multiple tech contacts

Migrated from http://code.simonecarletti.com/issues/330

*********************************************************************
* Please note that the following result could be a subgroup of      *
* the data contained in the database.                               *
*                                                                   *
* Additional information can be visualized at:                      *
* http://www.nic.it/cgi-bin/Whois/whois.cgi                         *
*********************************************************************

Domain:             innovazionepa.it
Status:             ACTIVE
Created:            2006-07-14 00:00:00
Last Update:        2009-07-30 00:06:53
Expire Date:        2010-07-14

Registrant
  Name:             Presidenza del Consiglio dei Ministri
  Organization:     Presidenza del Consiglio dei Ministri
  ContactID:        PRES2-ITNIC
  Address:          P.zza Colonna, 370
                    Roma
                    00187
                    RM
                    IT
  Created:          2007-03-01 10:26:04
  Last Update:      2008-01-21 11:10:53

Admin Contact
  Name:             Salvatore Tucci
  ContactID:        ST1136-ITNIC
  Address:          Presidenza del Consiglio dei Ministri
                    P.zza Colonna, 370
                    Roma
                    00187
                    RM
                    IT
  Created:          2005-09-29 00:00:00
  Last Update:      2008-01-21 11:10:53

Technical Contacts
  Name:             Francesco Proietti
  ContactID:        FP43-ITNIC
  Address:          Consorzio CASPUR
                    Via dei Tizii, 6b
                    Roma
                    00185
                    RM
                    IT
  Created:          2003-05-05 00:00:00
  Last Update:      2009-11-03 13:28:46

  Name:             Marco Lusini
  ContactID:        ML3648-ITNIC
  Address:          Presidenza del Consiglio dei Ministri
                    Via della Mercede, 96
                    Roma
                    00187
                    RM
                    IT
  Created:          2005-02-18 00:00:00
  Last Update:      2007-03-01 07:37:08

  Name:             Sergio Patrucco
  ContactID:        SP5403-ITNIC
  Address:          Presidenza del Consiglio dei Ministri
                    Via della Mercede, 96
                    Roma
                    00187
                    RM
                    IT
  Created:          2005-04-28 00:00:00
  Last Update:      2007-03-01 07:37:08

  Name:             Ezio gandini
  ContactID:        EG4997-ITNIC
  Address:          Presidenza del Consiglio dei Ministri
                    Via della Mercede, 96
                    Roma
                    00187
                    RM
                    IT
  Created:          2007-03-28 14:59:18
  Last Update:      2008-01-21 12:09:27

Registrar
  Organization:     Caspur
  Name:             INROMA-MNT

Nameservers
  ns.palazzochigi.it
  ns2.palazzochigi.it
  decsrv.caspur.it

Update .tv WHOIS server to tvwhois.verisign-grs.com

whois.nic.tv is no longer available.

$ ruby-whois set.tv
/Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:126:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:126:in `open'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:126:in `ask_the_socket'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/verisign.rb:28:in `request'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:85:in `query'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:109:in `with_buffer'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/server/adapters/base.rb:84:in `query'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/client.rb:79:in `query'
    from /Users/weppos/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/timeout.rb:62:in `timeout'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/../lib/whois/client.rb:77:in `query'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/gems/whois-1.3.7/bin/ruby-whois:52
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/bin/ruby-whois:19:in `load'
    from /Users/weppos/.rvm/gems/ruby-1.8.7-p249/bin/ruby-whois:19

ARIN requires a special query format

Migrated from http://code.simonecarletti.com/issues/279

ARIN returns only a stripped version of the whois entry if no additional parameter (+) is given.

Modified search_whois:

/var/lib/gems/1.8/gems/whois-0.4.2/lib/whois.rb

def search_whois
s = TCPsocket.open(@server.server, 43)
if @server.class.name.eql?("Whois::Server::Arin")
s.write("+#{self.ip.to_s}\n")
else
s.write("#{self.ip.to_s}\n")
end
ret = ''
while s.gets do ret += $_ end
s.close
@all = ret
end

#version parser property

Some responses support the #version property.
Also, some parsers already introduce the #version property and #schema private method.

whois.nic.bj doesn't work

Doesn't answer within 60 seconds.

weppos:whois weppos$ ruby-whois google.bj
/Users/weppos/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/timeout.rb:60:in `open': execution expired (Timeout::Error)
    from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/base.rb:83:in `ask_the_socket'
    from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/base.rb:77:in `query_the_socket'
    from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/standard.rb:34:in `request'
    from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/base.rb:52:in `query'
    from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/base.rb:66:in `with_buffer'
    from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/base.rb:51:in `query'
    from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/client.rb:72:in `query'
    from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/client.rb:70:in `query'
    from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/bin/ruby-whois:37
    from /Users/weppos/.rvm/gems/ruby/1.8.7/bin/ruby-whois:19:in `load'
    from /Users/weppos/.rvm/gems/ruby/1.8.7/bin/ruby-whois:19

whois.nic.gp doesn't work

$ bin/ruby-whois google.gp
./bin/../lib/whois/server/adapters/base.rb:126:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
    from ./bin/../lib/whois/server/adapters/base.rb:126:in `open'
    from ./bin/../lib/whois/server/adapters/base.rb:126:in `ask_the_socket'
    from ./bin/../lib/whois/server/adapters/base.rb:120:in `query_the_socket'
    from ./bin/../lib/whois/server/adapters/standard.rb:34:in `request'
    from ./bin/../lib/whois/server/adapters/base.rb:85:in `query'
    from ./bin/../lib/whois/server/adapters/base.rb:109:in `with_buffer'
    from ./bin/../lib/whois/server/adapters/base.rb:84:in `query'
    from ./bin/../lib/whois/client.rb:79:in `query'
    from /Users/weppos/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/timeout.rb:62:in `timeout'
    from ./bin/../lib/whois/client.rb:77:in `query'
    from bin/ruby-whois:52

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.