whois 4.0.6 → 6.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +12 -0
- data/.github/dependabot.yml +17 -0
- data/.github/workflows/release.yml +19 -0
- data/.github/workflows/tests.yml +29 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/.rubocop.yml +27 -0
- data/.rubocop_opinionated.yml +115 -0
- data/.rubocop_todo.yml +89 -0
- data/.simplecov +6 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +147 -44
- data/CONTRIBUTING.md +18 -6
- data/Gemfile +8 -0
- data/LICENSE.txt +1 -1
- data/README.md +4 -4
- data/Rakefile +28 -0
- data/SECURITY.md +24 -0
- data/bin/console +1 -0
- data/bin/whoisrb +6 -5
- data/data/ipv4.json +1 -3
- data/data/tld.json +125 -1049
- data/lib/whois/client.rb +5 -7
- data/lib/whois/errors.rb +4 -6
- data/lib/whois/record/part.rb +5 -6
- data/lib/whois/record.rb +5 -8
- data/lib/whois/server/adapters/afilias.rb +4 -5
- data/lib/whois/server/adapters/arin.rb +7 -8
- data/lib/whois/server/adapters/arpa.rb +19 -24
- data/lib/whois/server/adapters/base.rb +29 -46
- data/lib/whois/server/adapters/formatted.rb +4 -6
- data/lib/whois/server/adapters/none.rb +4 -6
- data/lib/whois/server/adapters/not_implemented.rb +4 -6
- data/lib/whois/server/adapters/standard.rb +4 -6
- data/lib/whois/server/adapters/verisign.rb +4 -5
- data/lib/whois/server/adapters/web.rb +4 -6
- data/lib/whois/server/socket_handler.rb +11 -12
- data/lib/whois/server.rb +73 -64
- data/lib/whois/version.rb +4 -2
- data/lib/whois.rb +32 -33
- data/spec/fixtures/referrals/afilias.bz.txt +23 -0
- data/spec/fixtures/referrals/arin_referral_apnic.txt +78 -0
- data/spec/fixtures/referrals/arin_referral_missing.txt +52 -0
- data/spec/fixtures/referrals/arin_referral_ripe.txt +50 -0
- data/spec/fixtures/referrals/arin_referral_rwhois.txt +63 -0
- data/spec/fixtures/referrals/arin_referral_servernap.txt +63 -0
- data/spec/fixtures/referrals/arin_referral_whois.txt +56 -0
- data/spec/fixtures/referrals/crsnic.com.txt +60 -0
- data/spec/fixtures/referrals/crsnic.com_referral.txt +56 -0
- data/spec/fixtures/referrals/crsnic.com_referral_missing.txt +50 -0
- data/spec/integration/whois_spec.rb +73 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/support/helpers/connectivity_helper.rb +15 -0
- data/spec/support/helpers/spec_helper.rb +31 -0
- data/spec/whois/client_spec.rb +143 -0
- data/spec/whois/record/part_spec.rb +38 -0
- data/spec/whois/record_spec.rb +168 -0
- data/spec/whois/server/adapters/afilias_spec.rb +49 -0
- data/spec/whois/server/adapters/arin_spec.rb +83 -0
- data/spec/whois/server/adapters/arpa_spec.rb +29 -0
- data/spec/whois/server/adapters/base_spec.rb +155 -0
- data/spec/whois/server/adapters/formatted_spec.rb +53 -0
- data/spec/whois/server/adapters/none_spec.rb +23 -0
- data/spec/whois/server/adapters/not_implemented_spec.rb +24 -0
- data/spec/whois/server/adapters/standard_spec.rb +42 -0
- data/spec/whois/server/adapters/verisign_spec.rb +60 -0
- data/spec/whois/server/adapters/web_spec.rb +24 -0
- data/spec/whois/server/socket_handler_spec.rb +33 -0
- data/spec/whois/server_spec.rb +302 -0
- data/spec/whois/web_interface_error_spec.rb +23 -0
- data/spec/whois/whois_spec.rb +15 -0
- data/utils/compare-whois.rb +30 -0
- data/utils/deftld.rb +230 -0
- data/utils/defutils.rb +26 -0
- data/utils/fixupd.rb +60 -0
- data/utils/matrix.rb +68 -0
- data/utils/mkwhois.rb +31 -0
- data/whois.gemspec +19 -32
- metadata +58 -11
- data/4.0-Upgrade.md +0 -143
- data/bin/setup +0 -8
data/lib/whois/client.rb
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
|
-
require
|
|
12
|
+
require "timeout"
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
module Whois
|
|
14
|
-
|
|
15
16
|
class Client
|
|
16
|
-
|
|
17
17
|
# The maximum time to run a WHOIS query, expressed in seconds.
|
|
18
18
|
#
|
|
19
19
|
# @return [Fixnum] Timeout value in seconds.
|
|
@@ -88,13 +88,11 @@ module Whois
|
|
|
88
88
|
#
|
|
89
89
|
def lookup(object)
|
|
90
90
|
string = object.to_s.downcase
|
|
91
|
-
Timeout
|
|
91
|
+
Timeout.timeout(timeout) do
|
|
92
92
|
@server = Server.guess(string)
|
|
93
93
|
@server.configure(settings)
|
|
94
94
|
@server.lookup(string)
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
|
-
|
|
98
97
|
end
|
|
99
|
-
|
|
100
98
|
end
|
data/lib/whois/errors.rb
CHANGED
|
@@ -1,14 +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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
module Whois
|
|
11
|
-
|
|
12
13
|
# The base error class for all <tt>Whois</tt> error classes.
|
|
13
14
|
class Error < StandardError
|
|
14
15
|
end
|
|
@@ -69,9 +70,8 @@ module Whois
|
|
|
69
70
|
|
|
70
71
|
# Raised when the class has found a server but it doesn't support the
|
|
71
72
|
# standard WHOIS interface via port 43. This is the case of some
|
|
72
|
-
# specific domains that only provide a web
|
|
73
|
+
# specific domains that only provide a web-based WHOIS interface. (\x01)
|
|
73
74
|
class WebInterfaceError < InterfaceNotSupported
|
|
74
|
-
|
|
75
75
|
# @return [String] The URL of the web-based WHOIS interface.
|
|
76
76
|
attr_reader :url
|
|
77
77
|
|
|
@@ -82,9 +82,7 @@ module Whois
|
|
|
82
82
|
@url = url
|
|
83
83
|
super("This TLD has no WHOIS server, but you can access the WHOIS database at `#{@url}'")
|
|
84
84
|
end
|
|
85
|
-
|
|
86
85
|
end
|
|
87
86
|
|
|
88
87
|
# @!endgroup
|
|
89
|
-
|
|
90
88
|
end
|
data/lib/whois/record/part.rb
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
module Whois
|
|
11
13
|
class Record
|
|
12
|
-
|
|
13
14
|
# A single {Whois::Record} fragment. For instance,
|
|
14
15
|
# in case of *thin server*, a {Whois::Record} can be composed by
|
|
15
16
|
# one or more parts corresponding to all responses
|
|
@@ -20,12 +21,11 @@ module Whois
|
|
|
20
21
|
# @attr [String] body The body containing the WHOIS output.
|
|
21
22
|
# @attr [String] host The host which returned the body.
|
|
22
23
|
#
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
Part = Struct.new(:body, :host) do
|
|
25
25
|
def initialize(*args)
|
|
26
26
|
if args.first.is_a? Hash
|
|
27
27
|
initialize_with_hash(args.first)
|
|
28
|
-
elsif args.
|
|
28
|
+
elsif args.empty?
|
|
29
29
|
super
|
|
30
30
|
else
|
|
31
31
|
raise ArgumentError
|
|
@@ -41,6 +41,5 @@ module Whois
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
|
-
|
|
45
44
|
end
|
|
46
45
|
end
|
data/lib/whois/record.rb
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
|
-
require
|
|
12
|
+
require "whois/record/part"
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
module Whois
|
|
14
|
-
|
|
15
16
|
class Record
|
|
16
|
-
|
|
17
|
-
|
|
18
17
|
# @return [Whois::Server] The server that originated this record.
|
|
19
18
|
attr_reader :server
|
|
20
19
|
|
|
@@ -65,7 +64,7 @@ module Whois
|
|
|
65
64
|
end
|
|
66
65
|
end
|
|
67
66
|
|
|
68
|
-
|
|
67
|
+
alias eql? ==
|
|
69
68
|
|
|
70
69
|
|
|
71
70
|
# Invokes {#match} on record {#content}
|
|
@@ -111,7 +110,5 @@ module Whois
|
|
|
111
110
|
def content
|
|
112
111
|
@content ||= parts.map(&:body).join("\n")
|
|
113
112
|
end
|
|
114
|
-
|
|
115
113
|
end
|
|
116
|
-
|
|
117
114
|
end
|
|
@@ -1,23 +1,23 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
module Whois
|
|
11
13
|
class Server
|
|
12
14
|
module Adapters
|
|
13
|
-
|
|
14
15
|
#
|
|
15
16
|
# = Afilias Adapter
|
|
16
17
|
#
|
|
17
18
|
# Provides ability to query Afilias WHOIS interfaces.
|
|
18
19
|
#
|
|
19
20
|
class Afilias < Base
|
|
20
|
-
|
|
21
21
|
# Executes a WHOIS query to the Afilias WHOIS interface,
|
|
22
22
|
# resolving any intermediate referral,
|
|
23
23
|
# and appends the response to the client buffer.
|
|
@@ -40,12 +40,11 @@ module Whois
|
|
|
40
40
|
|
|
41
41
|
def extract_referral(response)
|
|
42
42
|
return unless (match = response.match(/Registrar WHOIS Server:(.+?)$/))
|
|
43
|
+
|
|
43
44
|
server = match[match.size - 1].strip
|
|
44
45
|
server.empty? ? nil : server
|
|
45
46
|
end
|
|
46
|
-
|
|
47
47
|
end
|
|
48
|
-
|
|
49
48
|
end
|
|
50
49
|
end
|
|
51
50
|
end
|
|
@@ -1,23 +1,23 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
module Whois
|
|
11
13
|
class Server
|
|
12
14
|
module Adapters
|
|
13
|
-
|
|
14
15
|
#
|
|
15
16
|
# = Arin Adapter
|
|
16
17
|
#
|
|
17
18
|
# Provides ability to query Arin WHOIS interfaces.
|
|
18
19
|
#
|
|
19
20
|
class Arin < Base
|
|
20
|
-
|
|
21
21
|
# Executes a WHOIS query to the Arin WHOIS interface,
|
|
22
22
|
# resolving any intermediate referral,
|
|
23
23
|
# and appends the response to the client buffer.
|
|
@@ -38,15 +38,14 @@ module Whois
|
|
|
38
38
|
private
|
|
39
39
|
|
|
40
40
|
def extract_referral(response)
|
|
41
|
-
return unless response =~
|
|
41
|
+
return unless response =~ %r{ReferralServer:\s*r?whois://([\w.-]+)(?::(\d+))?}
|
|
42
|
+
|
|
42
43
|
{
|
|
43
|
-
host:
|
|
44
|
-
port:
|
|
44
|
+
host: Regexp.last_match(1),
|
|
45
|
+
port: Regexp.last_match(2)&.to_i,
|
|
45
46
|
}
|
|
46
47
|
end
|
|
47
|
-
|
|
48
48
|
end
|
|
49
|
-
|
|
50
49
|
end
|
|
51
50
|
end
|
|
52
51
|
end
|
|
@@ -1,18 +1,18 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
module Whois
|
|
11
13
|
class Server
|
|
12
14
|
module Adapters
|
|
13
|
-
|
|
14
15
|
class Arpa < Base
|
|
15
|
-
|
|
16
16
|
def request(string)
|
|
17
17
|
record = Server.guess(inaddr_to_ip(string)).lookup(string)
|
|
18
18
|
part = record.parts.first
|
|
@@ -22,28 +22,23 @@ module Whois
|
|
|
22
22
|
|
|
23
23
|
private
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
end
|
|
42
|
-
end.join(".")
|
|
43
|
-
end
|
|
44
|
-
|
|
25
|
+
# "127.1.168.192.in-addr.arpa" => "192.168.1.127"
|
|
26
|
+
# "1.168.192.in-addr.arpa" => "192.168.1.0"
|
|
27
|
+
# "168.192.in-addr.arpa" => "192.168.0.0"
|
|
28
|
+
# "192.in-addr.arpa" => "192.0.0.0"
|
|
29
|
+
# "in-addr.arpa" => "0.0.0.0"
|
|
30
|
+
def inaddr_to_ip(string)
|
|
31
|
+
raise ServerError, "Invalid .in-addr.arpa address" unless string.match?(/\A([0-9]{1,3}\.?){0,4}in-addr\.arpa\z/)
|
|
32
|
+
|
|
33
|
+
a, b, c, d = string.scan(/[0-9]{1,3}\./).reverse
|
|
34
|
+
[a, b, c, d].map do |token|
|
|
35
|
+
token = (token || 0).to_i
|
|
36
|
+
raise ServerError, "Invalid .in-addr.arpa token `#{token}'" unless token.between?(0, 255)
|
|
37
|
+
|
|
38
|
+
token
|
|
39
|
+
end.join(".")
|
|
40
|
+
end
|
|
45
41
|
end
|
|
46
|
-
|
|
47
42
|
end
|
|
48
43
|
end
|
|
49
44
|
end
|
|
@@ -1,30 +1,29 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
|
-
require
|
|
11
|
-
require
|
|
12
|
-
require
|
|
12
|
+
require "whois/record/part"
|
|
13
|
+
require "whois/record"
|
|
14
|
+
require "whois/server/socket_handler"
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
module Whois
|
|
16
18
|
class Server
|
|
17
19
|
module Adapters
|
|
18
|
-
|
|
19
20
|
class Base
|
|
20
21
|
class << self
|
|
21
22
|
def query_handler
|
|
22
23
|
@query_handler ||= SocketHandler.new
|
|
23
24
|
end
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
@query_handler = handler
|
|
27
|
-
end
|
|
26
|
+
attr_writer :query_handler
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
# Default WHOIS request port.
|
|
@@ -48,15 +47,10 @@ module Whois
|
|
|
48
47
|
attr_reader :buffer
|
|
49
48
|
|
|
50
49
|
|
|
51
|
-
# @param [Symbol] type
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
# @param [
|
|
55
|
-
# The allocation, range or hostname, this server is responsible for.
|
|
56
|
-
# @param [String, nil] host
|
|
57
|
-
# The server hostname. Use nil if unknown or not available.
|
|
58
|
-
# @param [Hash] options Optional adapter properties.
|
|
59
|
-
#
|
|
50
|
+
# @param type [Symbol] the type of WHOIS adapter to define. Known values are :tld, :ipv4, :ipv6,
|
|
51
|
+
# @param allocation [String] the allocation, range or hostname, this server is responsible for.
|
|
52
|
+
# @param host [String, nil] the server hostname. Use nil if unknown or not available.
|
|
53
|
+
# @param options [Hash] optional adapter properties
|
|
60
54
|
def initialize(type, allocation, host, options = {})
|
|
61
55
|
@type = type
|
|
62
56
|
@allocation = allocation
|
|
@@ -66,53 +60,44 @@ module Whois
|
|
|
66
60
|
|
|
67
61
|
# Checks self and other for equality.
|
|
68
62
|
#
|
|
69
|
-
# @param [The Whois::Server::Adapters::Base]
|
|
70
|
-
# @return [Boolean]
|
|
63
|
+
# @param other [The Whois::Server::Adapters::Base]
|
|
64
|
+
# @return [Boolean] true if the other is the same object,
|
|
71
65
|
# or <tt>other</tt> attributes matches this object attributes.
|
|
72
|
-
#
|
|
73
66
|
def ==(other)
|
|
74
|
-
(
|
|
75
|
-
self.equal?(other)
|
|
76
|
-
) || (
|
|
67
|
+
equal?(other) || (
|
|
77
68
|
other.is_a?(self.class) &&
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
type == other.type &&
|
|
70
|
+
allocation == other.allocation &&
|
|
71
|
+
host == other.host &&
|
|
72
|
+
options == other.options
|
|
82
73
|
)
|
|
83
74
|
end
|
|
84
75
|
|
|
85
|
-
|
|
76
|
+
alias eql? ==
|
|
86
77
|
|
|
87
78
|
|
|
88
79
|
# Merges given +settings+ into current {#options}.
|
|
89
80
|
#
|
|
90
|
-
# @param [Hash]
|
|
91
|
-
# @return [Hash]
|
|
92
|
-
#
|
|
81
|
+
# @param settings [Hash]
|
|
82
|
+
# @return [Hash] the updated options for this object
|
|
93
83
|
def configure(settings)
|
|
94
84
|
@host = settings[:host] if settings[:host]
|
|
95
85
|
options.merge!(settings)
|
|
96
86
|
end
|
|
97
87
|
|
|
98
88
|
|
|
99
|
-
# Performs a Whois lookup for <tt>string</tt>
|
|
100
|
-
# using the current server adapter.
|
|
89
|
+
# Performs a Whois lookup for <tt>string</tt> using the current server adapter.
|
|
101
90
|
#
|
|
102
|
-
# Internally, this method calls {#request}
|
|
103
|
-
# using the Template Method design pattern.
|
|
91
|
+
# Internally, this method calls {#request} using the Template Method design pattern.
|
|
104
92
|
#
|
|
105
93
|
# server.lookup("google.com")
|
|
106
94
|
# # => Whois::Record
|
|
107
95
|
#
|
|
108
|
-
# @param [String]
|
|
96
|
+
# @param string [String] the string to query
|
|
109
97
|
# @return [Whois::Record]
|
|
110
|
-
#
|
|
111
98
|
def lookup(string)
|
|
112
|
-
buffer_start
|
|
113
|
-
|
|
114
|
-
Whois::Record.new(self, buffer.dup)
|
|
115
|
-
end
|
|
99
|
+
parts = buffer_start { request(string) }
|
|
100
|
+
Whois::Record.new(self, parts)
|
|
116
101
|
end
|
|
117
102
|
|
|
118
103
|
# Performs the real WHOIS request.
|
|
@@ -121,11 +106,10 @@ module Whois
|
|
|
121
106
|
# it is intended to be overwritten in the concrete subclasses.
|
|
122
107
|
# This is the heart of the Template Method design pattern.
|
|
123
108
|
#
|
|
124
|
-
# @param [String]
|
|
109
|
+
# @param string [String] the string to query
|
|
125
110
|
# @return [void]
|
|
126
111
|
# @raise [NotImplementedError]
|
|
127
112
|
# @abstract
|
|
128
|
-
#
|
|
129
113
|
def request(string)
|
|
130
114
|
raise NotImplementedError
|
|
131
115
|
end
|
|
@@ -149,6 +133,7 @@ module Whois
|
|
|
149
133
|
def buffer_start
|
|
150
134
|
@buffer ||= []
|
|
151
135
|
yield(@buffer)
|
|
136
|
+
@buffer.dup
|
|
152
137
|
ensure
|
|
153
138
|
@buffer.clear
|
|
154
139
|
end
|
|
@@ -183,10 +168,8 @@ module Whois
|
|
|
183
168
|
self.class.query_handler.call(query, *args)
|
|
184
169
|
end
|
|
185
170
|
|
|
186
|
-
alias
|
|
187
|
-
|
|
171
|
+
alias query_the_socket query
|
|
188
172
|
end
|
|
189
|
-
|
|
190
173
|
end
|
|
191
174
|
end
|
|
192
175
|
end
|
|
@@ -1,16 +1,17 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
module Whois
|
|
11
13
|
class Server
|
|
12
14
|
module Adapters
|
|
13
|
-
|
|
14
15
|
#
|
|
15
16
|
# = Formatted Adapter
|
|
16
17
|
#
|
|
@@ -32,7 +33,6 @@ module Whois
|
|
|
32
33
|
# @see Whois::Server::Adapters::Standard
|
|
33
34
|
#
|
|
34
35
|
class Formatted < Base
|
|
35
|
-
|
|
36
36
|
# Executes a WHOIS query to the WHOIS interface
|
|
37
37
|
# listening at +host+ and appends the response
|
|
38
38
|
# to the client buffer.
|
|
@@ -47,12 +47,10 @@ module Whois
|
|
|
47
47
|
#
|
|
48
48
|
def request(string)
|
|
49
49
|
options[:format] || raise(ServerError, "Missing mandatory :format option for adapter `Formatted'")
|
|
50
|
-
response = query_the_socket(
|
|
50
|
+
response = query_the_socket(format(options[:format], string), host)
|
|
51
51
|
buffer_append response, host
|
|
52
52
|
end
|
|
53
|
-
|
|
54
53
|
end
|
|
55
|
-
|
|
56
54
|
end
|
|
57
55
|
end
|
|
58
56
|
end
|
|
@@ -1,16 +1,17 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
module Whois
|
|
11
13
|
class Server
|
|
12
14
|
module Adapters
|
|
13
|
-
|
|
14
15
|
#
|
|
15
16
|
# = None Adapter
|
|
16
17
|
#
|
|
@@ -26,7 +27,6 @@ module Whois
|
|
|
26
27
|
# adapter raises a {Whois::NoInterfaceError} exception.
|
|
27
28
|
#
|
|
28
29
|
class None < Base
|
|
29
|
-
|
|
30
30
|
# Always raises a {Whois::NoInterfaceError} exception.
|
|
31
31
|
#
|
|
32
32
|
# @param [String] string
|
|
@@ -34,12 +34,10 @@ module Whois
|
|
|
34
34
|
#
|
|
35
35
|
# @raise [Whois::NoInterfaceError] For every request.
|
|
36
36
|
#
|
|
37
|
-
def request(
|
|
37
|
+
def request(_string)
|
|
38
38
|
raise NoInterfaceError, "This `#{type}' has no whois server"
|
|
39
39
|
end
|
|
40
|
-
|
|
41
40
|
end
|
|
42
|
-
|
|
43
41
|
end
|
|
44
42
|
end
|
|
45
43
|
end
|
|
@@ -1,18 +1,18 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
module Whois
|
|
11
13
|
class Server
|
|
12
14
|
module Adapters
|
|
13
|
-
|
|
14
15
|
class NotImplemented < Base
|
|
15
|
-
|
|
16
16
|
# Always raises a {Whois::ServerNotImplemented} exception.
|
|
17
17
|
#
|
|
18
18
|
# @param [String] string
|
|
@@ -20,12 +20,10 @@ module Whois
|
|
|
20
20
|
#
|
|
21
21
|
# @raise [Whois::ServerNotImplemented] For every request.
|
|
22
22
|
#
|
|
23
|
-
def request(
|
|
23
|
+
def request(_string)
|
|
24
24
|
raise ServerNotImplemented, "The `#{host}' feature has not been implemented yet."
|
|
25
25
|
end
|
|
26
|
-
|
|
27
26
|
end
|
|
28
|
-
|
|
29
27
|
end
|
|
30
28
|
end
|
|
31
29
|
end
|
|
@@ -1,16 +1,17 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
module Whois
|
|
11
13
|
class Server
|
|
12
14
|
module Adapters
|
|
13
|
-
|
|
14
15
|
#
|
|
15
16
|
# = Standard Adapter
|
|
16
17
|
#
|
|
@@ -36,7 +37,6 @@ module Whois
|
|
|
36
37
|
# * +:port+ - Specifies a port number different than 43
|
|
37
38
|
#
|
|
38
39
|
class Standard < Base
|
|
39
|
-
|
|
40
40
|
# Executes a WHOIS query to the WHOIS interface
|
|
41
41
|
# listening at +host+ and appends the response
|
|
42
42
|
# to the client buffer.
|
|
@@ -51,9 +51,7 @@ module Whois
|
|
|
51
51
|
response = query_the_socket(string, host)
|
|
52
52
|
buffer_append response, host
|
|
53
53
|
end
|
|
54
|
-
|
|
55
54
|
end
|
|
56
|
-
|
|
57
55
|
end
|
|
58
56
|
end
|
|
59
|
-
end
|
|
57
|
+
end
|
|
@@ -1,23 +1,23 @@
|
|
|
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-2024 Simone Carletti <weppos@weppos.net>
|
|
7
9
|
#++
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
module Whois
|
|
11
13
|
class Server
|
|
12
14
|
module Adapters
|
|
13
|
-
|
|
14
15
|
#
|
|
15
16
|
# = Verisign Adapter
|
|
16
17
|
#
|
|
17
18
|
# Provides ability to query Verisign WHOIS interfaces.
|
|
18
19
|
#
|
|
19
20
|
class Verisign < Base
|
|
20
|
-
|
|
21
21
|
# Executes a WHOIS query to the Verisign WHOIS interface,
|
|
22
22
|
# resolving any intermediate referral,
|
|
23
23
|
# and appends the response to the client buffer.
|
|
@@ -40,12 +40,11 @@ module Whois
|
|
|
40
40
|
|
|
41
41
|
def extract_referral(response)
|
|
42
42
|
return unless (match = response.match(/Registrar WHOIS Server:(.+?)$/))
|
|
43
|
+
|
|
43
44
|
server = match[match.size - 1].strip
|
|
44
45
|
server.empty? ? nil : server
|
|
45
46
|
end
|
|
46
|
-
|
|
47
47
|
end
|
|
48
|
-
|
|
49
48
|
end
|
|
50
49
|
end
|
|
51
50
|
end
|