Defines a new server for :type queries.
type: | The type of WHOIS server to define. Known values are :tld, :ipv4, :ipv6. |
allocation: | The allocation, range or hostname this server is responsible for. |
host: | The server hostname. Use nil if unknown or not available. |
options: | Hash of options (default: {}). The :adapter option has a special meaning and determines the adapter Class to use. Defaults to </tt>Whois::Server::Adapters::Standard</tt> unless specified. All the other options are passed directly to the adapter which can decide how to use them. |
Nothing.
# Define a server for the .it extension Whois::Server.define :tld, ".it", "whois.nic.it" # Define a new server for an range of IPv4 addresses Whois::Server.define :ipv4, "61.192.0.0/12", "whois.nic.ad.jp" # Define a new server for an range of IPv6 addresses Whois::Server.define :ipv6, "2001:2000::/19", "whois.ripe.net" # Define a new server with a custom adapter Whois::Server.define :tld, ".test", nil, :adapter => Whois::Server::Adapter::None # Define a new server with a custom adapter and options Whois::Server.define :tld, ".ar", nil, :adapter => Whois::Server::Adapters::Web, :web => "http://www.nic.ar/"
Lookup and returns the definition list for given type, or all definitions if type is nil.
type: | The type of WHOIS server to lookup. Known values are :tld, :ipv4, :ipv6. |
Hash: | If the method is called without specifying a type. |
Array: | If the method is called specifying a type, and the type exists. |
nil: | If the method is called specifying a type, and the type doesn‘t exist. |
Whois::Server.definitions # => { :tld => [...], :ipv4 => [], ... } Whois::Server.definitions(:tld) # => [...] Whois::Server.definitions(:invalid) # => nil
Creates a new server adapter from given arguments and returns the server instance.
By default, returns a new Whois::Servers::Adapter::Standard instance. You can customize the behavior passing a custom adapter class as :adapter option.
Whois::Server.factory :tld, ".it", "whois.nic.it" # => #<Whois::Servers::Adapter::Standard> Whois::Server.factory :tld, ".it", "whois.nic.it", :option => Whois::Servers::Adapter::Custom # => #<Whois::Servers::Adapter::Custom>
Please note that any adapter is responsible for a limited set of queries, which should be included in the range of the allocation parameter. Use Whois::Server#guess if you are not sure which adapter is the right one for a specific string.
type: | The type of WHOIS server to define. Known values are :tld, :ipv4, :ipv6. |
allocation: | The allocation, range or hostname this server is responsible for. |
host: | The server hostname. Use nil if unknown or not available. |
options: | Hash of options (default: {}). The :adapter option has a special meaning and determines the adapter Class to use. Defaults to </tt>Whois::Server::Adapters::Standard</tt> unless specified. All the other options are passed directly to the adapter which can decide how to use them. |
Whois::Server::Adapters::Standard: | An adapter that can be used to perform queries. |
Parses qstring and tries to guess the right server.
It successfully detects the following query types:
Note that not all query types actually have a corresponding adapter. For instance, the following request will result in a Whois::ServerNotSupported exception.
Whois::Server.guess "mail@example.com"
Whois::Server::Adapters::Base: | The adapter that can be used to perform WHOIS queries for qstring. |
Whois::ServerNotFound: | When unable to find an appropriate WHOIS adapter for qstring. Most of the cases, the qstring haven‘t been recognised as one of the supported query types. |
Whois::ServerNotSupported: | When the qstring type is detected, but the object type doesn‘t have any supported WHOIS adapter associated. |
Searches the /definitions folder for definition files and loads them. This method is automatically invoked when this file is parsed by the Ruby interpreter (scroll down to the bottom of this file).