async-dns 1.2.1 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/dns/extensions/resolv.rb +1 -2
- data/lib/async/dns/handler.rb +11 -9
- data/lib/async/dns/resolver.rb +6 -4
- data/lib/async/dns/server.rb +1 -1
- data/lib/async/dns/transport.rb +27 -51
- data/lib/async/dns/version.rb +1 -1
- metadata +50 -75
- data/.editorconfig +0 -6
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.travis.yml +0 -27
- data/Gemfile +0 -18
- data/README.md +0 -148
- data/Rakefile +0 -32
- data/async-dns.gemspec +0 -31
- data/examples/cloudflare.rb +0 -24
- data/spec/async/dns/handler_spec.rb +0 -60
- data/spec/async/dns/hosts.txt +0 -2
- data/spec/async/dns/ipv6_spec.rb +0 -78
- data/spec/async/dns/junk_server_context.rb +0 -62
- data/spec/async/dns/message_spec.rb +0 -56
- data/spec/async/dns/origin_spec.rb +0 -106
- data/spec/async/dns/replace_spec.rb +0 -44
- data/spec/async/dns/resolver_performance_spec.rb +0 -108
- data/spec/async/dns/resolver_spec.rb +0 -104
- data/spec/async/dns/server/bind9/generate-local.rb +0 -25
- data/spec/async/dns/server/bind9/local.zone +0 -5014
- data/spec/async/dns/server/bind9/named.conf +0 -14
- data/spec/async/dns/server/bind9/named.run +0 -0
- data/spec/async/dns/server/million.rb +0 -83
- data/spec/async/dns/server_performance_spec.rb +0 -159
- data/spec/async/dns/slow_server_spec.rb +0 -97
- data/spec/async/dns/socket_spec.rb +0 -72
- data/spec/async/dns/system_spec.rb +0 -57
- data/spec/async/dns/transaction_spec.rb +0 -140
- data/spec/async/dns/truncation_spec.rb +0 -61
- data/spec/spec_helper.rb +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea5c9c51849ba12863030e14261a5475bfa1d1ab52e39a2c845dafdf277683d7
|
4
|
+
data.tar.gz: ac45a456ef1cc82a2bd01046a549e37cb72908c42d5429bc6d6818b02ae63845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b673b004c18bd79e2cea44fe66e3236e0843d3ad46ed68cec7db26302f6baa34593ae62f7f0eb826be87abe518bdb0c21035098881224aa4132239cc66091e4d
|
7
|
+
data.tar.gz: 46a55367035e353d9494cba6433bbd063c01d96675de811af4f5f6fa98d499b1e0e3cb3f0edf7773af34742c799308d5767abcd53a4002658e4f8de11eda04eb
|
@@ -26,7 +26,7 @@ class Resolv
|
|
26
26
|
# Merge the given message with this message. A number of heuristics are applied in order to ensure that the result makes sense. For example, If the current message is not recursive but is being merged with a message that was recursive, this bit is maintained. If either message is authoritive, then the result is also authoritive.
|
27
27
|
#
|
28
28
|
# Modifies the current message in place.
|
29
|
-
def merge!
|
29
|
+
def merge!(other)
|
30
30
|
# Authoritive Answer
|
31
31
|
@aa = @aa && other.aa
|
32
32
|
|
@@ -67,7 +67,6 @@ class Resolv
|
|
67
67
|
return self.class.new(@labels + origin, absolute)
|
68
68
|
end
|
69
69
|
|
70
|
-
|
71
70
|
# Return the name, typically relative, without the specified origin suffix. If the origin is nil, don't change the name, but change it to absolute (as specified).
|
72
71
|
def without_origin(origin, absolute = false)
|
73
72
|
return self.class.new(@labels, absolute) if origin == nil
|
data/lib/async/dns/handler.rb
CHANGED
@@ -18,6 +18,8 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
require 'async/io/stream'
|
22
|
+
|
21
23
|
require_relative 'transport'
|
22
24
|
|
23
25
|
module Async::DNS
|
@@ -26,7 +28,7 @@ module Async::DNS
|
|
26
28
|
@server = server
|
27
29
|
@socket = socket
|
28
30
|
|
29
|
-
@logger = @server.logger ||
|
31
|
+
@logger = @server.logger || Console.logger
|
30
32
|
end
|
31
33
|
|
32
34
|
attr :server
|
@@ -57,8 +59,7 @@ module Async::DNS
|
|
57
59
|
|
58
60
|
return @server.process_query(query, options)
|
59
61
|
rescue StandardError => error
|
60
|
-
@logger.error
|
61
|
-
Async::DNS::log_exception(@logger, error)
|
62
|
+
@logger.error(self, error)
|
62
63
|
|
63
64
|
return error_response(query)
|
64
65
|
end
|
@@ -114,13 +115,14 @@ module Async::DNS
|
|
114
115
|
end
|
115
116
|
|
116
117
|
def handle_connection(socket)
|
117
|
-
|
118
|
-
|
119
|
-
response = process_query(input_data, remote_address: socket.remote_address)
|
120
|
-
|
121
|
-
length = StreamTransport.write_message(socket, response)
|
118
|
+
transport = Transport.new(socket)
|
122
119
|
|
123
|
-
|
120
|
+
while input_data = transport.read_chunk
|
121
|
+
response = process_query(input_data, remote_address: socket.remote_address)
|
122
|
+
length = transport.write_message(response)
|
123
|
+
|
124
|
+
@logger.debug "<#{response.id}> Wrote #{length} bytes via TCP..."
|
125
|
+
end
|
124
126
|
rescue EOFError => error
|
125
127
|
@logger.warn "<> Error: TCP session ended prematurely!"
|
126
128
|
rescue Errno::ECONNRESET => error
|
data/lib/async/dns/resolver.rb
CHANGED
@@ -46,7 +46,7 @@ module Async::DNS
|
|
46
46
|
# Servers are specified in the same manor as options[:listen], e.g.
|
47
47
|
# [:tcp/:udp, address, port]
|
48
48
|
# In the case of multiple servers, they will be checked in sequence.
|
49
|
-
def initialize(endpoints, origin: nil, logger:
|
49
|
+
def initialize(endpoints, origin: nil, logger: Console.logger, timeout: DEFAULT_TIMEOUT)
|
50
50
|
@endpoints = endpoints
|
51
51
|
|
52
52
|
@origin = origin
|
@@ -203,7 +203,7 @@ module Async::DNS
|
|
203
203
|
elsif response.id != message.id
|
204
204
|
@logger.warn "[#{message.id}] Received response with incorrect message id: #{response.id}!" if @logger
|
205
205
|
else
|
206
|
-
@logger.debug "[#{message.id}] Received valid response with #{response.answer.
|
206
|
+
@logger.debug "[#{message.id}] Received valid response with #{response.answer.size} answer(s)." if @logger
|
207
207
|
|
208
208
|
return true
|
209
209
|
end
|
@@ -220,9 +220,11 @@ module Async::DNS
|
|
220
220
|
end
|
221
221
|
|
222
222
|
def try_stream_server(request, socket)
|
223
|
-
|
223
|
+
transport = Transport.new(socket)
|
224
224
|
|
225
|
-
|
225
|
+
transport.write_chunk(request.packet)
|
226
|
+
|
227
|
+
input_data = transport.read_chunk
|
226
228
|
|
227
229
|
return Async::DNS::decode_message(input_data)
|
228
230
|
end
|
data/lib/async/dns/server.rb
CHANGED
@@ -36,7 +36,7 @@ module Async::DNS
|
|
36
36
|
# end
|
37
37
|
# end
|
38
38
|
#
|
39
|
-
def initialize(endpoints = DEFAULT_ENDPOINTS, origin: '.', logger:
|
39
|
+
def initialize(endpoints = DEFAULT_ENDPOINTS, origin: '.', logger: Console.logger)
|
40
40
|
@endpoints = endpoints
|
41
41
|
@origin = origin
|
42
42
|
@logger = logger
|
data/lib/async/dns/transport.rb
CHANGED
@@ -23,64 +23,40 @@ require 'ipaddr'
|
|
23
23
|
|
24
24
|
require_relative 'message'
|
25
25
|
|
26
|
-
module Async
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# A helper class for processing incoming network data.
|
32
|
-
class BinaryStringIO < StringIO
|
33
|
-
def initialize
|
34
|
-
super
|
35
|
-
|
36
|
-
set_encoding("BINARY")
|
26
|
+
module Async
|
27
|
+
module DNS
|
28
|
+
def self.address_family(host)
|
29
|
+
return IPAddr.new(host).family
|
37
30
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
# The data buffer:
|
43
|
-
buffer = BinaryStringIO.new
|
44
|
-
|
45
|
-
# First we need to read in the length of the packet
|
46
|
-
while buffer.size < 2
|
47
|
-
if data = socket.read(1)
|
48
|
-
buffer.write data
|
49
|
-
else
|
50
|
-
raise EOFError, "Could not read message size!"
|
51
|
-
end
|
31
|
+
|
32
|
+
class Transport
|
33
|
+
def initialize(socket)
|
34
|
+
@stream = IO::Stream.new(socket)
|
52
35
|
end
|
53
36
|
|
54
|
-
|
55
|
-
|
37
|
+
def write_message(message)
|
38
|
+
write_chunk(message.encode)
|
39
|
+
end
|
56
40
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
buffer.write data
|
64
|
-
else
|
65
|
-
raise EOFError, "Could not read message data!"
|
41
|
+
def read_chunk
|
42
|
+
if size_data = @stream.read(2)
|
43
|
+
# Read in the length, the first two bytes:
|
44
|
+
size = size_data.unpack('n')[0]
|
45
|
+
|
46
|
+
return @stream.read(size)
|
66
47
|
end
|
67
48
|
end
|
68
49
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
# TODO: Validate/check for data written correctly
|
80
|
-
count = socket.write(size_data)
|
81
|
-
count = socket.write(output_data)
|
82
|
-
|
83
|
-
return output_data.bytesize
|
50
|
+
def write_chunk(output_data)
|
51
|
+
size_data = [output_data.bytesize].pack('n')
|
52
|
+
|
53
|
+
@stream.write(size_data)
|
54
|
+
@stream.write(output_data)
|
55
|
+
|
56
|
+
@stream.flush
|
57
|
+
|
58
|
+
return output_data.bytesize
|
59
|
+
end
|
84
60
|
end
|
85
61
|
end
|
86
62
|
end
|
data/lib/async/dns/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-dns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-io
|
@@ -39,21 +39,21 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: covered
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -66,51 +66,68 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: process-daemon
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
89
|
+
version: '3.0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
96
|
+
version: '3.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: rspec-files
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - "
|
101
|
+
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
103
|
+
version: '1.0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - "
|
108
|
+
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
|
98
|
-
|
110
|
+
version: '1.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec-memory
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.0'
|
125
|
+
description:
|
99
126
|
email:
|
100
|
-
- samuel.williams@oriontransfer.co.nz
|
101
127
|
executables: []
|
102
128
|
extensions: []
|
103
129
|
extra_rdoc_files: []
|
104
130
|
files:
|
105
|
-
- ".editorconfig"
|
106
|
-
- ".gitignore"
|
107
|
-
- ".rspec"
|
108
|
-
- ".travis.yml"
|
109
|
-
- Gemfile
|
110
|
-
- README.md
|
111
|
-
- Rakefile
|
112
|
-
- async-dns.gemspec
|
113
|
-
- examples/cloudflare.rb
|
114
131
|
- lib/async/dns.rb
|
115
132
|
- lib/async/dns/chunked.rb
|
116
133
|
- lib/async/dns/extensions/resolv.rb
|
@@ -124,32 +141,11 @@ files:
|
|
124
141
|
- lib/async/dns/transaction.rb
|
125
142
|
- lib/async/dns/transport.rb
|
126
143
|
- lib/async/dns/version.rb
|
127
|
-
|
128
|
-
- spec/async/dns/hosts.txt
|
129
|
-
- spec/async/dns/ipv6_spec.rb
|
130
|
-
- spec/async/dns/junk_server_context.rb
|
131
|
-
- spec/async/dns/message_spec.rb
|
132
|
-
- spec/async/dns/origin_spec.rb
|
133
|
-
- spec/async/dns/replace_spec.rb
|
134
|
-
- spec/async/dns/resolver_performance_spec.rb
|
135
|
-
- spec/async/dns/resolver_spec.rb
|
136
|
-
- spec/async/dns/server/bind9/generate-local.rb
|
137
|
-
- spec/async/dns/server/bind9/local.zone
|
138
|
-
- spec/async/dns/server/bind9/named.conf
|
139
|
-
- spec/async/dns/server/bind9/named.run
|
140
|
-
- spec/async/dns/server/million.rb
|
141
|
-
- spec/async/dns/server_performance_spec.rb
|
142
|
-
- spec/async/dns/slow_server_spec.rb
|
143
|
-
- spec/async/dns/socket_spec.rb
|
144
|
-
- spec/async/dns/system_spec.rb
|
145
|
-
- spec/async/dns/transaction_spec.rb
|
146
|
-
- spec/async/dns/truncation_spec.rb
|
147
|
-
- spec/spec_helper.rb
|
148
|
-
homepage: https://github.com/async/async-dns
|
144
|
+
homepage: https://github.com/socketry/async-dns
|
149
145
|
licenses:
|
150
146
|
- MIT
|
151
147
|
metadata: {}
|
152
|
-
post_install_message:
|
148
|
+
post_install_message:
|
153
149
|
rdoc_options: []
|
154
150
|
require_paths:
|
155
151
|
- lib
|
@@ -164,29 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
160
|
- !ruby/object:Gem::Version
|
165
161
|
version: '0'
|
166
162
|
requirements: []
|
167
|
-
rubygems_version: 3.
|
168
|
-
signing_key:
|
163
|
+
rubygems_version: 3.2.3
|
164
|
+
signing_key:
|
169
165
|
specification_version: 4
|
170
166
|
summary: An easy to use DNS client resolver and server for Ruby.
|
171
|
-
test_files:
|
172
|
-
- spec/async/dns/handler_spec.rb
|
173
|
-
- spec/async/dns/hosts.txt
|
174
|
-
- spec/async/dns/ipv6_spec.rb
|
175
|
-
- spec/async/dns/junk_server_context.rb
|
176
|
-
- spec/async/dns/message_spec.rb
|
177
|
-
- spec/async/dns/origin_spec.rb
|
178
|
-
- spec/async/dns/replace_spec.rb
|
179
|
-
- spec/async/dns/resolver_performance_spec.rb
|
180
|
-
- spec/async/dns/resolver_spec.rb
|
181
|
-
- spec/async/dns/server/bind9/generate-local.rb
|
182
|
-
- spec/async/dns/server/bind9/local.zone
|
183
|
-
- spec/async/dns/server/bind9/named.conf
|
184
|
-
- spec/async/dns/server/bind9/named.run
|
185
|
-
- spec/async/dns/server/million.rb
|
186
|
-
- spec/async/dns/server_performance_spec.rb
|
187
|
-
- spec/async/dns/slow_server_spec.rb
|
188
|
-
- spec/async/dns/socket_spec.rb
|
189
|
-
- spec/async/dns/system_spec.rb
|
190
|
-
- spec/async/dns/transaction_spec.rb
|
191
|
-
- spec/async/dns/truncation_spec.rb
|
192
|
-
- spec/spec_helper.rb
|
167
|
+
test_files: []
|
data/.editorconfig
DELETED
data/.gitignore
DELETED
data/.rspec
DELETED