Giter Club home page Giter Club logo

whois's Introduction

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

This library was extracted from RoboWhois and RoboDomain. It has been performing queries in production since July 2009.

Build Status

Donate a coffee

Click here to lend your support to: whois and make a donation at pledgie.com !

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.

Features

Requirements

  • Ruby >= 2.0.0

For older versions of Ruby, see the CHANGELOG.

Installation

The best way to install Whois is via RubyGemsLearn more

$ gem install whois

Getting Started

Note. 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
w = Whois::Client.new
w.lookup("google.com")
# => #<Whois::Record>

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

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

# IPv6 WHOIS
w = Whois::Client.new
w.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.

w = Whois::Client.new
w.lookup("google.com")
w.lookup(".com")
w.lookup("74.125.67.100")
w.lookup("2001:db8::1428:57ab")
w.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, by using an object oriented syntax.

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

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

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

t = r.technical_contact
# => #<Whois::Record::Contact>
t.id
# => "TS7016-ITNIC"
t.name
# => "Technical Services"

r.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 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 until the response is sent back from the server or the process is killed. Don't disable the timeout unless you really know you are doing!

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

w.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-2015 Simone Carletti. This is Free Software distributed under the MIT license.

whois's People

Contributors

weppos avatar semaperepelitsa avatar takama avatar linrock avatar rorymckinley avatar uko avatar huyphan avatar kliuchnikau avatar ezkl avatar mat813 avatar sherwind avatar alexaitken avatar case avatar cu39 avatar geoffgarside avatar veszig avatar gromnsk avatar axic avatar aadlani avatar justincampbell avatar dergutemoritz avatar sheldonh avatar delwyn avatar donthorp avatar tanelj avatar turadg avatar ledowong avatar pmyteh avatar manuelmeurer avatar byroot avatar

Watchers

James Cloos avatar Oleh Kukil avatar

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.