whois 6.0.0 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +1 -0
- data/.rubocop_todo.yml +11 -87
- data/CHANGELOG.md +7 -0
- data/bin/whoisrb +3 -3
- data/data/tld.json +2 -769
- data/lib/whois/client.rb +1 -1
- data/lib/whois/record.rb +1 -1
- data/lib/whois/server/adapters/arpa.rb +3 -5
- data/lib/whois/server/adapters/base.rb +3 -3
- data/lib/whois/server/adapters/none.rb +1 -1
- data/lib/whois/server/adapters/not_implemented.rb +1 -1
- data/lib/whois/server/adapters/web.rb +1 -1
- data/lib/whois/server/socket_handler.rb +3 -3
- data/lib/whois/server.rb +5 -5
- data/lib/whois/version.rb +1 -1
- data/lib/whois.rb +18 -18
- data/spec/integration/whois_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- data/spec/whois/client_spec.rb +1 -1
- data/spec/whois/record/part_spec.rb +1 -1
- data/spec/whois/record_spec.rb +26 -18
- data/spec/whois/server/adapters/afilias_spec.rb +1 -1
- data/spec/whois/server/adapters/arin_spec.rb +1 -1
- data/spec/whois/server/adapters/arpa_spec.rb +2 -2
- data/spec/whois/server/adapters/base_spec.rb +17 -12
- data/spec/whois/server/adapters/formatted_spec.rb +1 -1
- data/spec/whois/server/adapters/none_spec.rb +1 -1
- data/spec/whois/server/adapters/not_implemented_spec.rb +2 -2
- data/spec/whois/server/adapters/standard_spec.rb +1 -1
- data/spec/whois/server/adapters/verisign_spec.rb +1 -1
- data/spec/whois/server/adapters/web_spec.rb +1 -1
- data/spec/whois/server/socket_handler_spec.rb +2 -2
- data/spec/whois/server_spec.rb +51 -51
- data/spec/whois/web_interface_error_spec.rb +1 -1
- data/spec/whois/whois_spec.rb +1 -1
- data/utils/deftld.rb +0 -1
- metadata +3 -3
data/lib/whois/client.rb
CHANGED
data/lib/whois/record.rb
CHANGED
@@ -35,11 +35,9 @@ module Whois
|
|
35
35
|
a, b, c, d = string.scan(/[0-9]{1,3}\./).reverse
|
36
36
|
[a, b, c, d].map do |token|
|
37
37
|
token = (token || 0).to_i
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
raise ServerError, "Invalid .in-addr.arpa token `#{token}'"
|
42
|
-
end
|
38
|
+
raise ServerError, "Invalid .in-addr.arpa token `#{token}'" unless token <= 255 && token >= 0
|
39
|
+
|
40
|
+
token
|
43
41
|
end.join(".")
|
44
42
|
end
|
45
43
|
|
@@ -9,8 +9,8 @@
|
|
9
9
|
#++
|
10
10
|
|
11
11
|
|
12
|
-
require
|
13
|
-
require
|
12
|
+
require "socket"
|
13
|
+
require "whois/errors"
|
14
14
|
|
15
15
|
|
16
16
|
module Whois
|
@@ -58,7 +58,7 @@ module Whois
|
|
58
58
|
client.write("#{query}\r\n") # I could use put(foo) and forget the \n
|
59
59
|
client.read # but write/read is more symmetric than puts/read
|
60
60
|
ensure # and I really want to use read instead of gets.
|
61
|
-
client
|
61
|
+
client&.close # If != client something went wrong.
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/lib/whois/server.rb
CHANGED
@@ -9,8 +9,8 @@
|
|
9
9
|
#++
|
10
10
|
|
11
11
|
|
12
|
-
require
|
13
|
-
require
|
12
|
+
require "ipaddr"
|
13
|
+
require "json"
|
14
14
|
require "whois/server/adapters/base"
|
15
15
|
require "whois/server/adapters/arin"
|
16
16
|
require "whois/server/adapters/arpa"
|
@@ -67,7 +67,7 @@ module Whois
|
|
67
67
|
# @return [void]
|
68
68
|
def load_definitions
|
69
69
|
clear_definitions
|
70
|
-
Dir[File.expand_path(
|
70
|
+
Dir[File.expand_path("../../data/*.json", __dir__)].each { |f| load_json(f) }
|
71
71
|
end
|
72
72
|
|
73
73
|
# Loads the definitions from a JSON file.
|
@@ -283,7 +283,7 @@ module Whois
|
|
283
283
|
# @param string [String]
|
284
284
|
# @raise [Whois::ServerNotSupported]
|
285
285
|
# emails are not supported.
|
286
|
-
def find_for_email(
|
286
|
+
def find_for_email(_string)
|
287
287
|
raise ServerNotSupported, "No WHOIS server is known for email objects"
|
288
288
|
end
|
289
289
|
|
@@ -363,7 +363,7 @@ module Whois
|
|
363
363
|
end
|
364
364
|
|
365
365
|
def matches_email?(string)
|
366
|
-
string.include?(
|
366
|
+
string.include?("@")
|
367
367
|
end
|
368
368
|
|
369
369
|
def matches_asn?(string)
|
data/lib/whois/version.rb
CHANGED
data/lib/whois.rb
CHANGED
@@ -9,11 +9,11 @@
|
|
9
9
|
#++
|
10
10
|
|
11
11
|
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
12
|
+
require "whois/version"
|
13
|
+
require "whois/errors"
|
14
|
+
require "whois/client"
|
15
|
+
require "whois/server"
|
16
|
+
require "whois/record"
|
17
17
|
|
18
18
|
|
19
19
|
module Whois
|
@@ -74,7 +74,7 @@ module Whois
|
|
74
74
|
result
|
75
75
|
end
|
76
76
|
|
77
|
-
def deprecate(message = nil,
|
77
|
+
def deprecate(message = nil, _callstack = caller)
|
78
78
|
# warn("DEPRECATION WARNING: #{message} #{deprecation_caller_message(callstack)}")
|
79
79
|
warn("DEPRECATION WARNING: #{message}")
|
80
80
|
end
|
@@ -99,24 +99,24 @@ module Whois
|
|
99
99
|
|
100
100
|
def deprecation_caller_message(callstack)
|
101
101
|
file, line, method = extract_callstack(callstack)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
102
|
+
return unless file
|
103
|
+
|
104
|
+
if line && method
|
105
|
+
"(called from #{method} at #{file}:#{line})"
|
106
|
+
else
|
107
|
+
"(called from #{file}:#{line})"
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
def extract_callstack(callstack)
|
112
112
|
gem_root = "#{File.expand_path('../..', __dir__)}/"
|
113
113
|
offending_line = callstack.find { |line| !line.start_with?(gem_root) } || callstack.first
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
114
|
+
return unless offending_line
|
115
|
+
|
116
|
+
if (md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/))
|
117
|
+
md.captures
|
118
|
+
else
|
119
|
+
offending_line
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Whois do
|
6
6
|
let(:response) { "Domain: example.it\nStatus: AVAILABLE\n" }
|
@@ -13,7 +13,7 @@ describe Whois do
|
|
13
13
|
.with("example.it", "whois.nic.it", 43)
|
14
14
|
.and_return(response)
|
15
15
|
|
16
|
-
record =
|
16
|
+
record = described_class.lookup("example.it")
|
17
17
|
|
18
18
|
expect(record).to be_a(Whois::Record)
|
19
19
|
# expect(record.available?).to be_truthy
|
data/spec/spec_helper.rb
CHANGED
data/spec/whois/client_spec.rb
CHANGED
data/spec/whois/record_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Whois::Record do
|
6
6
|
subject { described_class.new(server, parts) }
|
@@ -65,64 +65,72 @@ describe Whois::Record do
|
|
65
65
|
one = two = described_class.new(server, parts)
|
66
66
|
|
67
67
|
expect(one == two).to be_truthy
|
68
|
-
expect(one.eql
|
68
|
+
expect(one).to eql(two)
|
69
69
|
end
|
70
70
|
|
71
71
|
it "returns true when other has same class and has the same parts" do
|
72
|
-
one
|
72
|
+
one = described_class.new(server, parts)
|
73
|
+
two = described_class.new(server, parts)
|
73
74
|
|
74
75
|
expect(one == two).to be_truthy
|
75
|
-
expect(one.eql
|
76
|
+
expect(one).to eql(two)
|
76
77
|
end
|
77
78
|
|
78
79
|
it "returns true when other has descendant class and has the same parts" do
|
79
80
|
subklass = Class.new(described_class)
|
80
|
-
one
|
81
|
+
one = described_class.new(server, parts)
|
82
|
+
two = subklass.new(server, parts)
|
81
83
|
|
82
84
|
expect(one == two).to be_truthy
|
83
|
-
expect(one.eql
|
85
|
+
expect(one).to eql(two)
|
84
86
|
end
|
85
87
|
|
86
88
|
it "returns true when other has same class and has equal parts" do
|
87
|
-
one
|
89
|
+
one = described_class.new(server, parts)
|
90
|
+
two = described_class.new(server, parts.dup)
|
88
91
|
|
89
92
|
expect(one == two).to be_truthy
|
90
|
-
expect(one.eql
|
93
|
+
expect(one).to eql(two)
|
91
94
|
end
|
92
95
|
|
93
96
|
it "returns true when other has same class, different server and the same parts" do
|
94
|
-
one
|
97
|
+
one = described_class.new(server, parts)
|
98
|
+
two = described_class.new(nil, parts)
|
95
99
|
|
96
100
|
expect(one == two).to be_truthy
|
97
|
-
expect(one.eql
|
101
|
+
expect(one).to eql(two)
|
98
102
|
end
|
99
103
|
|
100
104
|
it "returns false when other has different class and has the same parts" do
|
101
|
-
one
|
105
|
+
one = described_class.new(server, parts)
|
106
|
+
two = Struct.new(:server, :parts).new(server, parts)
|
102
107
|
|
103
108
|
expect(one == two).to be_falsey
|
104
|
-
expect(one.eql
|
109
|
+
expect(one).not_to eql(two)
|
105
110
|
end
|
106
111
|
|
107
112
|
it "returns false when other has different parts" do
|
108
|
-
one
|
113
|
+
one = described_class.new(server, parts)
|
114
|
+
two = described_class.new(server, [])
|
109
115
|
|
110
116
|
expect(one == two).to be_falsey
|
111
|
-
expect(one.eql
|
117
|
+
expect(one).not_to eql(two)
|
112
118
|
end
|
113
119
|
|
114
120
|
it "returns false when other is string and has the same content" do
|
115
|
-
one
|
121
|
+
one = described_class.new(server, parts)
|
122
|
+
two = described_class.new(server, parts).to_s
|
116
123
|
|
117
124
|
expect(one == two).to be_falsey
|
118
|
-
expect(one.eql
|
125
|
+
expect(one).not_to eql(two)
|
119
126
|
end
|
120
127
|
|
121
128
|
it "returns false when other is string and has different content" do
|
122
|
-
one
|
129
|
+
one = described_class.new(server, parts)
|
130
|
+
two = "different"
|
123
131
|
|
124
132
|
expect(one == two).to be_falsey
|
125
|
-
expect(one.eql
|
133
|
+
expect(one).not_to eql(two)
|
126
134
|
end
|
127
135
|
end
|
128
136
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Whois::Server::Adapters::Base do
|
6
6
|
let(:definition) { [:tld, ".test", "whois.test", { foo: "bar" }] }
|
@@ -36,43 +36,48 @@ describe Whois::Server::Adapters::Base do
|
|
36
36
|
one = two = described_class.new(*definition)
|
37
37
|
|
38
38
|
expect(one == two).to be_truthy
|
39
|
-
expect(one.eql
|
39
|
+
expect(one).to eql(two)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "returns true when other has same class and has the same attributes" do
|
43
|
-
one
|
43
|
+
one = described_class.new(*definition)
|
44
|
+
two = described_class.new(*definition)
|
44
45
|
|
45
46
|
expect(one == two).to be_truthy
|
46
|
-
expect(one.eql
|
47
|
+
expect(one).to eql(two)
|
47
48
|
end
|
48
49
|
|
49
50
|
it "returns true when other has descendant class and has the same attributes" do
|
50
51
|
subklass = Class.new(described_class)
|
51
|
-
one
|
52
|
+
one = described_class.new(*definition)
|
53
|
+
two = subklass.new(*definition)
|
52
54
|
|
53
55
|
expect(one == two).to be_truthy
|
54
|
-
expect(one.eql
|
56
|
+
expect(one).to eql(two)
|
55
57
|
end
|
56
58
|
|
57
59
|
it "returns false when other has different class and has the same attributes" do
|
58
|
-
one
|
60
|
+
one = described_class.new(*definition)
|
61
|
+
two = Struct.new(:type, :allocation, :host, :options).new(*definition)
|
59
62
|
|
60
63
|
expect(one == two).to be_falsey
|
61
|
-
expect(one.eql
|
64
|
+
expect(one).not_to eql(two)
|
62
65
|
end
|
63
66
|
|
64
67
|
it "returns false when other has different attributes" do
|
65
|
-
one
|
68
|
+
one = described_class.new(:tld, ".test", "whois.test")
|
69
|
+
two = described_class.new(:tld, ".cool", "whois.test")
|
66
70
|
|
67
71
|
expect(one == two).to be_falsey
|
68
|
-
expect(one.eql
|
72
|
+
expect(one).not_to eql(two)
|
69
73
|
end
|
70
74
|
|
71
75
|
it "returns false when other has different options" do
|
72
|
-
one
|
76
|
+
one = described_class.new(:tld, ".test", "whois.test")
|
77
|
+
two = described_class.new(:tld, ".test", "whois.test", { foo: "bar" })
|
73
78
|
|
74
79
|
expect(one == two).to be_falsey
|
75
|
-
expect(one.eql
|
80
|
+
expect(one).not_to eql(two)
|
76
81
|
end
|
77
82
|
end
|
78
83
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Whois::Server::Adapters::NotImplemented do
|
6
6
|
before do
|
7
|
-
@definition = [:ipv6, "2001:0000::/32", "teredo", { adapter:
|
7
|
+
@definition = [:ipv6, "2001:0000::/32", "teredo", { adapter: described_class }]
|
8
8
|
end
|
9
9
|
|
10
10
|
|