dnsruby 1.55 → 1.56.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +96 -0
- data/Rakefile +30 -29
- data/demo/axfr.rb +93 -93
- data/demo/check_soa.rb +99 -99
- data/demo/check_zone.rb +59 -59
- data/demo/digdlv.rb +43 -43
- data/demo/digroot.rb +34 -34
- data/demo/example_recurse.rb +14 -14
- data/demo/mresolv.rb +30 -30
- data/demo/mx.rb +31 -31
- data/demo/rubydig.rb +37 -37
- data/demo/to_resolve.txt +3088 -3088
- data/demo/trace_dns.rb +46 -46
- data/lib/dnsruby.rb +161 -526
- data/lib/dnsruby/DNS.rb +305 -0
- data/lib/{Dnsruby/Cache.rb → dnsruby/cache.rb} +152 -152
- data/lib/{Dnsruby → dnsruby}/code_mapper.rb +48 -52
- data/lib/dnsruby/code_mappers.rb +295 -0
- data/lib/{Dnsruby/Config.rb → dnsruby/config.rb} +454 -454
- data/lib/{Dnsruby → dnsruby}/dnssec.rb +91 -91
- data/lib/{Dnsruby/Hosts.rb → dnsruby/hosts.rb} +125 -125
- data/lib/{Dnsruby → dnsruby}/ipv4.rb +26 -26
- data/lib/{Dnsruby → dnsruby}/ipv6.rb +42 -42
- data/lib/{Dnsruby → dnsruby}/key_cache.rb +29 -29
- data/lib/dnsruby/message/decoder.rb +164 -0
- data/lib/dnsruby/message/encoder.rb +75 -0
- data/lib/dnsruby/message/header.rb +249 -0
- data/lib/dnsruby/message/message.rb +629 -0
- data/lib/dnsruby/message/question.rb +86 -0
- data/lib/dnsruby/message/section.rb +96 -0
- data/lib/{Dnsruby → dnsruby}/name.rb +141 -141
- data/lib/dnsruby/packet_sender.rb +661 -0
- data/lib/{Dnsruby/Recursor.rb → dnsruby/recursor.rb} +235 -233
- data/lib/dnsruby/resolv.rb +113 -0
- data/lib/dnsruby/resolver.rb +1192 -0
- data/lib/dnsruby/resource/A.rb +56 -0
- data/lib/dnsruby/resource/AAAA.rb +54 -0
- data/lib/{Dnsruby → dnsruby}/resource/AFSDB.rb +68 -68
- data/lib/{Dnsruby → dnsruby}/resource/CERT.rb +105 -105
- data/lib/{Dnsruby → dnsruby}/resource/DHCID.rb +54 -54
- data/lib/dnsruby/resource/DLV.rb +27 -0
- data/lib/{Dnsruby → dnsruby}/resource/DNSKEY.rb +372 -372
- data/lib/{Dnsruby → dnsruby}/resource/DS.rb +255 -255
- data/lib/{Dnsruby → dnsruby}/resource/HINFO.rb +71 -71
- data/lib/{Dnsruby → dnsruby}/resource/HIP.rb +29 -29
- data/lib/{Dnsruby → dnsruby}/resource/IN.rb +30 -30
- data/lib/{Dnsruby → dnsruby}/resource/IPSECKEY.rb +31 -31
- data/lib/{Dnsruby → dnsruby}/resource/ISDN.rb +62 -62
- data/lib/{Dnsruby → dnsruby}/resource/KX.rb +65 -65
- data/lib/{Dnsruby → dnsruby}/resource/LOC.rb +263 -263
- data/lib/{Dnsruby → dnsruby}/resource/MINFO.rb +69 -69
- data/lib/{Dnsruby → dnsruby}/resource/MX.rb +65 -65
- data/lib/{Dnsruby → dnsruby}/resource/NAPTR.rb +98 -98
- data/lib/{Dnsruby → dnsruby}/resource/NSAP.rb +171 -171
- data/lib/dnsruby/resource/NSEC.rb +275 -0
- data/lib/dnsruby/resource/NSEC3.rb +332 -0
- data/lib/dnsruby/resource/NSEC3PARAM.rb +135 -0
- data/lib/dnsruby/resource/OPT.rb +272 -0
- data/lib/{Dnsruby → dnsruby}/resource/PX.rb +70 -70
- data/lib/{Dnsruby → dnsruby}/resource/RP.rb +75 -75
- data/lib/dnsruby/resource/RR.rb +421 -0
- data/lib/dnsruby/resource/RRSIG.rb +275 -0
- data/lib/dnsruby/resource/RRSet.rb +190 -0
- data/lib/{Dnsruby → dnsruby}/resource/RT.rb +67 -67
- data/lib/{Dnsruby → dnsruby}/resource/SOA.rb +94 -94
- data/lib/dnsruby/resource/SPF.rb +29 -0
- data/lib/dnsruby/resource/SRV.rb +112 -0
- data/lib/{Dnsruby → dnsruby}/resource/SSHFP.rb +14 -14
- data/lib/dnsruby/resource/TKEY.rb +163 -0
- data/lib/dnsruby/resource/TSIG.rb +593 -0
- data/lib/{Dnsruby → dnsruby}/resource/TXT.rb +191 -191
- data/lib/dnsruby/resource/X25.rb +55 -0
- data/lib/{Dnsruby → dnsruby}/resource/domain_name.rb +25 -25
- data/lib/{Dnsruby → dnsruby}/resource/generic.rb +80 -80
- data/lib/dnsruby/resource/resource.rb +25 -0
- data/lib/{Dnsruby → dnsruby}/select_thread.rb +148 -148
- data/lib/{Dnsruby/SingleResolver.rb → dnsruby/single_resolver.rb} +60 -60
- data/lib/{Dnsruby → dnsruby}/single_verifier.rb +344 -344
- data/lib/dnsruby/the_log.rb +44 -0
- data/lib/dnsruby/update.rb +278 -0
- data/lib/dnsruby/validator_thread.rb +124 -0
- data/lib/dnsruby/version.rb +3 -0
- data/lib/{Dnsruby → dnsruby}/zone_reader.rb +93 -93
- data/lib/{Dnsruby → dnsruby}/zone_transfer.rb +377 -377
- data/test/spec_helper.rb +16 -0
- data/test/tc_axfr.rb +31 -34
- data/test/tc_cache.rb +32 -32
- data/test/tc_dlv.rb +28 -28
- data/test/tc_dns.rb +73 -76
- data/test/tc_dnskey.rb +31 -32
- data/test/tc_dnsruby.rb +50 -44
- data/test/tc_ds.rb +36 -36
- data/test/tc_escapedchars.rb +252 -255
- data/test/tc_hash.rb +17 -21
- data/test/tc_header.rb +48 -57
- data/test/tc_hip.rb +19 -22
- data/test/tc_ipseckey.rb +18 -21
- data/test/tc_keith.rb +300 -0
- data/test/tc_message.rb +87 -0
- data/test/tc_misc.rb +83 -87
- data/test/tc_name.rb +81 -84
- data/test/tc_naptr.rb +18 -21
- data/test/tc_nsec.rb +55 -55
- data/test/tc_nsec3.rb +23 -24
- data/test/tc_nsec3param.rb +20 -21
- data/test/tc_packet.rb +90 -93
- data/test/tc_packet_unique_push.rb +48 -51
- data/test/tc_question.rb +30 -33
- data/test/tc_queue.rb +16 -17
- data/test/tc_recur.rb +16 -17
- data/test/tc_res_config.rb +38 -41
- data/test/tc_res_env.rb +29 -32
- data/test/tc_res_file.rb +26 -29
- data/test/tc_res_opt.rb +62 -65
- data/test/tc_resolver.rb +287 -242
- data/test/tc_rr-opt.rb +70 -63
- data/test/tc_rr-txt.rb +68 -71
- data/test/tc_rr-unknown.rb +45 -48
- data/test/tc_rr.rb +76 -70
- data/test/tc_rrset.rb +21 -22
- data/test/tc_rrsig.rb +19 -20
- data/test/tc_single_resolver.rb +294 -297
- data/test/tc_soak.rb +199 -202
- data/test/tc_soak_base.rb +29 -34
- data/test/tc_sshfp.rb +20 -23
- data/test/tc_tcp.rb +32 -35
- data/test/tc_tkey.rb +41 -44
- data/test/tc_tsig.rb +81 -84
- data/test/tc_update.rb +108 -111
- data/test/tc_validator.rb +29 -29
- data/test/tc_verifier.rb +81 -82
- data/test/ts_dnsruby.rb +16 -15
- data/test/ts_offline.rb +62 -63
- data/test/ts_online.rb +115 -115
- metadata +155 -90
- data/README +0 -59
- data/lib/Dnsruby/DNS.rb +0 -305
- data/lib/Dnsruby/PacketSender.rb +0 -656
- data/lib/Dnsruby/Resolver.rb +0 -1189
- data/lib/Dnsruby/TheLog.rb +0 -44
- data/lib/Dnsruby/message.rb +0 -1230
- data/lib/Dnsruby/resource/A.rb +0 -56
- data/lib/Dnsruby/resource/AAAA.rb +0 -54
- data/lib/Dnsruby/resource/DLV.rb +0 -27
- data/lib/Dnsruby/resource/NSEC.rb +0 -298
- data/lib/Dnsruby/resource/NSEC3.rb +0 -340
- data/lib/Dnsruby/resource/NSEC3PARAM.rb +0 -135
- data/lib/Dnsruby/resource/OPT.rb +0 -213
- data/lib/Dnsruby/resource/RRSIG.rb +0 -275
- data/lib/Dnsruby/resource/SPF.rb +0 -29
- data/lib/Dnsruby/resource/SRV.rb +0 -112
- data/lib/Dnsruby/resource/TKEY.rb +0 -163
- data/lib/Dnsruby/resource/TSIG.rb +0 -593
- data/lib/Dnsruby/resource/X25.rb +0 -55
- data/lib/Dnsruby/resource/resource.rb +0 -678
- data/lib/Dnsruby/update.rb +0 -278
- data/lib/Dnsruby/validator_thread.rb +0 -124
data/test/tc_rr.rb
CHANGED
@@ -1,53 +1,50 @@
|
|
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
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
require 'test/unit'
|
21
|
-
require 'dnsruby'
|
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
|
+
|
22
19
|
include Dnsruby
|
23
|
-
class TestRR < Test
|
20
|
+
class TestRR < Minitest::Test
|
24
21
|
def test_rr
|
25
|
-
|
26
|
-
#
|
27
|
-
|
28
|
-
|
22
|
+
# ------------------------------------------------------------------------------
|
23
|
+
# Canned data.
|
24
|
+
# ------------------------------------------------------------------------------
|
25
|
+
|
29
26
|
name = "foo.example.com";
|
30
27
|
klass = "IN";
|
31
28
|
ttl = 43200;
|
32
|
-
|
29
|
+
|
33
30
|
rrs = [
|
34
31
|
{ #[0]
|
35
32
|
:type => Types.A,
|
36
|
-
:address => '10.0.0.1',
|
37
|
-
},
|
33
|
+
:address => '10.0.0.1',
|
34
|
+
},
|
38
35
|
{ #[1]
|
39
36
|
:type => Types::AAAA,
|
40
37
|
:address => '102:304:506:708:90a:b0c:d0e:ff10',
|
41
|
-
},
|
38
|
+
},
|
42
39
|
{ #[2]
|
43
40
|
:type => 'AFSDB',
|
44
41
|
:subtype => 1,
|
45
42
|
:hostname => 'afsdb-hostname.example.com',
|
46
|
-
},
|
43
|
+
},
|
47
44
|
{ #[3]
|
48
45
|
:type => Types.CNAME,
|
49
46
|
:domainname => 'cname-cname.example.com',
|
50
|
-
},
|
47
|
+
},
|
51
48
|
{ #[4]
|
52
49
|
:type => Types.DNAME,
|
53
50
|
:domainname => 'dname.example.com',
|
@@ -56,29 +53,29 @@ class TestRR < Test::Unit::TestCase
|
|
56
53
|
:type => Types.HINFO,
|
57
54
|
:cpu => 'test-cpu',
|
58
55
|
:os => 'test-os',
|
59
|
-
},
|
56
|
+
},
|
60
57
|
{ #[6]
|
61
58
|
:type => Types.ISDN,
|
62
59
|
:address => '987654321',
|
63
60
|
:subaddress => '001',
|
64
|
-
},
|
61
|
+
},
|
65
62
|
{ #[7]
|
66
63
|
:type => Types.MB,
|
67
64
|
:domainname => 'mb-madname.example.com',
|
68
|
-
},
|
65
|
+
},
|
69
66
|
{ #[8]
|
70
67
|
:type => Types.MG,
|
71
68
|
:domainname => 'mg-mgmname.example.com',
|
72
|
-
},
|
69
|
+
},
|
73
70
|
{ #[9]
|
74
71
|
:type => Types.MINFO,
|
75
72
|
:rmailbx => 'minfo-rmailbx.example.com',
|
76
73
|
:emailbx => 'minfo-emailbx.example.com',
|
77
|
-
},
|
74
|
+
},
|
78
75
|
{ #[10]
|
79
76
|
:type => Types.MR,
|
80
77
|
:domainname => 'mr-newname.example.com',
|
81
|
-
},
|
78
|
+
},
|
82
79
|
{ #[11]
|
83
80
|
:type => Types.MX,
|
84
81
|
:preference => 10,
|
@@ -107,14 +104,14 @@ class TestRR < Test::Unit::TestCase
|
|
107
104
|
:area => '0020',
|
108
105
|
:id => '00800a123456',
|
109
106
|
:sel => '00',
|
110
|
-
#
|
111
|
-
#
|
107
|
+
# #:address => '4700580005a001000002000800a12345600'
|
108
|
+
# :address => '47000580005a0000001000002000800a12345600'
|
112
109
|
},
|
113
110
|
{ #[15]
|
114
111
|
:type => Types.PTR,
|
115
112
|
:domainname => 'ptr-ptrdname.example.com',
|
116
113
|
},
|
117
|
-
{ #[16]
|
114
|
+
{ #[16]
|
118
115
|
:type => Types.PX,
|
119
116
|
:preference => 10,
|
120
117
|
:map822 => 'px-map822.example.com',
|
@@ -182,48 +179,48 @@ class TestRR < Test::Unit::TestCase
|
|
182
179
|
:exchange => 'kx-exchange.example.com',
|
183
180
|
},
|
184
181
|
]
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
#
|
189
|
-
|
190
|
-
|
182
|
+
|
183
|
+
|
184
|
+
# ------------------------------------------------------------------------------
|
185
|
+
# Create the packet
|
186
|
+
# ------------------------------------------------------------------------------
|
187
|
+
|
191
188
|
message = Message.new
|
192
189
|
assert(message, 'Message created');
|
193
|
-
|
194
|
-
|
190
|
+
|
191
|
+
|
195
192
|
rrs.each do |data|
|
196
193
|
data.update({ :name => name,
|
197
194
|
:ttl => ttl,
|
198
195
|
})
|
199
196
|
rr=RR.create(data)
|
200
|
-
|
197
|
+
|
201
198
|
message.add_answer(rr);
|
202
199
|
end
|
203
|
-
|
204
|
-
|
205
|
-
#
|
206
|
-
|
200
|
+
|
201
|
+
# ------------------------------------------------------------------------------
|
202
|
+
# Re-create the packet from data.
|
203
|
+
# ------------------------------------------------------------------------------
|
207
204
|
data = message.encode;
|
208
205
|
assert(data, 'Packet has data after pushes');
|
209
|
-
|
206
|
+
|
210
207
|
message=nil;
|
211
208
|
message= Message.decode(data);
|
212
|
-
|
209
|
+
|
213
210
|
assert(message, 'Packet reconstructed from data');
|
214
|
-
|
211
|
+
|
215
212
|
answer = message.answer;
|
216
|
-
|
213
|
+
|
217
214
|
i = 0
|
218
215
|
rrs.each do |rec|
|
219
216
|
ret_rr = answer[i]
|
220
217
|
i += 1
|
221
218
|
rec.each do |key, value|
|
222
|
-
#
|
219
|
+
# method = key+'=?'
|
223
220
|
x = ret_rr.send(key)
|
224
221
|
if (ret_rr.kind_of?RR::CERT and (key == :alg or key == :certtype))
|
225
222
|
assert_equal(value.to_s, x.code.to_s.downcase, "Packet returned wrong answer section for #{ret_rr.to_s}, #{key}")
|
226
|
-
elsif (ret_rr.kind_of?RR::TXT and (key == :strings))
|
223
|
+
elsif (ret_rr.kind_of?RR::TXT and (key == :strings))
|
227
224
|
assert_equal(value.to_s.downcase, x[0].to_s.downcase, "TXT strings wrong")
|
228
225
|
else
|
229
226
|
if (key == :type)
|
@@ -234,25 +231,25 @@ class TestRR < Test::Unit::TestCase
|
|
234
231
|
end
|
235
232
|
end
|
236
233
|
end
|
237
|
-
|
238
|
-
|
239
|
-
|
234
|
+
|
235
|
+
|
236
|
+
|
240
237
|
while (!answer.empty? and !rrs.empty?)
|
241
238
|
data = rrs.shift;
|
242
239
|
rr = answer.shift;
|
243
240
|
type = data[:type];
|
244
|
-
|
245
|
-
assert(rr, "#{type} - RR defined");
|
246
|
-
assert_equal(name, rr.name.to_s, "#{type} - name() correct");
|
241
|
+
|
242
|
+
assert(rr, "#{type} - RR defined");
|
243
|
+
assert_equal(name, rr.name.to_s, "#{type} - name() correct");
|
247
244
|
assert_equal(klass, rr.klass.to_s, "#{type} - class() correct");
|
248
|
-
assert_equal(ttl, rr.ttl, "#{type} - ttl() correct");
|
249
|
-
|
250
|
-
#
|
245
|
+
assert_equal(ttl, rr.ttl, "#{type} - ttl() correct");
|
246
|
+
|
247
|
+
# foreach my $meth (keys %{data}) {
|
251
248
|
data.keys.each do |meth|
|
252
249
|
ret = rr.send(meth)
|
253
250
|
if (rr.kind_of?RR::CERT and (meth == :alg or meth == :certtype))
|
254
251
|
assert_equal(data[meth].to_s, ret.code.to_s.downcase, "#{type} - #{meth}() correct")
|
255
|
-
elsif (rr.kind_of?RR::TXT and (meth == :strings))
|
252
|
+
elsif (rr.kind_of?RR::TXT and (meth == :strings))
|
256
253
|
assert_equal(data[meth].to_s, ret[0].to_s.downcase, "TXT strings wrong")
|
257
254
|
else
|
258
255
|
if (meth == :type)
|
@@ -313,4 +310,13 @@ class TestRR < Test::Unit::TestCase
|
|
313
310
|
assert rr.to_s.index('"Shuttle-ST61G4 Intel PIV3000"')
|
314
311
|
assert rr.to_s.index('"FreeBSD 7.0-STABLE"')
|
315
312
|
end
|
313
|
+
|
314
|
+
def test_private_method_really_private
|
315
|
+
begin
|
316
|
+
RR._get_subclass(nil, nil, nil, nil, nil)
|
317
|
+
raise "This should not have gotten here; the method should have been private"
|
318
|
+
rescue NoMethodError
|
319
|
+
# We should be here because the method should not have been found.
|
320
|
+
end
|
321
|
+
end
|
316
322
|
end
|
data/test/tc_rrset.rb
CHANGED
@@ -1,27 +1,26 @@
|
|
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
|
-
#
|
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
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
|
-
|
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
16
|
|
17
|
-
|
18
|
-
require 'dnsruby'
|
17
|
+
require_relative 'spec_helper'
|
19
18
|
|
20
|
-
class RrsetTest < Test
|
19
|
+
class RrsetTest < Minitest::Test
|
21
20
|
def test_rrset
|
22
21
|
rrset = Dnsruby::RRSet.new
|
23
22
|
|
24
|
-
|
23
|
+
|
25
24
|
rr=Dnsruby::RR.create({ :name => "example.com",
|
26
25
|
:ttl => 3600,
|
27
26
|
:type => 'MX',
|
@@ -34,18 +33,18 @@ class RrsetTest < Test::Unit::TestCase
|
|
34
33
|
rrset.add(rr)
|
35
34
|
rr.preference = 1
|
36
35
|
rrset.add(rr)
|
37
|
-
|
36
|
+
|
38
37
|
canon = rrset.sort_canonical
|
39
|
-
|
38
|
+
|
40
39
|
assert(1 == canon[0].preference)
|
41
40
|
assert(10 == canon[1].preference)
|
42
41
|
assert(12 == canon[2].preference)
|
43
|
-
|
42
|
+
|
44
43
|
assert(rrset.sigs.length == 0)
|
45
44
|
assert(rrset.num_sigs == 0)
|
46
45
|
assert(rrset.rrs.length == 3)
|
47
46
|
|
48
|
-
#
|
47
|
+
# Check RRSIG records (only of the right type) can be added to the RRSet
|
49
48
|
sig = Dnsruby::RR.create({:name=>"example.com", :ttl => 3600,
|
50
49
|
:type => 'RRSIG',
|
51
50
|
:type_covered => 'A',
|
data/test/tc_rrsig.rb
CHANGED
@@ -1,24 +1,23 @@
|
|
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
|
-
#
|
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
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
|
-
|
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
16
|
|
17
|
-
|
18
|
-
require 'dnsruby'
|
17
|
+
require_relative 'spec_helper'
|
19
18
|
|
20
|
-
class RrsigTest < Test
|
21
|
-
INPUT = "host.example.com. 86400 IN RRSIG A 5 3 86400 20030322173103 ( " +
|
19
|
+
class RrsigTest < Minitest::Test
|
20
|
+
INPUT = "host.example.com. 86400 IN RRSIG A 5 3 86400 20030322173103 ( " +
|
22
21
|
"20030220173103 2642 example.com. " +
|
23
22
|
"oJB1W6WNGv+ldvQ3WDG0MQkg5IEhjRip8WTr" +
|
24
23
|
"PYGv07h108dUKGMeDPKijVCHX3DDKdfb+v6o" +
|
@@ -27,7 +26,7 @@ class RrsigTest < Test::Unit::TestCase
|
|
27
26
|
"J5D6fwFm8nN+6pBzeDQfsS3Ap3o= )"
|
28
27
|
def test_rrsig_from_string
|
29
28
|
rrsig = Dnsruby::RR.create(INPUT)
|
30
|
-
|
29
|
+
|
31
30
|
assert_equal(Dnsruby::Types.A, rrsig.type_covered)
|
32
31
|
assert_equal(Dnsruby::Algorithms::RSASHA1, rrsig.algorithm)
|
33
32
|
assert_equal(3, rrsig.labels)
|
@@ -41,7 +40,7 @@ class RrsigTest < Test::Unit::TestCase
|
|
41
40
|
"B9wfuh3DTJXUAfI/M0zmO/zz8bW0Rznl8O3t" +
|
42
41
|
"GNazPwQKkRN20XPXV6nwwfoXmJQbsLNrLfkG" +
|
43
42
|
"J5D6fwFm8nN+6pBzeDQfsS3Ap3o=", ([rrsig.signature].pack("m*")).gsub(/\n/,"").chomp)
|
44
|
-
|
43
|
+
|
45
44
|
rrsig2 = Dnsruby::RR.create(rrsig.to_s)
|
46
45
|
assert(rrsig2.to_s == rrsig.to_s)
|
47
46
|
end
|
data/test/tc_single_resolver.rb
CHANGED
@@ -1,298 +1,295 @@
|
|
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
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
res
|
86
|
-
|
87
|
-
|
88
|
-
res.
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
res.
|
117
|
-
|
118
|
-
msg
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
assert(packet)
|
143
|
-
assert_equal(packet.
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
question
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
assert_equal('IN',
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
res =
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
res =
|
225
|
-
res.src_port
|
226
|
-
|
227
|
-
res.src_port
|
228
|
-
|
229
|
-
res.
|
230
|
-
|
231
|
-
res.
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
#
|
249
|
-
#
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
udpPacket
|
263
|
-
u.
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
tcpPacket.
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
assert(tcpPacket.additional.rrsets('OPT', true)[0].rrs()[0].ttl == udpPacket.additional.rrsets('OPT', true)[0].rrs()[0].ttl, "UDP : #{udpPacket.additional.rrsets('OPT', true)[0].rrs()[0]}, TCP #{tcpPacket.additional.rrsets('OPT', true)[0].rrs()[0]}")
|
296
|
-
|
297
|
-
end
|
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 TestSingleResolver < Minitest::Test
|
21
|
+
Thread::abort_on_exception = true
|
22
|
+
# Dnsruby.log.level=Logger::DEBUG
|
23
|
+
|
24
|
+
def setup
|
25
|
+
Dnsruby::Config.reset
|
26
|
+
end
|
27
|
+
|
28
|
+
Rrs = [
|
29
|
+
{
|
30
|
+
:type => Types.A,
|
31
|
+
:name => 'a.t.dnsruby.validation-test-servers.nominet.org.uk',
|
32
|
+
:address => '10.0.1.128'
|
33
|
+
},
|
34
|
+
{
|
35
|
+
:type => Types::MX,
|
36
|
+
:name => 'mx.t.dnsruby.validation-test-servers.nominet.org.uk',
|
37
|
+
:exchange => 'a.t.dnsruby.validation-test-servers.nominet.org.uk',
|
38
|
+
:preference => 10
|
39
|
+
},
|
40
|
+
{
|
41
|
+
:type => 'CNAME',
|
42
|
+
:name => 'cname.t.dnsruby.validation-test-servers.nominet.org.uk',
|
43
|
+
:domainname => 'a.t.dnsruby.validation-test-servers.nominet.org.uk'
|
44
|
+
},
|
45
|
+
{
|
46
|
+
:type => Types.TXT,
|
47
|
+
:name => 'txt.t.dnsruby.validation-test-servers.nominet.org.uk',
|
48
|
+
:strings => ['Net-DNS']
|
49
|
+
}
|
50
|
+
]
|
51
|
+
|
52
|
+
def test_simple
|
53
|
+
res = SingleResolver.new()
|
54
|
+
m = res.query("a.t.dnsruby.validation-test-servers.nominet.org.uk")
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_timeout
|
58
|
+
# if ((RUBY_PLATFORM=~/darwin/) == nil)
|
59
|
+
# Run a query which will not respond, and check that the timeout works
|
60
|
+
start_time = 0
|
61
|
+
begin
|
62
|
+
udps = UDPSocket.new
|
63
|
+
udps.bind("127.0.0.1", 0)
|
64
|
+
port = *udps.addr.values_at(3,1)
|
65
|
+
|
66
|
+
begin
|
67
|
+
Dnsruby::PacketSender.clear_caches
|
68
|
+
res = SingleResolver.new("127.0.0.1")
|
69
|
+
res.port = port
|
70
|
+
res.packet_timeout=1
|
71
|
+
start_time = Time.now.to_i
|
72
|
+
m = res.query("a.t.dnsruby.validation-test-servers.nominet.org.uk")
|
73
|
+
fail "Got response when should have got none"
|
74
|
+
rescue ResolvTimeout
|
75
|
+
stop_time = Time.now.to_i
|
76
|
+
assert((stop_time - start_time) <= (res.packet_timeout * 2),
|
77
|
+
"UDP timeout too long : #{stop_time - start_time}" +
|
78
|
+
", should be #{res.packet_timeout}")
|
79
|
+
end
|
80
|
+
begin
|
81
|
+
Dnsruby::PacketSender.clear_caches
|
82
|
+
res = SingleResolver.new("127.0.0.1")
|
83
|
+
res.port = port
|
84
|
+
res.use_tcp = true
|
85
|
+
res.packet_timeout=1
|
86
|
+
start_time = Time.now.to_i
|
87
|
+
# TheLog.level = Logger::DEBUG
|
88
|
+
m = res.query("a.t.dnsruby.validation-test-servers.nominet.org.uk")
|
89
|
+
fail "TCP timeouts"
|
90
|
+
rescue ResolvTimeout
|
91
|
+
# print "Got Timeout for TCP\n"
|
92
|
+
stop_time = Time.now.to_i
|
93
|
+
assert((stop_time - start_time) <= (res.packet_timeout * 2),
|
94
|
+
"TCP timeout too long : #{stop_time - start_time}, should be #{res.packet_timeout}")
|
95
|
+
rescue Exception => e
|
96
|
+
fail(e)
|
97
|
+
end
|
98
|
+
TheLog.level = Logger::ERROR
|
99
|
+
rescue
|
100
|
+
udps.close
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_queue_timeout
|
105
|
+
port = 46129
|
106
|
+
# if (!RUBY_PLATFORM=~/darwin/)
|
107
|
+
begin
|
108
|
+
udps = UDPSocket.new
|
109
|
+
udps.bind("127.0.0.1", 0)
|
110
|
+
port = *udps.addr.values_at(3,1)
|
111
|
+
res = SingleResolver.new("127.0.0.1")
|
112
|
+
res.port = port
|
113
|
+
res.packet_timeout=1
|
114
|
+
q = Queue.new
|
115
|
+
msg = Message.new("a.t.dnsruby.validation-test-servers.nominet.org.uk")
|
116
|
+
res.send_async(msg, q, msg)
|
117
|
+
id,ret, error = q.pop
|
118
|
+
assert(id==msg)
|
119
|
+
assert(ret==nil)
|
120
|
+
assert(error.class == ResolvTimeout)
|
121
|
+
rescue
|
122
|
+
udps.close
|
123
|
+
end
|
124
|
+
# end
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_queries
|
128
|
+
res = SingleResolver.new
|
129
|
+
|
130
|
+
Rrs.each do |data|
|
131
|
+
packet=nil
|
132
|
+
2.times do
|
133
|
+
begin
|
134
|
+
packet = res.query(data[:name], data[:type])
|
135
|
+
rescue ResolvTimeout
|
136
|
+
end
|
137
|
+
break if packet
|
138
|
+
end
|
139
|
+
assert(packet)
|
140
|
+
assert_equal(packet.question[0].qclass, 'IN', 'Class correct' )
|
141
|
+
|
142
|
+
assert(packet, "Got an answer for #{data[:name]} IN #{data[:type]}")
|
143
|
+
assert_equal(1, packet.header.qdcount, 'Only one question')
|
144
|
+
assert_equal(1, packet.header.ancount, 'Got single answer')
|
145
|
+
|
146
|
+
question = (packet.question)[0]
|
147
|
+
answer = (packet.answer)[0]
|
148
|
+
|
149
|
+
assert(question, 'Got question' )
|
150
|
+
assert_equal(data[:name], question.qname.to_s, 'Question has right name' )
|
151
|
+
assert_equal(Types.new(data[:type]), question.qtype, 'Question has right type' )
|
152
|
+
assert_equal('IN', question.qclass.string, 'Question has right class')
|
153
|
+
|
154
|
+
assert(answer)
|
155
|
+
assert_equal(answer.klass, 'IN', 'Class correct' )
|
156
|
+
|
157
|
+
|
158
|
+
data.keys.each do |meth|
|
159
|
+
if (meth == :type)
|
160
|
+
assert_equal(Types.new(data[meth]).to_s, answer.send(meth).to_s, "#{meth} correct (#{data[:name]})")
|
161
|
+
else
|
162
|
+
assert_equal(data[meth].to_s, answer.send(meth).to_s, "#{meth} correct (#{data[:name]})")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end # do
|
166
|
+
end # test_queries
|
167
|
+
|
168
|
+
# @TODO@ Although the test_thread_stopped test runs in isolation, it won't run as part
|
169
|
+
# of the whole test suite (ts_dnsruby.rb). Commented out until I can figure out how to
|
170
|
+
# get Test::Unit to run this one sequentially...
|
171
|
+
# def test_thread_stopped
|
172
|
+
# res=SingleResolver.new
|
173
|
+
# # Send a query, and check select_thread running.
|
174
|
+
# m = res.query("example.com")
|
175
|
+
# assert(Dnsruby::SelectThread.instance.select_thread_alive?)
|
176
|
+
# # Wait a second, and check select_thread stopped.
|
177
|
+
# sleep(2)
|
178
|
+
# assert(!Dnsruby::SelectThread.instance.select_thread_alive?)
|
179
|
+
# # Send another query, and check select_thread running.
|
180
|
+
# m = res.query("example.com")
|
181
|
+
# assert(Dnsruby::SelectThread.instance.select_thread_alive?)
|
182
|
+
# end
|
183
|
+
|
184
|
+
def test_res_config
|
185
|
+
res = Dnsruby::SingleResolver.new
|
186
|
+
|
187
|
+
res.server=('a.t.dnsruby.validation-test-servers.nominet.org.uk')
|
188
|
+
ip = res.server
|
189
|
+
assert_equal('10.0.1.128', ip.to_s, 'nameserver() looks up IP.')
|
190
|
+
|
191
|
+
res.server=('cname.t.dnsruby.validation-test-servers.nominet.org.uk')
|
192
|
+
ip = res.server
|
193
|
+
assert_equal('10.0.1.128', ip.to_s, 'nameserver() looks up cname.')
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_truncated_response
|
197
|
+
res = SingleResolver.new
|
198
|
+
# print "Dnssec = #{res.dnssec}\n"
|
199
|
+
res.server=('ns0.validation-test-servers.nominet.org.uk')
|
200
|
+
res.packet_timeout = 15
|
201
|
+
m = res.query("overflow.dnsruby.validation-test-servers.nominet.org.uk", 'txt')
|
202
|
+
assert(m.header.ancount == 61, "61 answer records expected, got #{m.header.ancount}")
|
203
|
+
assert(!m.header.tc, "Message was truncated!")
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_illegal_src_port
|
207
|
+
# Try to set src_port to an illegal value - make sure error raised, and port OK
|
208
|
+
res = SingleResolver.new
|
209
|
+
tests = [53, 387, 1265, 3210, 48619]
|
210
|
+
tests.each do |bad_port|
|
211
|
+
begin
|
212
|
+
res.src_port = bad_port
|
213
|
+
fail("bad port #{bad_port}")
|
214
|
+
rescue
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_add_src_port
|
220
|
+
# Try setting and adding port ranges, and invalid ports, and 0.
|
221
|
+
res = SingleResolver.new
|
222
|
+
res.src_port = [56789,56790, 56793]
|
223
|
+
assert(res.src_port == [56789,56790, 56793])
|
224
|
+
res.src_port = 56889..56891
|
225
|
+
assert(res.src_port == [56889,56890,56891])
|
226
|
+
res.add_src_port(60000..60002)
|
227
|
+
assert(res.src_port == [56889,56890,56891,60000,60001,60002])
|
228
|
+
res.add_src_port([60004,60005])
|
229
|
+
assert(res.src_port == [56889,56890,56891,60000,60001,60002,60004,60005])
|
230
|
+
res.add_src_port(60006)
|
231
|
+
assert(res.src_port == [56889,56890,56891,60000,60001,60002,60004,60005,60006])
|
232
|
+
# Now test invalid src_ports
|
233
|
+
tests = [0, 53, [60007, 53], [60008, 0], 55..100]
|
234
|
+
tests.each do |x|
|
235
|
+
begin
|
236
|
+
res.add_src_port(x)
|
237
|
+
fail()
|
238
|
+
rescue
|
239
|
+
end
|
240
|
+
end
|
241
|
+
assert(res.src_port == [56889,56890,56891,60000,60001,60002,60004,60005,60006])
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_options_preserved_on_tcp_resend
|
245
|
+
# Send a very small EDNS message to trigger tcp resend.
|
246
|
+
# Can we do that without using send_raw and avoiding the case we want to test?
|
247
|
+
# Sure - just knock up a little server here, which simply returns the response with the
|
248
|
+
# TC bit set, and records both packets sent to it
|
249
|
+
# Need to listen once on UDP and once on TCP
|
250
|
+
udpPacket = nil
|
251
|
+
tcpPacket = nil
|
252
|
+
port = 59821
|
253
|
+
thread = Thread.new {
|
254
|
+
u = UDPSocket.new()
|
255
|
+
u.bind("127.0.0.1", port)
|
256
|
+
|
257
|
+
s = u.recvfrom(15000)
|
258
|
+
received_query = s[0]
|
259
|
+
udpPacket = Message.decode(received_query)
|
260
|
+
u.connect(s[1][2], s[1][1])
|
261
|
+
udpPacket.header.tc = true
|
262
|
+
u.send(udpPacket.encode(),0)
|
263
|
+
u.close
|
264
|
+
|
265
|
+
ts = TCPServer.new(port)
|
266
|
+
t = ts.accept
|
267
|
+
packet = t.recvfrom(2)[0]
|
268
|
+
|
269
|
+
len = (packet[0]<<8)+packet[1]
|
270
|
+
if (RUBY_VERSION >= "1.9")
|
271
|
+
len = (packet[0].getbyte(0)<<8)+packet[1].getbyte(0)# Ruby 1.9
|
272
|
+
end
|
273
|
+
packet = t.recvfrom(len)[0]
|
274
|
+
tcpPacket = Message.decode(packet)
|
275
|
+
tcpPacket.header.tc = true
|
276
|
+
lenmsg = [tcpPacket.encode.length].pack('n')
|
277
|
+
t.send(lenmsg, 0)
|
278
|
+
t.write(tcpPacket.encode)
|
279
|
+
t.close
|
280
|
+
ts.close
|
281
|
+
}
|
282
|
+
ret = nil
|
283
|
+
thread2 = Thread.new {
|
284
|
+
r = SingleResolver.new("127.0.0.1")
|
285
|
+
r.port = port
|
286
|
+
ret = r.query("example.com")
|
287
|
+
}
|
288
|
+
thread.join
|
289
|
+
thread2.join
|
290
|
+
assert(tcpPacket && udpPacket)
|
291
|
+
assert(tcpPacket.header == udpPacket.header)
|
292
|
+
assert(tcpPacket.additional.rrsets('OPT', true)[0].rrs()[0].ttl == udpPacket.additional.rrsets('OPT', true)[0].rrs()[0].ttl, "UDP : #{udpPacket.additional.rrsets('OPT', true)[0].rrs()[0]}, TCP #{tcpPacket.additional.rrsets('OPT', true)[0].rrs()[0]}")
|
293
|
+
|
294
|
+
end
|
298
295
|
end
|