whois 5.0.1 → 5.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -0
- data/.rubocop_opinionated.yml +157 -0
- data/.rubocop_todo.yml +242 -0
- data/.simplecov +2 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +68 -53
- data/Gemfile +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/Rakefile +12 -17
- data/bin/console +1 -0
- data/bin/whoisrb +3 -2
- data/data/ipv4.json +1 -3
- data/data/tld.json +2 -90
- data/lib/whois.rb +12 -10
- data/lib/whois/client.rb +4 -2
- data/lib/whois/errors.rb +4 -2
- data/lib/whois/record.rb +3 -1
- data/lib/whois/record/part.rb +4 -3
- data/lib/whois/server.rb +26 -21
- data/lib/whois/server/adapters/afilias.rb +4 -1
- data/lib/whois/server/adapters/arin.rb +5 -2
- data/lib/whois/server/adapters/arpa.rb +22 -19
- data/lib/whois/server/adapters/base.rb +4 -4
- data/lib/whois/server/adapters/formatted.rb +4 -2
- data/lib/whois/server/adapters/none.rb +3 -1
- data/lib/whois/server/adapters/not_implemented.rb +3 -1
- data/lib/whois/server/adapters/standard.rb +4 -2
- data/lib/whois/server/adapters/verisign.rb +4 -1
- data/lib/whois/server/adapters/web.rb +3 -1
- data/lib/whois/server/socket_handler.rb +8 -6
- data/lib/whois/version.rb +4 -2
- data/spec/integration/whois_spec.rb +6 -6
- data/spec/spec_helper.rb +4 -2
- data/spec/support/helpers/connectivity_helper.rb +2 -0
- data/spec/support/helpers/spec_helper.rb +2 -0
- data/spec/whois/client_spec.rb +6 -7
- data/spec/whois/record/part_spec.rb +4 -4
- data/spec/whois/record_spec.rb +9 -7
- data/spec/whois/server/adapters/afilias_spec.rb +3 -3
- data/spec/whois/server/adapters/arin_spec.rb +7 -8
- data/spec/whois/server/adapters/arpa_spec.rb +2 -2
- data/spec/whois/server/adapters/base_spec.rb +13 -13
- data/spec/whois/server/adapters/formatted_spec.rb +7 -7
- data/spec/whois/server/adapters/none_spec.rb +2 -2
- data/spec/whois/server/adapters/not_implemented_spec.rb +3 -3
- data/spec/whois/server/adapters/standard_spec.rb +5 -5
- data/spec/whois/server/adapters/verisign_spec.rb +3 -3
- data/spec/whois/server/adapters/web_spec.rb +3 -3
- data/spec/whois/server/socket_handler_spec.rb +7 -5
- data/spec/whois/server_spec.rb +31 -29
- data/spec/whois/{errors_spec.rb → web_interface_error_spec.rb} +4 -4
- data/spec/whois/whois_spec.rb +3 -3
- metadata +11 -8
- data/tasks/spec.rake +0 -199
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Ruby Whois
|
3
5
|
#
|
4
6
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
7
|
#
|
6
|
-
# Copyright (c) 2009-
|
8
|
+
# Copyright (c) 2009-2021 Simone Carletti <weppos@weppos.net>
|
7
9
|
#++
|
8
10
|
|
9
11
|
|
@@ -40,6 +42,7 @@ module Whois
|
|
40
42
|
|
41
43
|
def extract_referral(response)
|
42
44
|
return unless (match = response.match(/Registrar WHOIS Server:(.+?)$/))
|
45
|
+
|
43
46
|
server = match[match.size - 1].strip
|
44
47
|
server.empty? ? nil : server
|
45
48
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Ruby Whois
|
3
5
|
#
|
4
6
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
7
|
#
|
6
|
-
# Copyright (c) 2009-
|
8
|
+
# Copyright (c) 2009-2021 Simone Carletti <weppos@weppos.net>
|
7
9
|
#++
|
8
10
|
|
9
11
|
|
@@ -39,9 +41,10 @@ module Whois
|
|
39
41
|
|
40
42
|
def extract_referral(response)
|
41
43
|
return unless response =~ /ReferralServer:\s*r?whois:\/\/([\w.-]+)(?::(\d+))?/
|
44
|
+
|
42
45
|
{
|
43
46
|
host: $1,
|
44
|
-
port: $2 ? $2.to_i : nil
|
47
|
+
port: $2 ? $2.to_i : nil,
|
45
48
|
}
|
46
49
|
end
|
47
50
|
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Ruby Whois
|
3
5
|
#
|
4
6
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
7
|
#
|
6
|
-
# Copyright (c) 2009-
|
8
|
+
# Copyright (c) 2009-2021 Simone Carletti <weppos@weppos.net>
|
7
9
|
#++
|
8
10
|
|
9
11
|
|
@@ -22,26 +24,27 @@ module Whois
|
|
22
24
|
|
23
25
|
private
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
a, b, c, d = string.scan(/[0-9]{1,3}\./).reverse
|
35
|
-
[a, b, c, d].map do |token|
|
36
|
-
token = (token ||= 0).to_i
|
37
|
-
if token <= 255 && token >= 0
|
38
|
-
token
|
39
|
-
else
|
40
|
-
raise ServerError, "Invalid .in-addr.arpa token `#{token}'"
|
41
|
-
end
|
42
|
-
end.join(".")
|
27
|
+
# "127.1.168.192.in-addr.arpa" => "192.168.1.127"
|
28
|
+
# "1.168.192.in-addr.arpa" => "192.168.1.0"
|
29
|
+
# "168.192.in-addr.arpa" => "192.168.0.0"
|
30
|
+
# "192.in-addr.arpa" => "192.0.0.0"
|
31
|
+
# "in-addr.arpa" => "0.0.0.0"
|
32
|
+
def inaddr_to_ip(string)
|
33
|
+
unless string.match?(/^([0-9]{1,3}\.?){0,4}in-addr\.arpa$/)
|
34
|
+
raise ServerError, "Invalid .in-addr.arpa address"
|
43
35
|
end
|
44
36
|
|
37
|
+
a, b, c, d = string.scan(/[0-9]{1,3}\./).reverse
|
38
|
+
[a, b, c, d].map do |token|
|
39
|
+
token = (token || 0).to_i
|
40
|
+
if token <= 255 && token >= 0
|
41
|
+
token
|
42
|
+
else
|
43
|
+
raise ServerError, "Invalid .in-addr.arpa token `#{token}'"
|
44
|
+
end
|
45
|
+
end.join(".")
|
46
|
+
end
|
47
|
+
|
45
48
|
end
|
46
49
|
|
47
50
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Ruby Whois
|
3
5
|
#
|
4
6
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
7
|
#
|
6
|
-
# Copyright (c) 2009-
|
8
|
+
# Copyright (c) 2009-2021 Simone Carletti <weppos@weppos.net>
|
7
9
|
#++
|
8
10
|
|
9
11
|
|
@@ -22,9 +24,7 @@ module Whois
|
|
22
24
|
@query_handler ||= SocketHandler.new
|
23
25
|
end
|
24
26
|
|
25
|
-
|
26
|
-
@query_handler = handler
|
27
|
-
end
|
27
|
+
attr_writer :query_handler
|
28
28
|
end
|
29
29
|
|
30
30
|
# Default WHOIS request port.
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Ruby Whois
|
3
5
|
#
|
4
6
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
7
|
#
|
6
|
-
# Copyright (c) 2009-
|
8
|
+
# Copyright (c) 2009-2021 Simone Carletti <weppos@weppos.net>
|
7
9
|
#++
|
8
10
|
|
9
11
|
|
@@ -47,7 +49,7 @@ module Whois
|
|
47
49
|
#
|
48
50
|
def request(string)
|
49
51
|
options[:format] || raise(ServerError, "Missing mandatory :format option for adapter `Formatted'")
|
50
|
-
response = query_the_socket(
|
52
|
+
response = query_the_socket(format(options[:format], string), host)
|
51
53
|
buffer_append response, host
|
52
54
|
end
|
53
55
|
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Ruby Whois
|
3
5
|
#
|
4
6
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
7
|
#
|
6
|
-
# Copyright (c) 2009-
|
8
|
+
# Copyright (c) 2009-2021 Simone Carletti <weppos@weppos.net>
|
7
9
|
#++
|
8
10
|
|
9
11
|
|
@@ -56,4 +58,4 @@ module Whois
|
|
56
58
|
|
57
59
|
end
|
58
60
|
end
|
59
|
-
end
|
61
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Ruby Whois
|
3
5
|
#
|
4
6
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
7
|
#
|
6
|
-
# Copyright (c) 2009-
|
8
|
+
# Copyright (c) 2009-2021 Simone Carletti <weppos@weppos.net>
|
7
9
|
#++
|
8
10
|
|
9
11
|
|
@@ -40,6 +42,7 @@ module Whois
|
|
40
42
|
|
41
43
|
def extract_referral(response)
|
42
44
|
return unless (match = response.match(/Registrar WHOIS Server:(.+?)$/))
|
45
|
+
|
43
46
|
server = match[match.size - 1].strip
|
44
47
|
server.empty? ? nil : server
|
45
48
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Ruby Whois
|
3
5
|
#
|
4
6
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
7
|
#
|
6
|
-
# Copyright (c) 2009-
|
8
|
+
# Copyright (c) 2009-2021 Simone Carletti <weppos@weppos.net>
|
7
9
|
#++
|
8
10
|
|
9
11
|
|
@@ -22,9 +24,9 @@ module Whois
|
|
22
24
|
# Array of connection errors to rescue
|
23
25
|
# and wrap into a {Whois::ConnectionError}
|
24
26
|
RESCUABLE_CONNECTION_ERRORS = [
|
25
|
-
|
26
|
-
|
27
|
-
]
|
27
|
+
SystemCallError,
|
28
|
+
SocketError,
|
29
|
+
].freeze
|
28
30
|
|
29
31
|
# Performs the Socket request.
|
30
32
|
#
|
@@ -36,8 +38,8 @@ module Whois
|
|
36
38
|
#
|
37
39
|
def call(query, *args)
|
38
40
|
execute(query, *args)
|
39
|
-
rescue *RESCUABLE_CONNECTION_ERRORS =>
|
40
|
-
raise ConnectionError, "#{
|
41
|
+
rescue *RESCUABLE_CONNECTION_ERRORS => e
|
42
|
+
raise ConnectionError, "#{e.class}: #{e.message}"
|
41
43
|
end
|
42
44
|
|
43
45
|
# Executes the low-level Socket connection.
|
data/lib/whois/version.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Ruby Whois
|
3
5
|
#
|
4
6
|
# An intelligent pure Ruby WHOIS client and parser.
|
5
7
|
#
|
6
|
-
# Copyright (c) 2009-
|
8
|
+
# Copyright (c) 2009-2021 Simone Carletti <weppos@weppos.net>
|
7
9
|
#++
|
8
10
|
|
9
11
|
|
10
12
|
module Whois
|
11
13
|
# The current library version.
|
12
|
-
VERSION = "5.0.
|
14
|
+
VERSION = "5.0.2"
|
13
15
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Whois do
|
4
|
-
|
5
|
-
let(:response) { "Domain: example.it\nStatus: AVAILABLE\n" }
|
6
|
+
let(:response) { "Domain: example.it\nStatus: AVAILABLE\n" }
|
6
7
|
|
7
8
|
describe "Basic WHOIS querying and parsing" do
|
8
9
|
it "works" do
|
@@ -32,7 +33,7 @@ describe Whois do
|
|
32
33
|
.with("example.it", "whois.nic.it", 43, "192.168.1.1", 3000)
|
33
34
|
.and_return(response)
|
34
35
|
|
35
|
-
client = Whois::Client.new(:
|
36
|
+
client = Whois::Client.new(bind_host: "192.168.1.1", bind_port: 3000)
|
36
37
|
client.lookup("example.it")
|
37
38
|
end
|
38
39
|
end
|
@@ -46,7 +47,7 @@ describe Whois do
|
|
46
47
|
.with("example.it", "whois.nic.it", 43, Whois::Server::Adapters::Base::DEFAULT_BIND_HOST, 3000)
|
47
48
|
.and_return(response)
|
48
49
|
|
49
|
-
client = Whois::Client.new(:
|
50
|
+
client = Whois::Client.new(bind_port: 3000)
|
50
51
|
client.lookup("example.it")
|
51
52
|
end
|
52
53
|
end
|
@@ -60,7 +61,7 @@ describe Whois do
|
|
60
61
|
.with("example.it", "whois.example.com", 43)
|
61
62
|
.and_return(response)
|
62
63
|
|
63
|
-
client = Whois::Client.new(:
|
64
|
+
client = Whois::Client.new(host: "whois.example.com")
|
64
65
|
record = client.lookup("example.it")
|
65
66
|
|
66
67
|
expect(record.parts.size).to eq(1)
|
@@ -69,5 +70,4 @@ describe Whois do
|
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
72
|
-
|
73
73
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rspec'
|
2
4
|
require 'whois'
|
3
5
|
|
4
6
|
unless defined?(SPEC_ROOT)
|
5
|
-
SPEC_ROOT = File.expand_path(
|
7
|
+
SPEC_ROOT = File.expand_path(__dir__)
|
6
8
|
end
|
7
9
|
|
8
10
|
# The fixtures are UTF-8 encoded.
|
@@ -12,7 +14,7 @@ Encoding.default_internal = Encoding::UTF_8
|
|
12
14
|
|
13
15
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
14
16
|
# in spec/support/ and its subdirectories.
|
15
|
-
Dir[File.join(SPEC_ROOT, "support/**/*.rb")].each { |f| require f }
|
17
|
+
Dir[File.join(SPEC_ROOT, "support/**/*.rb")].sort.each { |f| require f }
|
16
18
|
|
17
19
|
RSpec.configure do |config|
|
18
20
|
config.mock_with :rspec
|
data/spec/whois/client_spec.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Whois::Client do
|
4
|
-
|
5
6
|
describe "#initialize" do
|
6
7
|
it "accepts a zero parameters" do
|
7
|
-
expect { described_class.new }.
|
8
|
+
expect { described_class.new }.not_to raise_error
|
8
9
|
end
|
9
10
|
|
10
11
|
it "accepts a settings parameter" do
|
11
|
-
expect { described_class.new({ foo: "bar" }) }.
|
12
|
+
expect { described_class.new({ foo: "bar" }) }.not_to raise_error
|
12
13
|
end
|
13
14
|
|
14
15
|
|
@@ -111,7 +112,7 @@ describe Whois::Client do
|
|
111
112
|
client = described_class.new(timeout: 5)
|
112
113
|
expect {
|
113
114
|
client.lookup("example.test")
|
114
|
-
}.
|
115
|
+
}.not_to raise_error
|
115
116
|
end
|
116
117
|
|
117
118
|
it "supports unlimited timeout" do
|
@@ -125,9 +126,8 @@ describe Whois::Client do
|
|
125
126
|
client = described_class.new.tap { |c| c.timeout = nil }
|
126
127
|
expect {
|
127
128
|
client.lookup("example.test")
|
128
|
-
}.
|
129
|
+
}.not_to raise_error
|
129
130
|
end
|
130
|
-
|
131
131
|
end
|
132
132
|
|
133
133
|
# FIXME: use RSpec metadata
|
@@ -140,5 +140,4 @@ describe Whois::Client do
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
143
|
-
|
144
143
|
end
|
@@ -1,20 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Whois::Record::Part do
|
4
|
-
|
5
6
|
describe "#initialize" do
|
6
7
|
it "accepts an empty value" do
|
7
8
|
expect {
|
8
9
|
instance = described_class.new
|
9
10
|
expect(instance.body).to be_nil
|
10
|
-
}.
|
11
|
+
}.not_to raise_error
|
11
12
|
end
|
12
13
|
|
13
14
|
it "accepts an empty hash" do
|
14
15
|
expect {
|
15
16
|
instance = described_class.new({})
|
16
17
|
expect(instance.body).to be_nil
|
17
|
-
}.
|
18
|
+
}.not_to raise_error
|
18
19
|
end
|
19
20
|
|
20
21
|
it "initializes a new instance from given hash" do
|
@@ -34,5 +35,4 @@ describe Whois::Record::Part do
|
|
34
35
|
expect(instance.host).to eq("whois.example.test")
|
35
36
|
end
|
36
37
|
end
|
37
|
-
|
38
38
|
end
|