dnsruby 1.57.0 → 1.58.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/.travis.yml +1 -1
- data/README.md +2 -2
- data/RELEASE_NOTES.md +16 -0
- data/Rakefile +2 -0
- data/dnsruby.gemspec +2 -0
- data/lib/dnsruby.rb +5 -0
- data/lib/dnsruby/bit_mapping.rb +138 -0
- data/lib/dnsruby/bitmap.rb +108 -0
- data/lib/dnsruby/message/decoder.rb +90 -80
- data/lib/dnsruby/message/message.rb +16 -3
- data/lib/dnsruby/message/section.rb +3 -3
- data/lib/dnsruby/name.rb +2 -2
- data/lib/dnsruby/packet_sender.rb +73 -1
- data/lib/dnsruby/resolv.rb +56 -42
- data/lib/dnsruby/resolver.rb +95 -73
- data/lib/dnsruby/resource/GPOS.rb +9 -3
- data/lib/dnsruby/resource/HIP.rb +1 -1
- data/lib/dnsruby/resource/IN.rb +3 -1
- data/lib/dnsruby/resource/NAPTR.rb +2 -2
- data/lib/dnsruby/resource/NSEC3.rb +2 -2
- data/lib/dnsruby/resource/NXT.rb +302 -0
- data/lib/dnsruby/resource/OPT.rb +2 -2
- data/lib/dnsruby/resource/TXT.rb +2 -2
- data/lib/dnsruby/resource/generic.rb +1 -0
- data/lib/dnsruby/resource/type_bitmap.rb +0 -0
- data/lib/dnsruby/select_thread.rb +174 -83
- data/lib/dnsruby/single_resolver.rb +2 -2
- data/lib/dnsruby/version.rb +1 -1
- data/lib/dnsruby/zone_reader.rb +19 -9
- data/lib/dnsruby/zone_transfer.rb +1 -1
- data/test/spec_helper.rb +9 -1
- data/test/tc_axfr.rb +17 -4
- data/test/tc_gpos.rb +3 -3
- data/test/tc_message.rb +7 -1
- data/test/tc_nxt.rb +192 -0
- data/test/tc_recur.rb +2 -1
- data/test/tc_resolv.rb +73 -0
- data/test/tc_resolver.rb +22 -4
- data/test/tc_rr-opt.rb +9 -8
- data/test/tc_rr.rb +22 -0
- data/test/tc_single_resolver.rb +15 -15
- data/test/tc_soak.rb +154 -65
- data/test/tc_soak_base.rb +15 -15
- data/test/tc_tcp.rb +1 -1
- data/test/tc_tcp_pipelining.rb +203 -0
- data/test/tc_zone_reader.rb +73 -0
- data/test/test_dnsserver.rb +208 -0
- data/test/test_utils.rb +49 -0
- data/test/ts_offline.rb +59 -41
- data/test/ts_online.rb +92 -63
- metadata +40 -3
- data/test/tc_dnsruby.rb +0 -51
data/test/test_utils.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
# Use this in tests in the tests directory with:
|
4
|
+
# require_relative 'test_utils'
|
5
|
+
# include TestUtils
|
6
|
+
|
7
|
+
module Dnsruby
|
8
|
+
module TestUtils
|
9
|
+
|
10
|
+
module_function
|
11
|
+
|
12
|
+
# Asserts that all exceptions whose type are the specified exception class
|
13
|
+
# or one of its subclasses are *not* raised.
|
14
|
+
#
|
15
|
+
# If any other kind of exception is raised, the test throws an exception
|
16
|
+
# (rather than failing).
|
17
|
+
#
|
18
|
+
# The test passes if and only if no exceptions are raised.
|
19
|
+
def assert_not_raised(exception_class, failure_message = nil)
|
20
|
+
begin
|
21
|
+
yield
|
22
|
+
rescue => e
|
23
|
+
if e.is_a?(exception_class)
|
24
|
+
flunk(failure_message || "An exception was not expected but was raised: #{e}")
|
25
|
+
else
|
26
|
+
raise e
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
=begin
|
32
|
+
# This should result in a test failure:
|
33
|
+
def test_target_exception
|
34
|
+
assert_not_raised(ArgumentError, 'ArgumentError') { raise ArgumentError.new }
|
35
|
+
end
|
36
|
+
|
37
|
+
# This should result in a test error:
|
38
|
+
def test_other_exception
|
39
|
+
assert_not_raised(ArgumentError, 'RuntimeError') { raise RuntimeError.new }
|
40
|
+
end
|
41
|
+
|
42
|
+
# This should result in a passed test:
|
43
|
+
def test_no_exception
|
44
|
+
assert_not_raised(ArgumentError, 'No Error') { }
|
45
|
+
end
|
46
|
+
=end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
data/test/ts_offline.rb
CHANGED
@@ -18,46 +18,64 @@ require_relative 'spec_helper'
|
|
18
18
|
|
19
19
|
Dnsruby.log.level = Logger::FATAL
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
21
|
+
# We'll prepend 'tc_' and append '.rb' to these:
|
22
|
+
TESTS = %w(
|
23
|
+
dnskey
|
24
|
+
escapedchars
|
25
|
+
gpos
|
26
|
+
hash
|
27
|
+
header
|
28
|
+
ipseckey
|
29
|
+
message
|
30
|
+
misc
|
31
|
+
name
|
32
|
+
naptr
|
33
|
+
nsec
|
34
|
+
nsec3
|
35
|
+
nsec3param
|
36
|
+
nxt
|
37
|
+
packet
|
38
|
+
packet_unique_push
|
39
|
+
question
|
40
|
+
res_config
|
41
|
+
res_file
|
42
|
+
res_opt
|
43
|
+
rr
|
44
|
+
rr-txt
|
45
|
+
rr-unknown
|
46
|
+
rrset
|
47
|
+
rrsig
|
48
|
+
tkey
|
49
|
+
update
|
50
|
+
zone_reader
|
51
|
+
)
|
52
|
+
|
53
|
+
# Omitted:
|
54
|
+
#
|
55
|
+
# tc_res_env
|
56
|
+
|
57
|
+
|
58
|
+
TESTS.each { |test| require_relative "tc_#{test}.rb" }
|
59
|
+
|
60
|
+
|
61
|
+
def have_open_ssl?
|
62
|
+
have_open_ssl = true
|
63
|
+
begin
|
64
|
+
require "openssl"
|
65
|
+
OpenSSL::HMAC.digest(OpenSSL::Digest::MD5.new, "key", "data")
|
66
|
+
key = OpenSSL::PKey::RSA.new
|
67
|
+
key.e = 111
|
68
|
+
rescue
|
69
|
+
have_open_ssl = false
|
70
|
+
end
|
71
|
+
have_open_ssl
|
60
72
|
end
|
61
|
-
|
62
|
-
|
73
|
+
|
74
|
+
if have_open_ssl?
|
75
|
+
require_relative 'tc_ds.rb'
|
76
|
+
else
|
77
|
+
puts "-----------------------------------------------------------------------"
|
78
|
+
puts "OpenSSL not present (with full functionality) - skipping DS digest test"
|
79
|
+
puts "-----------------------------------------------------------------------"
|
63
80
|
end
|
81
|
+
|
data/test/ts_online.rb
CHANGED
@@ -17,40 +17,69 @@
|
|
17
17
|
require_relative 'spec_helper'
|
18
18
|
Dnsruby.log.level = Logger::FATAL
|
19
19
|
|
20
|
-
# Disable these tests if we're not online
|
21
20
|
require 'socket'
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
online =
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
21
|
+
|
22
|
+
|
23
|
+
# Tells whether or not we can connect to the Internet.
|
24
|
+
def online?
|
25
|
+
sock = UDPSocket.new()
|
26
|
+
online = false
|
27
|
+
begin
|
28
|
+
sock.connect('193.0.14.129', 25) # that address is k.root-servers.net
|
29
|
+
online = true
|
30
|
+
sock.close
|
31
|
+
rescue Exception => exception
|
32
|
+
puts "
|
33
|
+
------------------------------------------------------------
|
34
|
+
Cannot bind to socket:
|
35
|
+
#{exception}
|
36
|
+
|
37
|
+
This is an indication you have network problems.
|
38
|
+
No online tests will be run!!
|
39
|
+
------------------------------------------------------------
|
40
|
+
"
|
41
|
+
end
|
42
|
+
online
|
35
43
|
end
|
36
|
-
|
44
|
+
|
45
|
+
|
46
|
+
if online?
|
47
|
+
online_tests = %w(
|
48
|
+
axfr
|
49
|
+
hs
|
50
|
+
recur
|
51
|
+
resolv
|
52
|
+
resolver
|
53
|
+
tcp
|
54
|
+
tcp_pipelining
|
55
|
+
)
|
56
|
+
|
57
|
+
# Excluded are:
|
58
|
+
#
|
59
|
+
# inet6
|
60
|
+
# recurse
|
61
|
+
# queue
|
62
|
+
# soak
|
63
|
+
|
37
64
|
# OK - online and ready to go
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
65
|
+
puts '
|
66
|
+
Running online tests. These tests send UDP packets - some may be lost.
|
67
|
+
If you get the odd timeout error with these tests, try running them again.
|
68
|
+
It may just be that some UDP packets got lost the first time...
|
69
|
+
'
|
70
|
+
|
71
|
+
online_tests.each { |test| require_relative("tc_#{test}.rb") }
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
# We have set server_up to unconditionally return false.
|
76
|
+
# Therefore, to avoid any misconception that this code could run,
|
77
|
+
# I'm commenting it out.
|
78
|
+
=begin
|
79
|
+
def server_up?
|
80
|
+
false
|
81
|
+
# Check if we can contact the server - if we can't, then abort the test
|
52
82
|
# (but tell user that test has not been run due to connectivity problems)
|
53
|
-
server_up = false
|
54
83
|
|
55
84
|
# Disabling the attempt to connect to Nominet servers...
|
56
85
|
# begin
|
@@ -65,38 +94,40 @@ if (online)
|
|
65
94
|
# puts "\n\nNo tests targetting this server will be run!!\n\n"
|
66
95
|
# puts "----------------------------------------"
|
67
96
|
# end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
if (server_up)
|
101
|
+
|
102
|
+
require_relative "tc_single_resolver.rb"
|
103
|
+
require_relative "tc_cache.rb"
|
104
|
+
require_relative "tc_dns.rb"
|
105
|
+
require_relative "tc_rr-opt.rb"
|
106
|
+
require_relative "tc_res_config.rb"
|
68
107
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
require_relative "tc_tsig.rb"
|
93
|
-
puts "------------------------------------------------------"
|
94
|
-
puts "Running DNSSEC test - may fail if OpenSSL not complete"
|
95
|
-
puts "------------------------------------------------------"
|
96
|
-
require_relative "tc_verifier.rb"
|
97
|
-
require_relative "tc_dlv.rb"
|
98
|
-
require_relative "tc_validator.rb"
|
99
|
-
end
|
108
|
+
have_openssl = false
|
109
|
+
begin
|
110
|
+
require "openssl"
|
111
|
+
OpenSSL::HMAC.digest(OpenSSL::Digest::MD5.new, "key", "data")
|
112
|
+
key = OpenSSL::PKey::RSA.new
|
113
|
+
key.e = 111
|
114
|
+
|
115
|
+
have_openssl=true
|
116
|
+
rescue Exception => e
|
117
|
+
puts "-------------------------------------------------------------------------"
|
118
|
+
puts "OpenSSL not present (with full functionality) - skipping TSIG/DNSSEC test"
|
119
|
+
puts "-------------------------------------------------------------------------"
|
120
|
+
end
|
121
|
+
if (have_openssl)
|
122
|
+
require_relative "tc_tsig.rb"
|
123
|
+
puts "------------------------------------------------------"
|
124
|
+
puts "Running DNSSEC test - may fail if OpenSSL not complete"
|
125
|
+
puts "------------------------------------------------------"
|
126
|
+
require_relative "tc_verifier.rb"
|
127
|
+
require_relative "tc_dlv.rb"
|
128
|
+
require_relative "tc_validator.rb"
|
129
|
+
end
|
130
|
+
=end
|
100
131
|
|
101
132
|
# have_em = false
|
102
133
|
# begin
|
@@ -112,5 +143,3 @@ if (online)
|
|
112
143
|
# require 'test/tc_event_machine_res.rb'
|
113
144
|
# require 'test/tc_event_machine_deferrable.rb'
|
114
145
|
# end
|
115
|
-
end
|
116
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.58.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dalitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -72,6 +72,34 @@ dependencies:
|
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '5.4'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubydns
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: nio4r
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.1'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '1.1'
|
75
103
|
- !ruby/object:Gem::Dependency
|
76
104
|
name: coveralls
|
77
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +152,8 @@ files:
|
|
124
152
|
- dnsruby.gemspec
|
125
153
|
- lib/dnsruby.rb
|
126
154
|
- lib/dnsruby/DNS.rb
|
155
|
+
- lib/dnsruby/bit_mapping.rb
|
156
|
+
- lib/dnsruby/bitmap.rb
|
127
157
|
- lib/dnsruby/cache.rb
|
128
158
|
- lib/dnsruby/code_mapper.rb
|
129
159
|
- lib/dnsruby/code_mappers.rb
|
@@ -167,6 +197,7 @@ files:
|
|
167
197
|
- lib/dnsruby/resource/NSEC.rb
|
168
198
|
- lib/dnsruby/resource/NSEC3.rb
|
169
199
|
- lib/dnsruby/resource/NSEC3PARAM.rb
|
200
|
+
- lib/dnsruby/resource/NXT.rb
|
170
201
|
- lib/dnsruby/resource/OPT.rb
|
171
202
|
- lib/dnsruby/resource/PX.rb
|
172
203
|
- lib/dnsruby/resource/RP.rb
|
@@ -185,6 +216,7 @@ files:
|
|
185
216
|
- lib/dnsruby/resource/domain_name.rb
|
186
217
|
- lib/dnsruby/resource/generic.rb
|
187
218
|
- lib/dnsruby/resource/resource.rb
|
219
|
+
- lib/dnsruby/resource/type_bitmap.rb
|
188
220
|
- lib/dnsruby/select_thread.rb
|
189
221
|
- lib/dnsruby/single_resolver.rb
|
190
222
|
- lib/dnsruby/single_verifier.rb
|
@@ -202,7 +234,6 @@ files:
|
|
202
234
|
- test/tc_dlv.rb
|
203
235
|
- test/tc_dns.rb
|
204
236
|
- test/tc_dnskey.rb
|
205
|
-
- test/tc_dnsruby.rb
|
206
237
|
- test/tc_ds.rb
|
207
238
|
- test/tc_escapedchars.rb
|
208
239
|
- test/tc_gpos.rb
|
@@ -218,6 +249,7 @@ files:
|
|
218
249
|
- test/tc_nsec.rb
|
219
250
|
- test/tc_nsec3.rb
|
220
251
|
- test/tc_nsec3param.rb
|
252
|
+
- test/tc_nxt.rb
|
221
253
|
- test/tc_packet.rb
|
222
254
|
- test/tc_packet_unique_push.rb
|
223
255
|
- test/tc_question.rb
|
@@ -227,6 +259,7 @@ files:
|
|
227
259
|
- test/tc_res_env.rb
|
228
260
|
- test/tc_res_file.rb
|
229
261
|
- test/tc_res_opt.rb
|
262
|
+
- test/tc_resolv.rb
|
230
263
|
- test/tc_resolver.rb
|
231
264
|
- test/tc_rr-opt.rb
|
232
265
|
- test/tc_rr-txt.rb
|
@@ -239,11 +272,15 @@ files:
|
|
239
272
|
- test/tc_soak_base.rb
|
240
273
|
- test/tc_sshfp.rb
|
241
274
|
- test/tc_tcp.rb
|
275
|
+
- test/tc_tcp_pipelining.rb
|
242
276
|
- test/tc_tkey.rb
|
243
277
|
- test/tc_tsig.rb
|
244
278
|
- test/tc_update.rb
|
245
279
|
- test/tc_validator.rb
|
246
280
|
- test/tc_verifier.rb
|
281
|
+
- test/tc_zone_reader.rb
|
282
|
+
- test/test_dnsserver.rb
|
283
|
+
- test/test_utils.rb
|
247
284
|
- test/ts_dnsruby.rb
|
248
285
|
- test/ts_offline.rb
|
249
286
|
- test/ts_online.rb
|
data/test/tc_dnsruby.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# --
|
2
|
-
# Copyright 2007 Nominet UK
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
# ++
|
16
|
-
|
17
|
-
require_relative 'spec_helper'
|
18
|
-
|
19
|
-
include Dnsruby
|
20
|
-
class TestDnsruby < Minitest::Test
|
21
|
-
def test_dnsruby
|
22
|
-
a = Resolv.getaddress("google-public-dns-a.google.com.")
|
23
|
-
assert_equal(a.to_s, "8.8.8.8")
|
24
|
-
a = Resolv.getaddresses("google-public-dns-a.google.com.")
|
25
|
-
if (a.length == 1)
|
26
|
-
assert(a.length==1, a.to_s + " should only have one response. Had " + a.length.to_s)
|
27
|
-
assert(a.any? {|s| s.to_s == ("8.8.8.8")})
|
28
|
-
Resolv.each_address("google-public-dns-a.google.com.") {|address| assert_equal(address, "8.8.8.8")}
|
29
|
-
else
|
30
|
-
assert(a.length==2, a.to_s + " should have had two responses. Had " + a.length.to_s)
|
31
|
-
assert(a.any? {|s| s.to_s == ("8.8.8.8")})
|
32
|
-
assert(a.any? {|s| s.to_s == ("2001:4860:4860::8888")})
|
33
|
-
Resolv.each_address("google-public-dns-a.google.com.") {|address|
|
34
|
-
assert((address == "8.8.8.8") || (address = "2001:4860:4860::8888")) }
|
35
|
-
end
|
36
|
-
|
37
|
-
n = Resolv.getname("8.8.8.8")
|
38
|
-
assert_equal(n, "google-public-dns-a.google.com")
|
39
|
-
begin
|
40
|
-
ret = Resolv.getname("google-public-dns-a.google.com.")
|
41
|
-
assert(false, ret)
|
42
|
-
rescue Exception => e
|
43
|
-
# assert(e.kind_of?(ResolvError))
|
44
|
-
assert(e.kind_of?(Resolv::ResolvError), "Error was a #{e.class}: #{e}")
|
45
|
-
end
|
46
|
-
n = Resolv.getnames("8.8.8.8")
|
47
|
-
assert(n.length==1)
|
48
|
-
assert_equal(n[0], "google-public-dns-a.google.com")
|
49
|
-
Resolv.each_name("8.8.8.8") {|name| assert_equal(name, "google-public-dns-a.google.com")}
|
50
|
-
end
|
51
|
-
end
|