dnsruby 1.55 → 1.56.0
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/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_message.rb
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
class TestMessage < Minitest::Test
|
|
20
|
+
|
|
21
|
+
include Dnsruby
|
|
22
|
+
|
|
23
|
+
# Creates and returns sample message:
|
|
24
|
+
#
|
|
25
|
+
# ;; QUESTION SECTION (1 record)
|
|
26
|
+
# ;; cnn.com. IN A
|
|
27
|
+
# ;; Security Level : UNCHECKED
|
|
28
|
+
# ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7195
|
|
29
|
+
# ;; flags: ; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
|
|
30
|
+
def sample_message
|
|
31
|
+
Message.new('cnn.com', 'A')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_question_section_formatted_ok
|
|
35
|
+
multiline_regex = /QUESTION SECTION.+record.+cnn.com.\s+IN\s+A/m
|
|
36
|
+
assert multiline_regex.match(sample_message.to_s)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_has_security_level_line
|
|
40
|
+
line_regex = /^;; Security Level : .+/
|
|
41
|
+
assert line_regex.match(sample_message.to_s)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_has_flags_and_section_count
|
|
45
|
+
line_regex = /^;; flags:.+QUERY: \d+, ANSWER: \d+, AUTHORITY: \d+, ADDITIONAL: \d+/
|
|
46
|
+
assert line_regex.match(sample_message.to_s)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_rd_flag_displayed_when_true
|
|
50
|
+
message = sample_message
|
|
51
|
+
message.header.instance_variable_set(:@rd, true)
|
|
52
|
+
assert /;; flags(.+)rd/.match(message.to_s), message
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_header_line_contains_opcode_and_status_and_id
|
|
56
|
+
message = sample_message
|
|
57
|
+
header_line = message.to_s.split("\n").grep(/->>HEADER<<-/).first
|
|
58
|
+
line_regex = /->>HEADER<<- opcode: .+, status: .+, id: \d+/
|
|
59
|
+
assert line_regex.match(header_line)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_getopt
|
|
63
|
+
message = sample_message
|
|
64
|
+
assert message.get_opt.nil?
|
|
65
|
+
|
|
66
|
+
# Add an OPT record
|
|
67
|
+
opt = RR::OPT.new(4096, 32768)
|
|
68
|
+
message.additional << opt
|
|
69
|
+
|
|
70
|
+
opt = message.get_opt
|
|
71
|
+
assert opt.is_a?(Dnsruby::RR::OPT),
|
|
72
|
+
"Expected get_opt to return a Dnsruby::RR::OPT, but it returned a #{opt.class}"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_2eq
|
|
76
|
+
test = ->(msg1, msg2, expected_result) do
|
|
77
|
+
assert (msg1 == msg2) == expected_result
|
|
78
|
+
end
|
|
79
|
+
msg_a = sample_message
|
|
80
|
+
msg_b = sample_message; msg_b.header.rd = (! msg_b.header.rd)
|
|
81
|
+
test.(msg_a, msg_a, true)
|
|
82
|
+
test.(msg_a, msg_b, false)
|
|
83
|
+
test.(msg_a, msg_a.to_s, false)
|
|
84
|
+
test.(msg_a, nil, false)
|
|
85
|
+
# TODO: Add more tests.
|
|
86
|
+
end
|
|
87
|
+
end
|
data/test/tc_misc.rb
CHANGED
|
@@ -1,99 +1,95 @@
|
|
|
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
|
-
require 'test/unit'
|
|
21
|
-
require 'dnsruby'
|
|
22
|
-
class TestMisc < Test::Unit::TestCase
|
|
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
|
+
class TestMisc < Minitest::Test
|
|
23
20
|
def test_wildcard
|
|
24
|
-
#
|
|
25
|
-
#
|
|
21
|
+
# test to make sure that wildcarding works.
|
|
22
|
+
#
|
|
26
23
|
rr = Dnsruby::RR.create('*.t.dnsruby.validation-test-servers.nominet.org.uk 60 IN A 10.0.0.1')
|
|
27
|
-
|
|
24
|
+
|
|
28
25
|
assert(rr, 'RR got made')
|
|
29
|
-
|
|
26
|
+
|
|
30
27
|
assert_equal('*.t.dnsruby.validation-test-servers.nominet.org.uk', rr.name.to_s, 'Name is correct' )
|
|
31
28
|
assert_equal(60, rr.ttl, 'TTL is correct' )
|
|
32
29
|
assert_equal(Dnsruby::Classes.IN, rr.klass, 'CLASS is correct' )
|
|
33
30
|
assert_equal(Dnsruby::Types.A, rr.type, 'TYPE is correct' )
|
|
34
31
|
assert_equal('10.0.0.1', rr.address.to_s, 'Address is correct')
|
|
35
32
|
end
|
|
36
|
-
|
|
33
|
+
|
|
37
34
|
def test_misc
|
|
38
|
-
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# Make sure the underscore in SRV hostnames work.
|
|
38
|
+
#
|
|
42
39
|
srv = Dnsruby::RR.create('_rvp._tcp.t.dnsruby.validation-test-servers.nominet.org.uk. 60 IN SRV 0 0 80 im.bastardsinc.biz')
|
|
43
|
-
|
|
44
|
-
assert(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
#~ # /usr/local/lib/perl5/site_perl/5.005/Net/DNS/RR.pm line 639. bug is gone
|
|
40
|
+
|
|
41
|
+
assert(srv, 'SRV not created successfully')
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# ~ # Test that the 5.005 Use of uninitialized value at
|
|
45
|
+
# ~ # /usr/local/lib/perl5/site_perl/5.005/Net/DNS/RR.pm line 639. bug is gone
|
|
50
46
|
rr = Dnsruby::RR.create('mx.t.dnsruby.validation-test-servers.nominet.org.uk 60 IN MX 10 a.t.dnsruby.validation-test-servers.nominet.org.uk')
|
|
51
47
|
assert(rr, 'RR created')
|
|
52
|
-
|
|
48
|
+
|
|
53
49
|
assert_equal(rr.preference, 10, 'Preference works')
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
57
53
|
mx = Dnsruby::RR.create('mx.t.dnsruby.validation-test-servers.nominet.org.uk 60 IN MX 0 mail.dnsruby.validation-test-servers.nominet.org.uk')
|
|
58
|
-
|
|
54
|
+
|
|
59
55
|
assert(mx.to_s =~ /0 mail.dnsruby.validation-test-servers.nominet.org.uk/) # was 'like'
|
|
60
56
|
assert_equal(mx.preference, 0)
|
|
61
57
|
assert_equal(mx.exchange.to_s, 'mail.dnsruby.validation-test-servers.nominet.org.uk')
|
|
62
|
-
|
|
58
|
+
|
|
63
59
|
srv = Dnsruby::RR.create('srv.t.dnsruby.validation-test-servers.nominet.org.uk 60 IN SRV 0 2 3 target.dnsruby.validation-test-servers.nominet.org.uk')
|
|
64
|
-
|
|
60
|
+
|
|
65
61
|
# # @todo@ Absolute name issues
|
|
66
62
|
# assert(srv.inspect =~ /0 2 3 target.dnsruby.validation-test-servers.nominet.org.uk\./)
|
|
67
63
|
# assert_equal(srv.rdatastr, '0 2 3 target.dnsruby.validation-test-servers.nominet.org.uk.')
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
71
67
|
end
|
|
72
|
-
|
|
68
|
+
|
|
73
69
|
def test_TXT_RR
|
|
74
|
-
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
#
|
|
79
|
-
#
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
#
|
|
83
|
-
#txt2.t.net-dns.org. IN TXT
|
|
84
|
-
|
|
85
|
-
#
|
|
86
|
-
#txt2.t.net-dns.org. 60 IN TXT "Net-DNS\ complicated $tuff" "sort of \" text\ and binary \000 data"
|
|
87
|
-
|
|
88
|
-
#
|
|
89
|
-
#net-dns.org. 3600 IN NS ns1.net-dns.org.
|
|
90
|
-
#net-dns.org. 3600 IN NS ns.ripe.net.
|
|
91
|
-
#net-dns.org. 3600 IN NS ns.hactrn.net.
|
|
92
|
-
|
|
93
|
-
#
|
|
94
|
-
#ns1.net-dns.org. 3600 IN A 193.0.4.49
|
|
95
|
-
#ns1.net-dns.org. 3600 IN AAAA
|
|
96
|
-
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
#
|
|
73
|
+
# Below are some thests that have to do with TXT RRs
|
|
74
|
+
#
|
|
75
|
+
#
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# QUESTION SECTION:
|
|
79
|
+
# txt2.t.net-dns.org. IN TXT
|
|
80
|
+
|
|
81
|
+
# ANSWER SECTION:
|
|
82
|
+
# txt2.t.net-dns.org. 60 IN TXT "Net-DNS\ complicated $tuff" "sort of \" text\ and binary \000 data"
|
|
83
|
+
|
|
84
|
+
# AUTHORITY SECTION:
|
|
85
|
+
# net-dns.org. 3600 IN NS ns1.net-dns.org.
|
|
86
|
+
# net-dns.org. 3600 IN NS ns.ripe.net.
|
|
87
|
+
# net-dns.org. 3600 IN NS ns.hactrn.net.
|
|
88
|
+
|
|
89
|
+
# ADDITIONAL SECTION:
|
|
90
|
+
# ns1.net-dns.org. 3600 IN A 193.0.4.49
|
|
91
|
+
# ns1.net-dns.org. 3600 IN AAAA
|
|
92
|
+
|
|
97
93
|
uuencodedPacket=%w{
|
|
98
94
|
11 99 85 00 00 01
|
|
99
95
|
00 01 00 03 00 02 04 74 78 74 32 01 74 07 6e 65
|
|
@@ -109,34 +105,34 @@ class TestMisc < Test::Unit::TestCase
|
|
|
109
105
|
73 06 68 61 63 74 72 6e c0 93 c0 79 00 01 00 01
|
|
110
106
|
00 00 0e 10 00 04 c1 00 04 31 c0 79 00 1c 00 01
|
|
111
107
|
00 00 0e 10 00 10 20 01 06 10 02 40 00 03 00 00
|
|
112
|
-
12 34 be 21 e3 1e
|
|
108
|
+
12 34 be 21 e3 1e
|
|
113
109
|
}
|
|
114
|
-
|
|
110
|
+
|
|
115
111
|
uuencodedPacket.map!{|e| e.hex}
|
|
116
112
|
packetdata = uuencodedPacket.pack('c*')
|
|
117
113
|
packetdata.gsub!("\s*", "")
|
|
118
|
-
|
|
114
|
+
|
|
119
115
|
packet = Dnsruby::Message.decode(packetdata)
|
|
120
116
|
txtRr=(packet.answer)[0]
|
|
121
117
|
assert_equal('Net-DNS; complicated $tuff',txtRr.strings[0],"First Char string in TXT RR read from wireformat")
|
|
122
|
-
|
|
123
|
-
#
|
|
124
|
-
#
|
|
125
|
-
|
|
118
|
+
|
|
119
|
+
# Compare the second char_str this contains a NULL byte (space NULL
|
|
120
|
+
# space=200020 in hex)
|
|
121
|
+
|
|
126
122
|
temp = (txtRr.strings)[1].unpack('H*')[0]
|
|
127
|
-
#
|
|
123
|
+
# #assert_equal(unpack('H*',(TXTrr.char_str_list())[1]),"736f7274206f66202220746578743b20616e642062696e61727920002064617461", "Second Char string in TXT RR read from wireformat")
|
|
128
124
|
assert_equal("736f7274206f66202220746578743b20616e642062696e61727920002064617461", temp,"Second Char string in TXT RR read from wireformat")
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
|
|
126
|
+
|
|
131
127
|
txtRr2=Dnsruby::RR.create('txt2.t.dnsruby.validation-test-servers.nominet.org.uk. 60 IN TXT "Test1 \" \; more stuff" "Test2"')
|
|
132
|
-
|
|
128
|
+
|
|
133
129
|
assert_equal((txtRr2.strings)[0],'Test1 " ; more stuff', "First arg string in TXT RR read from zonefileformat")
|
|
134
130
|
assert_equal((txtRr2.strings)[1],'Test2',"Second Char string in TXT RR read from zonefileformat")
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
#
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# txtRr3 = RR.create("baz.example.com 3600 HS TXT '\"' 'Char Str2'")
|
|
138
134
|
txtRr3 = Dnsruby::RR.create("baz.example.com 3600 IN TXT '\"' 'Char Str2'")
|
|
139
|
-
|
|
135
|
+
|
|
140
136
|
assert_equal( (txtRr3.strings)[0],'"',"Escaped \" between the single quotes")
|
|
141
137
|
end
|
|
142
138
|
end
|
data/test/tc_name.rb
CHANGED
|
@@ -1,84 +1,81 @@
|
|
|
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
|
-
n
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
n
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
names
|
|
59
|
-
names.push(Name.create("example"))
|
|
60
|
-
names.push(Name.create("a.
|
|
61
|
-
names.push(Name.create("
|
|
62
|
-
names.push(Name.create("
|
|
63
|
-
names.push(Name.create("
|
|
64
|
-
names.push(Name.create("z.example"))
|
|
65
|
-
names.push(Name.create("
|
|
66
|
-
names.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
assert(n1 == n2, n1.to_s)
|
|
83
|
-
end
|
|
84
|
-
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 TestName < Minitest::Test
|
|
21
|
+
def test_label_length
|
|
22
|
+
Name::Label.set_max_length(Name::Label::MaxLabelLength) # Other tests may have changed this
|
|
23
|
+
# Test max label length = 63
|
|
24
|
+
begin
|
|
25
|
+
name = Name.create("a.b.12345678901234567890123456789012345678901234567890123456789012345.com")
|
|
26
|
+
assert(false, "Label of more than max=63 allowed")
|
|
27
|
+
rescue ResolvError
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_name_length
|
|
32
|
+
# Test max name length=255
|
|
33
|
+
begin
|
|
34
|
+
name = Name.create("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123.com")
|
|
35
|
+
assert(false, "Name of length > 255 allowed")
|
|
36
|
+
rescue ResolvError
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_absolute
|
|
41
|
+
n = Name.create("example.com")
|
|
42
|
+
assert(!n.absolute?)
|
|
43
|
+
n = Name.create("example.com.")
|
|
44
|
+
assert(n.absolute?)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_wild
|
|
48
|
+
n = Name.create("example.com")
|
|
49
|
+
assert(!n.wild?)
|
|
50
|
+
n = Name.create("*.example.com.")
|
|
51
|
+
assert(n.wild?)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_canonical_ordering
|
|
55
|
+
names = []
|
|
56
|
+
names.push(Name.create("example"))
|
|
57
|
+
names.push(Name.create("a.example"))
|
|
58
|
+
names.push(Name.create("yljkjljk.a.example"))
|
|
59
|
+
names.push(Name.create("Z.a.example"))
|
|
60
|
+
names.push(Name.create("zABC.a.EXAMPLE"))
|
|
61
|
+
names.push(Name.create("z.example"))
|
|
62
|
+
names.push(Name.create("\001.z.example"))
|
|
63
|
+
names.push(Name.create("*.z.example"))
|
|
64
|
+
# names.push(Name.create("\200.z.example"))
|
|
65
|
+
names.push(Name.create(["c8"].pack("H*")+".z.example"))
|
|
66
|
+
names.each_index {|i|
|
|
67
|
+
if (i < (names.length() - 1))
|
|
68
|
+
assert(names[i].canonically_before(names[i+1]))
|
|
69
|
+
assert(!(names[i+1].canonically_before(names[i])))
|
|
70
|
+
end
|
|
71
|
+
}
|
|
72
|
+
assert(Name.create("x.w.example").canonically_before(Name.create("z.w.example")))
|
|
73
|
+
assert(Name.create("x.w.example").canonically_before(Name.create("a.z.w.example")))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_escapes
|
|
77
|
+
n1 = Name.create("\\nall.all.")
|
|
78
|
+
n2 = Name.create("nall.all.")
|
|
79
|
+
assert(n1 == n2, n1.to_s)
|
|
80
|
+
end
|
|
81
|
+
end
|