whois 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +10 -1
- data/Manifest +1 -0
- data/README.rdoc +17 -3
- data/Rakefile +2 -11
- data/bin/ruby-whois +37 -0
- data/lib/whois/server/adapters/afilias.rb +14 -5
- data/lib/whois/server/adapters/pir.rb +16 -7
- data/lib/whois/server/adapters/verisign.rb +13 -4
- data/lib/whois/version.rb +1 -1
- data/test/adapters/afilias_test.rb +8 -6
- data/test/adapters/pir_test.rb +8 -6
- data/test/adapters/verisign_test.rb +8 -6
- data/whois.gemspec +7 -5
- metadata +9 -5
data/CHANGELOG.rdoc
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
3
|
|
4
|
-
== 0.5.
|
4
|
+
== Release 0.5.1
|
5
|
+
|
6
|
+
* FIXED: 'rake coverage' task crashes.
|
7
|
+
|
8
|
+
* FIXED: In case of thin server the client should concatenate all responses (closes #259).
|
9
|
+
|
10
|
+
* ADDED: Whois binary (closes #271).
|
11
|
+
|
12
|
+
|
13
|
+
== Release 0.5.0
|
5
14
|
|
6
15
|
* FIXED: Whois#whois defined as instance method but modules can't have instances!
|
7
16
|
|
data/Manifest
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
= Whois
|
2
2
|
|
3
|
-
Whois is
|
3
|
+
Whois is an intelligent pure Ruby WHOIS client.
|
4
|
+
|
4
5
|
It is a os-independent library and doesn't require external C libraries or GEMS: it is a 100% Ruby software with all the advantages and disadvantages that it involves.
|
5
6
|
|
6
7
|
This software was developed to power RoboDomain[http://www.robodomain.com] and, despite it has been using in a production environment since July 2009, it should not be considered production-ready yet. It is currently in its beta stage.
|
@@ -42,6 +43,8 @@ You might need administrator privileges on your system to install it.
|
|
42
43
|
|
43
44
|
== Getting Started
|
44
45
|
|
46
|
+
Note. This section covers only the essentials for getting started with the Whois library. If you want to take the full advantage of all its features, visit the {documentation page}[http://code.simonecarletti.com/wiki/whois].
|
47
|
+
|
45
48
|
Whois provides the ability to get whois information for hostnames, ipv4 and ipv6 ip addresses. The client is smart enough to guess the best whois server according to given query, send the request and return the response.
|
46
49
|
|
47
50
|
Checkout the following examples:
|
@@ -69,10 +72,18 @@ The query method is stateless. For this reason, you can safely re-use the same c
|
|
69
72
|
w.query("2001:db8::1428:57ab")
|
70
73
|
w.query("google.it")
|
71
74
|
|
75
|
+
=== Timeout
|
72
76
|
|
73
|
-
|
77
|
+
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 <tt>Timeout::Error</tt> exception.
|
74
78
|
|
75
|
-
|
79
|
+
Off course, you can customize the timeout value setting a different value. If timeout is <tt>nil</tt>, 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!
|
80
|
+
|
81
|
+
w = Whois::Client.new(:timeout => 10)
|
82
|
+
w.timeout # => 10
|
83
|
+
w.timeout = 5
|
84
|
+
w.timeout # => 5
|
85
|
+
|
86
|
+
w.query("google.com")
|
76
87
|
|
77
88
|
|
78
89
|
== Acknowledgments
|
@@ -121,6 +132,9 @@ Bug reports and Feature suggestions {are welcomed}[http://code.simonecarletti.co
|
|
121
132
|
* {Homepage}[http://code.simonecarletti.com/whois]
|
122
133
|
* {GitHub}[http://github.com/weppos/whois]
|
123
134
|
* {RubyForge}[http://rubyforge.org/projects/whois/]
|
135
|
+
|
136
|
+
* {Documentation}[http://code.simonecarletti.com/wiki/whois]
|
137
|
+
* {API}[http://whois.rubyforge.org/]
|
124
138
|
* {Discussion Group}[http://groups.google.com/group/ruby-whois]
|
125
139
|
|
126
140
|
|
data/Rakefile
CHANGED
@@ -9,10 +9,6 @@ require 'whois'
|
|
9
9
|
# Common package properties
|
10
10
|
PKG_NAME = ENV['PKG_NAME'] || Whois::GEM
|
11
11
|
PKG_VERSION = ENV['PKG_VERSION'] || Whois::VERSION
|
12
|
-
PKG_FILES = FileList.new("{lib,test}/**/*.rb") do |files|
|
13
|
-
files.include %w(README.rdoc CHANGELOG.rdoc LICENSE.rdoc)
|
14
|
-
files.include %w(Rakefile)
|
15
|
-
end
|
16
12
|
RUBYFORGE_PROJECT = 'whois'
|
17
13
|
|
18
14
|
if ENV['SNAPSHOT'].to_i == 1
|
@@ -27,22 +23,17 @@ Echoe.new(PKG_NAME, PKG_VERSION) do |p|
|
|
27
23
|
p.url = "http://code.simonecarletti.com/whois"
|
28
24
|
p.project = RUBYFORGE_PROJECT
|
29
25
|
p.description = <<-EOD
|
30
|
-
|
26
|
+
Whois is an intelligent WHOIS client written in pure Ruby. \
|
31
27
|
It enables you to query registry data for ipv4, ipv6 and top level domains.
|
32
28
|
EOD
|
33
29
|
|
34
30
|
p.need_zip = true
|
35
|
-
p.rdoc_pattern = /^(lib|CHANGELOG.rdoc|README.rdoc)/
|
36
31
|
|
37
32
|
p.development_dependencies += ["rake ~>0.8",
|
38
33
|
"echoe ~>3.1",
|
39
34
|
"mocha ~>0.9"]
|
40
|
-
#p.add_development_dependency "rake", "~>0.8.0"
|
41
|
-
#p.add_development_dependency "echoe", "~>3.1.0"
|
42
|
-
#p.add_development_dependency "mocha", "~>0.9.0"
|
43
|
-
|
44
|
-
p.rcov_options = ["--main << README.rdoc -x Rakefile -x mocha -x rcov"]
|
45
35
|
|
36
|
+
p.rcov_options = ["-Itest -x mocha,rcov,Rakefile"]
|
46
37
|
end
|
47
38
|
|
48
39
|
|
data/bin/ruby-whois
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby -wKU
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'whois'
|
6
|
+
|
7
|
+
opts = OptionParser.new do |opts|
|
8
|
+
opts.banner = "Whois: an intelligent pure Ruby Whois client"
|
9
|
+
opts.define_head "Usage: whois [options] object"
|
10
|
+
opts.separator ""
|
11
|
+
opts.separator "Examples:"
|
12
|
+
opts.separator " whois ruby-lang.com"
|
13
|
+
opts.separator " whois 213.149.247.64"
|
14
|
+
opts.separator ""
|
15
|
+
opts.separator "Options:"
|
16
|
+
|
17
|
+
opts.on_tail("--help", "Show this message") do
|
18
|
+
puts opts
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on_tail("-V", "--version", "Show version") do
|
23
|
+
puts "#{Whois::NAME} #{Whois::VERSION}"
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
opts.parse!
|
28
|
+
|
29
|
+
qstring = ARGV.shift
|
30
|
+
|
31
|
+
if qstring.to_s.strip.empty?
|
32
|
+
puts opts
|
33
|
+
exit 1
|
34
|
+
end
|
35
|
+
|
36
|
+
@client = Whois::Client.new
|
37
|
+
puts @client.query(qstring)
|
@@ -17,18 +17,27 @@
|
|
17
17
|
module Whois
|
18
18
|
class Server
|
19
19
|
module Adapters
|
20
|
-
|
20
|
+
|
21
21
|
class Afilias < Base
|
22
|
-
|
22
|
+
|
23
23
|
def request(qstring)
|
24
24
|
response = ask_the_socket(qstring, "whois.afilias-grs.info", DEFAULT_WHOIS_PORT)
|
25
|
-
|
26
|
-
|
25
|
+
endpoint = extract_referral(response)
|
26
|
+
if endpoint
|
27
|
+
response + "\n" + ask_the_socket(qstring, endpoint, DEFAULT_WHOIS_PORT)
|
27
28
|
else
|
28
29
|
response
|
29
30
|
end
|
30
31
|
end
|
31
|
-
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def extract_referral(response)
|
36
|
+
if response =~ /Domain Name:/ && response =~ /Whois Server:(\S+)/
|
37
|
+
$1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
32
41
|
end
|
33
42
|
|
34
43
|
end
|
@@ -17,21 +17,30 @@
|
|
17
17
|
module Whois
|
18
18
|
class Server
|
19
19
|
module Adapters
|
20
|
-
|
20
|
+
|
21
21
|
class Pir < Base
|
22
|
-
|
22
|
+
|
23
23
|
def request(qstring)
|
24
24
|
response = ask_the_socket("FULL #{qstring}", "whois.publicinterestregistry.net", DEFAULT_WHOIS_PORT)
|
25
|
-
|
26
|
-
|
27
|
-
ask_the_socket(qstring,
|
25
|
+
endpoint = extract_referral(response)
|
26
|
+
if endpoint
|
27
|
+
response + "\n" + ask_the_socket(qstring, endpoint, DEFAULT_WHOIS_PORT)
|
28
28
|
else
|
29
29
|
response
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def extract_referral(response)
|
36
|
+
if response =~ /Registrant Name:SEE SPONSORING REGISTRAR/ &&
|
37
|
+
response =~ /Registrant Street1:Whois Server:(\S+)/
|
38
|
+
$1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
33
42
|
end
|
34
|
-
|
43
|
+
|
35
44
|
end
|
36
45
|
end
|
37
46
|
end
|
@@ -22,15 +22,24 @@ module Whois
|
|
22
22
|
|
23
23
|
def request(qstring)
|
24
24
|
response = ask_the_socket("=#{qstring}", host, DEFAULT_WHOIS_PORT)
|
25
|
-
|
26
|
-
|
25
|
+
endpoint = extract_referral(response)
|
26
|
+
if endpoint
|
27
|
+
response + "\n" + ask_the_socket(qstring, endpoint, DEFAULT_WHOIS_PORT)
|
27
28
|
else
|
28
29
|
response
|
29
30
|
end
|
30
31
|
end
|
31
|
-
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def extract_referral(response)
|
36
|
+
if response =~ /Domain Name:/ && response =~ /Whois Server: (\S+)/
|
37
|
+
$1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
32
41
|
end
|
33
|
-
|
42
|
+
|
34
43
|
end
|
35
44
|
end
|
36
45
|
end
|
data/lib/whois/version.rb
CHANGED
@@ -10,16 +10,18 @@ class ServerAdaptersAfiliasTest < Test::Unit::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_query
|
13
|
-
|
14
|
-
|
13
|
+
response = "No match for DOMAIN.FOO."
|
14
|
+
expected = response
|
15
|
+
@server.expects(:ask_the_socket).with("domain.foo", "whois.afilias-grs.info", 43).returns(response)
|
15
16
|
assert_equal expected, @server.query("domain.foo")
|
16
17
|
end
|
17
18
|
|
18
19
|
def test_query_with_referral
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@server.expects(:ask_the_socket).with("domain.foo", "whois.
|
20
|
+
referral = File.read(File.dirname(__FILE__) + "/../testcases/referrals/afilias.bz.txt")
|
21
|
+
response = "Match for DOMAIN.FOO."
|
22
|
+
expected = referral + "\n" + response
|
23
|
+
@server.expects(:ask_the_socket).with("domain.foo", "whois.afilias-grs.info", 43).returns(referral)
|
24
|
+
@server.expects(:ask_the_socket).with("domain.foo", "whois.belizenic.bz", 43).returns(response)
|
23
25
|
assert_equal expected, @server.query("domain.foo")
|
24
26
|
end
|
25
27
|
|
data/test/adapters/pir_test.rb
CHANGED
@@ -10,16 +10,18 @@ class ServerAdaptersPirTest < Test::Unit::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_query
|
13
|
-
|
14
|
-
|
13
|
+
response = "No match for DOMAIN.FOO."
|
14
|
+
expected = response
|
15
|
+
@server.expects(:ask_the_socket).with("FULL domain.foo", "whois.publicinterestregistry.net", 43).returns(response)
|
15
16
|
assert_equal expected, @server.query("domain.foo")
|
16
17
|
end
|
17
18
|
|
18
19
|
def test_query_with_referral
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@server.expects(:ask_the_socket).with("domain.foo", "whois.
|
20
|
+
referral = File.read(File.dirname(__FILE__) + "/../testcases/referrals/pir.org.txt")
|
21
|
+
response = "Match for DOMAIN.FOO."
|
22
|
+
expected = referral + "\n" + response
|
23
|
+
@server.expects(:ask_the_socket).with("FULL domain.foo", "whois.publicinterestregistry.net", 43).returns(referral)
|
24
|
+
@server.expects(:ask_the_socket).with("domain.foo", "whois.iana.org", 43).returns(response)
|
23
25
|
assert_equal expected, @server.query("domain.foo")
|
24
26
|
end
|
25
27
|
|
@@ -10,16 +10,18 @@ class ServerAdaptersVerisignTest < Test::Unit::TestCase
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_query
|
13
|
-
|
14
|
-
|
13
|
+
response = "No match for DOMAIN.FOO."
|
14
|
+
expected = response
|
15
|
+
@server.expects(:ask_the_socket).with("=domain.foo", "whois.foo", 43).returns(response)
|
15
16
|
assert_equal expected, @server.query("domain.foo")
|
16
17
|
end
|
17
18
|
|
18
19
|
def test_query_with_referral
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@server.expects(:ask_the_socket).with("domain.foo", "whois.
|
20
|
+
referral = File.read(File.dirname(__FILE__) + "/../testcases/referrals/crsnic.com.txt")
|
21
|
+
response = "Match for DOMAIN.FOO."
|
22
|
+
expected = referral + "\n" + response
|
23
|
+
@server.expects(:ask_the_socket).with("=domain.foo", "whois.foo", 43).returns(referral)
|
24
|
+
@server.expects(:ask_the_socket).with("domain.foo", "whois.tucows.com", 43).returns(response)
|
23
25
|
assert_equal expected, @server.query("domain.foo")
|
24
26
|
end
|
25
27
|
|
data/whois.gemspec
CHANGED
@@ -2,16 +2,18 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{whois}
|
5
|
-
s.version = "0.5.
|
5
|
+
s.version = "0.5.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Simone Carletti"]
|
9
|
-
s.date = %q{2009-08-
|
10
|
-
s.
|
9
|
+
s.date = %q{2009-08-10}
|
10
|
+
s.default_executable = %q{ruby-whois}
|
11
|
+
s.description = %q{ Whois is an intelligent WHOIS client written in pure Ruby. It enables you to query registry data for ipv4, ipv6 and top level domains.
|
11
12
|
}
|
12
13
|
s.email = %q{weppos@weppos.net}
|
13
|
-
s.
|
14
|
-
s.
|
14
|
+
s.executables = ["ruby-whois"]
|
15
|
+
s.extra_rdoc_files = ["bin/ruby-whois", "CHANGELOG.rdoc", "lib/whois/client.rb", "lib/whois/definitions/ipv4.rb", "lib/whois/definitions/ipv4.txt", "lib/whois/definitions/ipv6.rb", "lib/whois/definitions/ipv6.txt", "lib/whois/definitions/tlds.rb", "lib/whois/definitions/tlds.txt", "lib/whois/errors.rb", "lib/whois/server/adapters/afilias.rb", "lib/whois/server/adapters/arpa.rb", "lib/whois/server/adapters/base.rb", "lib/whois/server/adapters/formatted.rb", "lib/whois/server/adapters/none.rb", "lib/whois/server/adapters/not_implemented.rb", "lib/whois/server/adapters/pir.rb", "lib/whois/server/adapters/standard.rb", "lib/whois/server/adapters/verisign.rb", "lib/whois/server/adapters/web.rb", "lib/whois/server.rb", "lib/whois/version.rb", "lib/whois/whois.rb", "lib/whois.rb", "LICENSE.rdoc", "README.rdoc", "tasks/server.rake"]
|
16
|
+
s.files = ["bin/ruby-whois", "CHANGELOG.rdoc", "data/ip6_del_list", "data/ip_del_list", "data/make_ip6_del.pl", "data/make_ip_del.pl", "data/make_tld_serv.pl", "data/tld_serv_list", "lib/whois/client.rb", "lib/whois/definitions/ipv4.rb", "lib/whois/definitions/ipv4.txt", "lib/whois/definitions/ipv6.rb", "lib/whois/definitions/ipv6.txt", "lib/whois/definitions/tlds.rb", "lib/whois/definitions/tlds.txt", "lib/whois/errors.rb", "lib/whois/server/adapters/afilias.rb", "lib/whois/server/adapters/arpa.rb", "lib/whois/server/adapters/base.rb", "lib/whois/server/adapters/formatted.rb", "lib/whois/server/adapters/none.rb", "lib/whois/server/adapters/not_implemented.rb", "lib/whois/server/adapters/pir.rb", "lib/whois/server/adapters/standard.rb", "lib/whois/server/adapters/verisign.rb", "lib/whois/server/adapters/web.rb", "lib/whois/server.rb", "lib/whois/version.rb", "lib/whois/whois.rb", "lib/whois.rb", "LICENSE.rdoc", "Manifest", "Rakefile", "README.rdoc", "tasks/server.rake", "test/adapters/afilias_test.rb", "test/adapters/none_test.rb", "test/adapters/not_implemented_test.rb", "test/adapters/pir_test.rb", "test/adapters/standard_test.rb", "test/adapters/verisign_test.rb", "test/adapters/web_test.rb", "test/client_test.rb", "test/deprecated_test.rb", "test/server_test.rb", "test/test_helper.rb", "test/testcases/referrals/afilias.bz.txt", "test/testcases/referrals/crsnic.com.txt", "test/testcases/referrals/niccc.cc.txt", "test/testcases/referrals/pir.org.txt", "test/testcases/responses/it.txt", "test/whois_test.rb", "utils/bm_shell_vs_pure.rb", "utils/tlds.txt", "whois.gemspec"]
|
15
17
|
s.homepage = %q{http://code.simonecarletti.com/whois}
|
16
18
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Whois", "--main", "README.rdoc"]
|
17
19
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whois
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simone Carletti
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-10 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,13 +42,14 @@ dependencies:
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: "0.9"
|
44
44
|
version:
|
45
|
-
description: "
|
45
|
+
description: " Whois is an intelligent WHOIS client written in pure Ruby. It enables you to query registry data for ipv4, ipv6 and top level domains.\n"
|
46
46
|
email: weppos@weppos.net
|
47
|
-
executables:
|
48
|
-
|
47
|
+
executables:
|
48
|
+
- ruby-whois
|
49
49
|
extensions: []
|
50
50
|
|
51
51
|
extra_rdoc_files:
|
52
|
+
- bin/ruby-whois
|
52
53
|
- CHANGELOG.rdoc
|
53
54
|
- lib/whois/client.rb
|
54
55
|
- lib/whois/definitions/ipv4.rb
|
@@ -72,8 +73,11 @@ extra_rdoc_files:
|
|
72
73
|
- lib/whois/version.rb
|
73
74
|
- lib/whois/whois.rb
|
74
75
|
- lib/whois.rb
|
76
|
+
- LICENSE.rdoc
|
75
77
|
- README.rdoc
|
78
|
+
- tasks/server.rake
|
76
79
|
files:
|
80
|
+
- bin/ruby-whois
|
77
81
|
- CHANGELOG.rdoc
|
78
82
|
- data/ip6_del_list
|
79
83
|
- data/ip_del_list
|