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
|
@@ -1,192 +1,192 @@
|
|
|
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
|
-
begin
|
|
17
|
-
require 'jcode'
|
|
18
|
-
rescue LoadError => e
|
|
19
|
-
end
|
|
20
|
-
module Dnsruby
|
|
21
|
-
class RR
|
|
22
|
-
#Class for DNS Text (TXT) resource records.
|
|
23
|
-
#RFC 1035 Section 3.3.14
|
|
24
|
-
class TXT < RR
|
|
25
|
-
ClassValue = nil #:nodoc: all
|
|
26
|
-
TypeValue = Types::TXT #:nodoc: all
|
|
27
|
-
|
|
28
|
-
#List of the individual elements
|
|
29
|
-
attr_accessor :strings
|
|
30
|
-
|
|
31
|
-
def data
|
|
32
|
-
@strings[0]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def from_data(data)
|
|
36
|
-
@strings = data
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def from_hash(hash)
|
|
40
|
-
if (hash.has_key?:strings)
|
|
41
|
-
from_string(hash[:strings])
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
ESCAPE_CHARS = {"b" => 8, "t" => 9, "n" => 10, "v" => 11, "f" => 12, "r" => 13}
|
|
46
|
-
ESCAPE_CODES = ESCAPE_CHARS.invert
|
|
47
|
-
|
|
48
|
-
def from_string(input)
|
|
49
|
-
@strings = TXT.parse(input)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def TXT.parse(input)
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
in_escaped = false
|
|
58
|
-
in_string = false
|
|
59
|
-
count = -1
|
|
60
|
-
strings = []
|
|
61
|
-
current_binary = ""
|
|
62
|
-
current_quote_char = '"'
|
|
63
|
-
unquoted = false
|
|
64
|
-
seen_strings = false
|
|
65
|
-
pos = 0
|
|
66
|
-
input.sub!(/^\s*\(\s*/, "")
|
|
67
|
-
input.sub!(/\s*\)\s*$/, "")
|
|
68
|
-
input.each_char {|c|
|
|
69
|
-
if (((c == "'") || (c == '"')) && (!in_escaped) && (!unquoted))
|
|
70
|
-
if (!in_string)
|
|
71
|
-
seen_strings = true
|
|
72
|
-
current_quote_char = c
|
|
73
|
-
in_string = true
|
|
74
|
-
count+=1
|
|
75
|
-
strings[count] = ""
|
|
76
|
-
else
|
|
77
|
-
if (c == current_quote_char)
|
|
78
|
-
in_string = false
|
|
79
|
-
else
|
|
80
|
-
strings[count]+=c
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
else
|
|
84
|
-
if (seen_strings && !in_string)
|
|
85
|
-
next
|
|
86
|
-
end
|
|
87
|
-
if (pos == 0)
|
|
88
|
-
unquoted = true
|
|
89
|
-
count+=1
|
|
90
|
-
strings[count] = ""
|
|
91
|
-
elsif (unquoted)
|
|
92
|
-
if (c == " ")
|
|
93
|
-
count+=1
|
|
94
|
-
strings[count] = ""
|
|
95
|
-
pos += 1
|
|
96
|
-
next
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
if (c == "\\")
|
|
101
|
-
if (in_escaped)
|
|
102
|
-
in_escaped = false
|
|
103
|
-
strings[count]+=(c)
|
|
104
|
-
else
|
|
105
|
-
in_escaped = true
|
|
106
|
-
end
|
|
107
|
-
else
|
|
108
|
-
if (in_escaped)
|
|
109
|
-
#
|
|
110
|
-
if (c == ";") || (c == '"')
|
|
111
|
-
strings[count]+=c
|
|
112
|
-
in_escaped = false
|
|
113
|
-
elsif (ESCAPE_CHARS[c])
|
|
114
|
-
in_escaped=false
|
|
115
|
-
strings[count]+=ESCAPE_CHARS[c].chr
|
|
116
|
-
elsif (c<"0" || c>"9")
|
|
117
|
-
in_escaped = false
|
|
118
|
-
strings[count]+=c
|
|
119
|
-
else
|
|
120
|
-
#
|
|
121
|
-
# if (c >= "0" && c <= "9")
|
|
122
|
-
current_binary += c
|
|
123
|
-
# end
|
|
124
|
-
if ((current_binary.length == 3) ) # || (c < "0" || c > "9"))
|
|
125
|
-
strings[count]+=current_binary.to_i.chr
|
|
126
|
-
in_escaped = false
|
|
127
|
-
current_binary = ""
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
else
|
|
131
|
-
strings[count]+=(c)
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
pos += 1
|
|
136
|
-
}
|
|
137
|
-
return strings
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def TXT.display(str, do_escapes = true)
|
|
141
|
-
output = ""
|
|
142
|
-
#
|
|
143
|
-
#
|
|
144
|
-
#
|
|
145
|
-
str.each_byte {|c|
|
|
146
|
-
if (c == 34) || (c == 92) # || (c == 59)
|
|
147
|
-
if (do_escapes)
|
|
148
|
-
output+='\\'
|
|
149
|
-
end
|
|
150
|
-
output+=c.chr
|
|
151
|
-
elsif (c < 32) # c is binary
|
|
152
|
-
if (ESCAPE_CODES[c])
|
|
153
|
-
output += c.chr
|
|
154
|
-
else
|
|
155
|
-
output+= '\\'
|
|
156
|
-
num = c.to_i.to_s
|
|
157
|
-
(3-num.length).times {|i|
|
|
158
|
-
num="0"+num
|
|
159
|
-
}
|
|
160
|
-
output+= num # Need a 3 digit number here.
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
else
|
|
164
|
-
output += c.chr
|
|
165
|
-
end
|
|
166
|
-
}
|
|
167
|
-
return output
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def rdata_to_string
|
|
171
|
-
if (defined?@strings)
|
|
172
|
-
temp = []
|
|
173
|
-
@strings.each {|str|
|
|
174
|
-
output = TXT.display(str)
|
|
175
|
-
temp.push("\"#{output}\"")
|
|
176
|
-
}
|
|
177
|
-
return temp.join(' ')
|
|
178
|
-
end
|
|
179
|
-
return ''
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
def encode_rdata(msg, canonical=false) #:nodoc: all
|
|
183
|
-
msg.put_string_list(@strings)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def self.decode_rdata(msg) #:nodoc: all
|
|
187
|
-
strings = msg.get_string_list
|
|
188
|
-
return self.new(strings)
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
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
|
+
begin
|
|
17
|
+
require 'jcode'
|
|
18
|
+
rescue LoadError => e
|
|
19
|
+
end
|
|
20
|
+
module Dnsruby
|
|
21
|
+
class RR
|
|
22
|
+
# Class for DNS Text (TXT) resource records.
|
|
23
|
+
# RFC 1035 Section 3.3.14
|
|
24
|
+
class TXT < RR
|
|
25
|
+
ClassValue = nil #:nodoc: all
|
|
26
|
+
TypeValue = Types::TXT #:nodoc: all
|
|
27
|
+
|
|
28
|
+
# List of the individual elements
|
|
29
|
+
attr_accessor :strings
|
|
30
|
+
|
|
31
|
+
def data
|
|
32
|
+
@strings[0]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def from_data(data)
|
|
36
|
+
@strings = data
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def from_hash(hash)
|
|
40
|
+
if (hash.has_key?:strings)
|
|
41
|
+
from_string(hash[:strings])
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
ESCAPE_CHARS = {"b" => 8, "t" => 9, "n" => 10, "v" => 11, "f" => 12, "r" => 13}
|
|
46
|
+
ESCAPE_CODES = ESCAPE_CHARS.invert
|
|
47
|
+
|
|
48
|
+
def from_string(input)
|
|
49
|
+
@strings = TXT.parse(input)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def TXT.parse(input)
|
|
53
|
+
# Need to look out for special characters.
|
|
54
|
+
# Need to split the input up into strings (which are defined by non-escaped " characters)
|
|
55
|
+
# Then need to fix up any \ escape characters (should just be " and ; and binary?)
|
|
56
|
+
# Sadly, it's going to be easiest just to scan through this character by character...
|
|
57
|
+
in_escaped = false
|
|
58
|
+
in_string = false
|
|
59
|
+
count = -1
|
|
60
|
+
strings = []
|
|
61
|
+
current_binary = ""
|
|
62
|
+
current_quote_char = '"'
|
|
63
|
+
unquoted = false
|
|
64
|
+
seen_strings = false
|
|
65
|
+
pos = 0
|
|
66
|
+
input.sub!(/^\s*\(\s*/, "")
|
|
67
|
+
input.sub!(/\s*\)\s*$/, "")
|
|
68
|
+
input.each_char {|c|
|
|
69
|
+
if (((c == "'") || (c == '"')) && (!in_escaped) && (!unquoted))
|
|
70
|
+
if (!in_string)
|
|
71
|
+
seen_strings = true
|
|
72
|
+
current_quote_char = c
|
|
73
|
+
in_string = true
|
|
74
|
+
count+=1
|
|
75
|
+
strings[count] = ""
|
|
76
|
+
else
|
|
77
|
+
if (c == current_quote_char)
|
|
78
|
+
in_string = false
|
|
79
|
+
else
|
|
80
|
+
strings[count]+=c
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
else
|
|
84
|
+
if (seen_strings && !in_string)
|
|
85
|
+
next
|
|
86
|
+
end
|
|
87
|
+
if (pos == 0)
|
|
88
|
+
unquoted = true
|
|
89
|
+
count+=1
|
|
90
|
+
strings[count] = ""
|
|
91
|
+
elsif (unquoted)
|
|
92
|
+
if (c == " ")
|
|
93
|
+
count+=1
|
|
94
|
+
strings[count] = ""
|
|
95
|
+
pos += 1
|
|
96
|
+
next
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
if (c == "\\")
|
|
101
|
+
if (in_escaped)
|
|
102
|
+
in_escaped = false
|
|
103
|
+
strings[count]+=(c)
|
|
104
|
+
else
|
|
105
|
+
in_escaped = true
|
|
106
|
+
end
|
|
107
|
+
else
|
|
108
|
+
if (in_escaped)
|
|
109
|
+
# Build up the binary
|
|
110
|
+
if (c == ";") || (c == '"')
|
|
111
|
+
strings[count]+=c
|
|
112
|
+
in_escaped = false
|
|
113
|
+
elsif (ESCAPE_CHARS[c])
|
|
114
|
+
in_escaped=false
|
|
115
|
+
strings[count]+=ESCAPE_CHARS[c].chr
|
|
116
|
+
elsif (c<"0" || c>"9")
|
|
117
|
+
in_escaped = false
|
|
118
|
+
strings[count]+=c
|
|
119
|
+
else
|
|
120
|
+
# Must be building up three digit string to identify binary value?
|
|
121
|
+
# if (c >= "0" && c <= "9")
|
|
122
|
+
current_binary += c
|
|
123
|
+
# end
|
|
124
|
+
if ((current_binary.length == 3) ) # || (c < "0" || c > "9"))
|
|
125
|
+
strings[count]+=current_binary.to_i.chr
|
|
126
|
+
in_escaped = false
|
|
127
|
+
current_binary = ""
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
else
|
|
131
|
+
strings[count]+=(c)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
pos += 1
|
|
136
|
+
}
|
|
137
|
+
return strings
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def TXT.display(str, do_escapes = true)
|
|
141
|
+
output = ""
|
|
142
|
+
# Probably need to scan through each string manually
|
|
143
|
+
# Make sure to remember to escape binary characters.
|
|
144
|
+
# Go through copying to output, and adding "\" characters as necessary?
|
|
145
|
+
str.each_byte {|c|
|
|
146
|
+
if (c == 34) || (c == 92) # || (c == 59)
|
|
147
|
+
if (do_escapes)
|
|
148
|
+
output+='\\'
|
|
149
|
+
end
|
|
150
|
+
output+=c.chr
|
|
151
|
+
elsif (c < 32) # c is binary
|
|
152
|
+
if (ESCAPE_CODES[c])
|
|
153
|
+
output += c.chr
|
|
154
|
+
else
|
|
155
|
+
output+= '\\'
|
|
156
|
+
num = c.to_i.to_s
|
|
157
|
+
(3-num.length).times {|i|
|
|
158
|
+
num="0"+num
|
|
159
|
+
}
|
|
160
|
+
output+= num # Need a 3 digit number here.
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
else
|
|
164
|
+
output += c.chr
|
|
165
|
+
end
|
|
166
|
+
}
|
|
167
|
+
return output
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def rdata_to_string
|
|
171
|
+
if (defined?@strings)
|
|
172
|
+
temp = []
|
|
173
|
+
@strings.each {|str|
|
|
174
|
+
output = TXT.display(str)
|
|
175
|
+
temp.push("\"#{output}\"")
|
|
176
|
+
}
|
|
177
|
+
return temp.join(' ')
|
|
178
|
+
end
|
|
179
|
+
return ''
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def encode_rdata(msg, canonical=false) #:nodoc: all
|
|
183
|
+
msg.put_string_list(@strings)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def self.decode_rdata(msg) #:nodoc: all
|
|
187
|
+
strings = msg.get_string_list
|
|
188
|
+
return self.new(strings)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
192
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
module Dnsruby
|
|
17
|
+
class RR
|
|
18
|
+
# Class for DNS X25 resource records.
|
|
19
|
+
# RFC 1183 Section 3.1
|
|
20
|
+
class X25 < RR
|
|
21
|
+
ClassValue = nil #:nodoc: all
|
|
22
|
+
TypeValue = Types::X25 #:nodoc: all
|
|
23
|
+
|
|
24
|
+
# The PSDN address
|
|
25
|
+
attr_accessor :address
|
|
26
|
+
|
|
27
|
+
def from_data(data)
|
|
28
|
+
@address = data
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def from_string(input)
|
|
32
|
+
address = input
|
|
33
|
+
address.sub!(/^\"/, "")
|
|
34
|
+
@address = address.sub(/\"$/, "")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def rdata_to_string
|
|
38
|
+
if (@address!=nil)
|
|
39
|
+
return @address
|
|
40
|
+
else
|
|
41
|
+
return ""
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def encode_rdata(msg, canonical=false) #:nodoc: all
|
|
46
|
+
msg.put_string(@address)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.decode_rdata(msg) #:nodoc: all
|
|
50
|
+
address = msg.get_string
|
|
51
|
+
return self.new(*address)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -1,51 +1,51 @@
|
|
|
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
|
-
|
|
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
16
|
module Dnsruby
|
|
17
17
|
class RR
|
|
18
|
-
#
|
|
18
|
+
# Abstract superclass for RR's which have a domain name in the data section.
|
|
19
19
|
class DomainName < RR
|
|
20
|
-
#
|
|
20
|
+
# The domain name in the RR data section.
|
|
21
21
|
attr_reader :domainname
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
def set_domain_name(newname)
|
|
24
24
|
@domainname=Name.create(newname)
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
alias domainname= set_domain_name
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
def from_hash(hash) #:nodoc: all
|
|
30
30
|
set_domain_name(hash[:domainname])
|
|
31
31
|
end
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
def from_data(data) #:nodoc: all
|
|
34
34
|
@domainname = data
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
def from_string(input) #:nodoc: all
|
|
38
38
|
set_domain_name(input)
|
|
39
39
|
end
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
def rdata_to_string #:nodoc: all
|
|
42
42
|
return @domainname.to_s(true)
|
|
43
43
|
end
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
def encode_rdata(msg, canonical=false) #:nodoc: all
|
|
46
46
|
msg.put_name(@domainname, canonical)
|
|
47
47
|
end
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
def self.decode_rdata(msg) #:nodoc: all
|
|
50
50
|
return self.new(msg.get_name)
|
|
51
51
|
end
|