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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe06cb348414e96cabc7ad81a08d8c030d36d4f95cec538a2a1ca457123d6b58
4
- data.tar.gz: 76e5664c2582c7ebac250e7ae2c0680864ea85f4896eaca76b1f5050f517c934
3
+ metadata.gz: ea5c9c51849ba12863030e14261a5475bfa1d1ab52e39a2c845dafdf277683d7
4
+ data.tar.gz: ac45a456ef1cc82a2bd01046a549e37cb72908c42d5429bc6d6818b02ae63845
5
5
  SHA512:
6
- metadata.gz: d5770a6b12241696f5930240913a15740a6950b94d8be0e0b64a83bc8f86da75c6c26d044e754590a1b8915e5f997c134d07653eaa64ee2177147edefa5f33ef
7
- data.tar.gz: 34916a1a687ecf6fac55bf52a860529e29642043c5e8a35b44a9931ce37c6fc26edab43b6edc664eae5052649bbf133f92a24597f9b757a14feb81deb493c010
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! (other)
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
@@ -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 || Async.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 "<> Error processing request: #{error.inspect}!"
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
- input_data = StreamTransport.read_chunk(socket)
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
- @logger.debug "<#{response.id}> Wrote #{length} bytes via TCP..."
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
@@ -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: Async.logger, timeout: DEFAULT_TIMEOUT)
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.count} answer(s)." if @logger
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
- StreamTransport.write_chunk(socket, request.packet)
223
+ transport = Transport.new(socket)
224
224
 
225
- input_data = StreamTransport.read_chunk(socket)
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
@@ -36,7 +36,7 @@ module Async::DNS
36
36
  # end
37
37
  # end
38
38
  #
39
- def initialize(endpoints = DEFAULT_ENDPOINTS, origin: '.', logger: Async.logger)
39
+ def initialize(endpoints = DEFAULT_ENDPOINTS, origin: '.', logger: Console.logger)
40
40
  @endpoints = endpoints
41
41
  @origin = origin
42
42
  @logger = logger
@@ -23,64 +23,40 @@ require 'ipaddr'
23
23
 
24
24
  require_relative 'message'
25
25
 
26
- module Async::DNS
27
- def self.address_family(host)
28
- return IPAddr.new(host).family
29
- end
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
- end
39
-
40
- module StreamTransport
41
- def self.read_chunk(socket)
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
- # Read in the length, the first two bytes:
55
- length = buffer.string.byteslice(0, 2).unpack('n')[0]
37
+ def write_message(message)
38
+ write_chunk(message.encode)
39
+ end
56
40
 
57
- # Read data until we have the amount specified:
58
- while (buffer.size - 2) < length
59
- required = (2 + length) - buffer.size
60
-
61
- # Read precisely the required amount:
62
- if data = socket.read(required)
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
- return buffer.string.byteslice(2, length)
70
- end
71
-
72
- def self.write_message(socket, message)
73
- write_chunk(socket, message.encode)
74
- end
75
-
76
- def self.write_chunk(socket, output_data)
77
- size_data = [output_data.bytesize].pack('n')
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
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module DNS
23
- VERSION = '1.2.1'
23
+ VERSION = '1.2.6'
24
24
  end
25
25
  end
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.1
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: 2019-01-21 00:00:00.000000000 Z
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: process-daemon
42
+ name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
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: '1.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: bundler
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.6'
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.6'
96
+ version: '3.0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: rake
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
- description: "\t\tAsync::DNS provides a high-performance DNS client resolver and server\n\t\twhich
98
- can be easily integrated into other projects or used as a stand-alone\n\t\tdaemon.\n"
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
- - spec/async/dns/handler_spec.rb
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.0.1
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
@@ -1,6 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
6
-
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- /spec/**/log/
12
-
13
- # rspec failure tracking
14
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --warnings
3
- --require spec_helper