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.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +96 -0
  3. data/Rakefile +30 -29
  4. data/demo/axfr.rb +93 -93
  5. data/demo/check_soa.rb +99 -99
  6. data/demo/check_zone.rb +59 -59
  7. data/demo/digdlv.rb +43 -43
  8. data/demo/digroot.rb +34 -34
  9. data/demo/example_recurse.rb +14 -14
  10. data/demo/mresolv.rb +30 -30
  11. data/demo/mx.rb +31 -31
  12. data/demo/rubydig.rb +37 -37
  13. data/demo/to_resolve.txt +3088 -3088
  14. data/demo/trace_dns.rb +46 -46
  15. data/lib/dnsruby.rb +161 -526
  16. data/lib/dnsruby/DNS.rb +305 -0
  17. data/lib/{Dnsruby/Cache.rb → dnsruby/cache.rb} +152 -152
  18. data/lib/{Dnsruby → dnsruby}/code_mapper.rb +48 -52
  19. data/lib/dnsruby/code_mappers.rb +295 -0
  20. data/lib/{Dnsruby/Config.rb → dnsruby/config.rb} +454 -454
  21. data/lib/{Dnsruby → dnsruby}/dnssec.rb +91 -91
  22. data/lib/{Dnsruby/Hosts.rb → dnsruby/hosts.rb} +125 -125
  23. data/lib/{Dnsruby → dnsruby}/ipv4.rb +26 -26
  24. data/lib/{Dnsruby → dnsruby}/ipv6.rb +42 -42
  25. data/lib/{Dnsruby → dnsruby}/key_cache.rb +29 -29
  26. data/lib/dnsruby/message/decoder.rb +164 -0
  27. data/lib/dnsruby/message/encoder.rb +75 -0
  28. data/lib/dnsruby/message/header.rb +249 -0
  29. data/lib/dnsruby/message/message.rb +629 -0
  30. data/lib/dnsruby/message/question.rb +86 -0
  31. data/lib/dnsruby/message/section.rb +96 -0
  32. data/lib/{Dnsruby → dnsruby}/name.rb +141 -141
  33. data/lib/dnsruby/packet_sender.rb +661 -0
  34. data/lib/{Dnsruby/Recursor.rb → dnsruby/recursor.rb} +235 -233
  35. data/lib/dnsruby/resolv.rb +113 -0
  36. data/lib/dnsruby/resolver.rb +1192 -0
  37. data/lib/dnsruby/resource/A.rb +56 -0
  38. data/lib/dnsruby/resource/AAAA.rb +54 -0
  39. data/lib/{Dnsruby → dnsruby}/resource/AFSDB.rb +68 -68
  40. data/lib/{Dnsruby → dnsruby}/resource/CERT.rb +105 -105
  41. data/lib/{Dnsruby → dnsruby}/resource/DHCID.rb +54 -54
  42. data/lib/dnsruby/resource/DLV.rb +27 -0
  43. data/lib/{Dnsruby → dnsruby}/resource/DNSKEY.rb +372 -372
  44. data/lib/{Dnsruby → dnsruby}/resource/DS.rb +255 -255
  45. data/lib/{Dnsruby → dnsruby}/resource/HINFO.rb +71 -71
  46. data/lib/{Dnsruby → dnsruby}/resource/HIP.rb +29 -29
  47. data/lib/{Dnsruby → dnsruby}/resource/IN.rb +30 -30
  48. data/lib/{Dnsruby → dnsruby}/resource/IPSECKEY.rb +31 -31
  49. data/lib/{Dnsruby → dnsruby}/resource/ISDN.rb +62 -62
  50. data/lib/{Dnsruby → dnsruby}/resource/KX.rb +65 -65
  51. data/lib/{Dnsruby → dnsruby}/resource/LOC.rb +263 -263
  52. data/lib/{Dnsruby → dnsruby}/resource/MINFO.rb +69 -69
  53. data/lib/{Dnsruby → dnsruby}/resource/MX.rb +65 -65
  54. data/lib/{Dnsruby → dnsruby}/resource/NAPTR.rb +98 -98
  55. data/lib/{Dnsruby → dnsruby}/resource/NSAP.rb +171 -171
  56. data/lib/dnsruby/resource/NSEC.rb +275 -0
  57. data/lib/dnsruby/resource/NSEC3.rb +332 -0
  58. data/lib/dnsruby/resource/NSEC3PARAM.rb +135 -0
  59. data/lib/dnsruby/resource/OPT.rb +272 -0
  60. data/lib/{Dnsruby → dnsruby}/resource/PX.rb +70 -70
  61. data/lib/{Dnsruby → dnsruby}/resource/RP.rb +75 -75
  62. data/lib/dnsruby/resource/RR.rb +421 -0
  63. data/lib/dnsruby/resource/RRSIG.rb +275 -0
  64. data/lib/dnsruby/resource/RRSet.rb +190 -0
  65. data/lib/{Dnsruby → dnsruby}/resource/RT.rb +67 -67
  66. data/lib/{Dnsruby → dnsruby}/resource/SOA.rb +94 -94
  67. data/lib/dnsruby/resource/SPF.rb +29 -0
  68. data/lib/dnsruby/resource/SRV.rb +112 -0
  69. data/lib/{Dnsruby → dnsruby}/resource/SSHFP.rb +14 -14
  70. data/lib/dnsruby/resource/TKEY.rb +163 -0
  71. data/lib/dnsruby/resource/TSIG.rb +593 -0
  72. data/lib/{Dnsruby → dnsruby}/resource/TXT.rb +191 -191
  73. data/lib/dnsruby/resource/X25.rb +55 -0
  74. data/lib/{Dnsruby → dnsruby}/resource/domain_name.rb +25 -25
  75. data/lib/{Dnsruby → dnsruby}/resource/generic.rb +80 -80
  76. data/lib/dnsruby/resource/resource.rb +25 -0
  77. data/lib/{Dnsruby → dnsruby}/select_thread.rb +148 -148
  78. data/lib/{Dnsruby/SingleResolver.rb → dnsruby/single_resolver.rb} +60 -60
  79. data/lib/{Dnsruby → dnsruby}/single_verifier.rb +344 -344
  80. data/lib/dnsruby/the_log.rb +44 -0
  81. data/lib/dnsruby/update.rb +278 -0
  82. data/lib/dnsruby/validator_thread.rb +124 -0
  83. data/lib/dnsruby/version.rb +3 -0
  84. data/lib/{Dnsruby → dnsruby}/zone_reader.rb +93 -93
  85. data/lib/{Dnsruby → dnsruby}/zone_transfer.rb +377 -377
  86. data/test/spec_helper.rb +16 -0
  87. data/test/tc_axfr.rb +31 -34
  88. data/test/tc_cache.rb +32 -32
  89. data/test/tc_dlv.rb +28 -28
  90. data/test/tc_dns.rb +73 -76
  91. data/test/tc_dnskey.rb +31 -32
  92. data/test/tc_dnsruby.rb +50 -44
  93. data/test/tc_ds.rb +36 -36
  94. data/test/tc_escapedchars.rb +252 -255
  95. data/test/tc_hash.rb +17 -21
  96. data/test/tc_header.rb +48 -57
  97. data/test/tc_hip.rb +19 -22
  98. data/test/tc_ipseckey.rb +18 -21
  99. data/test/tc_keith.rb +300 -0
  100. data/test/tc_message.rb +87 -0
  101. data/test/tc_misc.rb +83 -87
  102. data/test/tc_name.rb +81 -84
  103. data/test/tc_naptr.rb +18 -21
  104. data/test/tc_nsec.rb +55 -55
  105. data/test/tc_nsec3.rb +23 -24
  106. data/test/tc_nsec3param.rb +20 -21
  107. data/test/tc_packet.rb +90 -93
  108. data/test/tc_packet_unique_push.rb +48 -51
  109. data/test/tc_question.rb +30 -33
  110. data/test/tc_queue.rb +16 -17
  111. data/test/tc_recur.rb +16 -17
  112. data/test/tc_res_config.rb +38 -41
  113. data/test/tc_res_env.rb +29 -32
  114. data/test/tc_res_file.rb +26 -29
  115. data/test/tc_res_opt.rb +62 -65
  116. data/test/tc_resolver.rb +287 -242
  117. data/test/tc_rr-opt.rb +70 -63
  118. data/test/tc_rr-txt.rb +68 -71
  119. data/test/tc_rr-unknown.rb +45 -48
  120. data/test/tc_rr.rb +76 -70
  121. data/test/tc_rrset.rb +21 -22
  122. data/test/tc_rrsig.rb +19 -20
  123. data/test/tc_single_resolver.rb +294 -297
  124. data/test/tc_soak.rb +199 -202
  125. data/test/tc_soak_base.rb +29 -34
  126. data/test/tc_sshfp.rb +20 -23
  127. data/test/tc_tcp.rb +32 -35
  128. data/test/tc_tkey.rb +41 -44
  129. data/test/tc_tsig.rb +81 -84
  130. data/test/tc_update.rb +108 -111
  131. data/test/tc_validator.rb +29 -29
  132. data/test/tc_verifier.rb +81 -82
  133. data/test/ts_dnsruby.rb +16 -15
  134. data/test/ts_offline.rb +62 -63
  135. data/test/ts_online.rb +115 -115
  136. metadata +155 -90
  137. data/README +0 -59
  138. data/lib/Dnsruby/DNS.rb +0 -305
  139. data/lib/Dnsruby/PacketSender.rb +0 -656
  140. data/lib/Dnsruby/Resolver.rb +0 -1189
  141. data/lib/Dnsruby/TheLog.rb +0 -44
  142. data/lib/Dnsruby/message.rb +0 -1230
  143. data/lib/Dnsruby/resource/A.rb +0 -56
  144. data/lib/Dnsruby/resource/AAAA.rb +0 -54
  145. data/lib/Dnsruby/resource/DLV.rb +0 -27
  146. data/lib/Dnsruby/resource/NSEC.rb +0 -298
  147. data/lib/Dnsruby/resource/NSEC3.rb +0 -340
  148. data/lib/Dnsruby/resource/NSEC3PARAM.rb +0 -135
  149. data/lib/Dnsruby/resource/OPT.rb +0 -213
  150. data/lib/Dnsruby/resource/RRSIG.rb +0 -275
  151. data/lib/Dnsruby/resource/SPF.rb +0 -29
  152. data/lib/Dnsruby/resource/SRV.rb +0 -112
  153. data/lib/Dnsruby/resource/TKEY.rb +0 -163
  154. data/lib/Dnsruby/resource/TSIG.rb +0 -593
  155. data/lib/Dnsruby/resource/X25.rb +0 -55
  156. data/lib/Dnsruby/resource/resource.rb +0 -678
  157. data/lib/Dnsruby/update.rb +0 -278
  158. data/lib/Dnsruby/validator_thread.rb +0 -124
@@ -0,0 +1,272 @@
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 EDNS pseudo resource record OPT.
19
+ # This class is effectively internal to Dnsruby
20
+ # See RFC 2671, RFC 2435 Section 3
21
+ # @TODO@ Extended labels RFC2671 section 3
22
+ class OPT < RR #:nodoc: all
23
+ ClassValue = nil #:nodoc: all
24
+ TypeValue = Types::OPT #:nodoc: all
25
+ DO_BIT = 0x8000
26
+
27
+ ADDRESS_FAMILIES = [1, 2]
28
+ IPV4_ADDRESS_FAMILY, IPV6_ADDRESS_FAMILY = ADDRESS_FAMILIES
29
+
30
+ EDNS_SUBNET_OPTION = 8
31
+
32
+ # @TODO@ Add BADVERS to an XRCode CodeMapper object
33
+
34
+ # Can be called with up to 3 arguments, none of which must be present
35
+ # * OPT.new()
36
+ # * OPT.new(size)
37
+ # * OPT.new(size,flags)
38
+ # * OPT.new(size,flags,options)
39
+ def initialize(*args)
40
+ @type = Types.new('OPT')
41
+ @ttl = nil
42
+
43
+ @options=nil
44
+ if (args.length > 0)
45
+ self.payloadsize=(args[0])
46
+ if (args.length > 1)
47
+ self.flags=(args[1])
48
+ if (args.length > 2)
49
+ self.options=(args[2])
50
+ else
51
+ self.options=nil
52
+ end
53
+ else
54
+ self.flags=0
55
+ end
56
+ else
57
+ self.payloadsize=0
58
+ end
59
+ end
60
+
61
+ # From RFC 2671 :
62
+ # 4.3. The fixed part of an OPT RR is structured as follows:
63
+ #
64
+ # Field Name Field Type Description
65
+ # ------------------------------------------------------
66
+ # NAME domain name empty (root domain)
67
+ # TYPE u_int16_t OPT
68
+ # CLASS u_int16_t sender's UDP payload size
69
+ # TTL u_int32_t extended RCODE and flags
70
+ # RDLEN u_int16_t describes RDATA
71
+ # RDATA octet stream {attribute,value} pairs
72
+
73
+ # 4.6. The extended RCODE and flags (which OPT stores in the RR TTL field)
74
+ # are structured as follows:
75
+ #
76
+ # +0 (MSB) +1 (LSB)
77
+ # +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
78
+ # 0: | EXTENDED-RCODE | VERSION |
79
+ # +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
80
+ # 2: | Z |
81
+ # +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
82
+ #
83
+ # EXTENDED-RCODE Forms upper 8 bits of extended 12-bit RCODE. Note
84
+ # that EXTENDED-RCODE value "0" indicates that an
85
+ # unextended RCODE is in use (values "0" through "15").
86
+ #
87
+ # VERSION Indicates the implementation level of whoever sets
88
+ # it. Full conformance with this specification is
89
+ # indicated by version "0."
90
+
91
+ def flags_from_ttl
92
+ if (@ttl)
93
+ return [@ttl].pack("N")
94
+ else
95
+ return [0].pack("N")
96
+ end
97
+ end
98
+
99
+ def xrcode
100
+ return ExtendedRCode.new(flags_from_ttl[0, 1].unpack("C")[0])
101
+ end
102
+
103
+ def xrcode=(c)
104
+ code = ExtendedRCode.new(c)
105
+ @ttl = (code.code << 24) + (version() << 16) + flags()
106
+ end
107
+
108
+ def version
109
+ return flags_from_ttl[1, 1].unpack("C")[0]
110
+ end
111
+
112
+ def version=(code)
113
+ @ttl = (xrcode().code << 24) + (code << 16) + flags()
114
+ end
115
+
116
+ def flags
117
+ return flags_from_ttl[2, 2].unpack("n")[0]
118
+ end
119
+
120
+ def flags=(code)
121
+ set_flags(code)
122
+ end
123
+
124
+ def set_flags(code) # Should always be zero
125
+ @ttl = (xrcode().code << 24) + (version() << 16) + code
126
+ end
127
+
128
+ def dnssec_ok
129
+ return ((flags() & DO_BIT) == DO_BIT)
130
+ end
131
+
132
+ def dnssec_ok=(on)
133
+ if (on)
134
+ set_flags(flags() | DO_BIT)
135
+ else
136
+ set_flags(flags() & (~DO_BIT))
137
+ end
138
+ end
139
+
140
+ def payloadsize
141
+ return @klass.code
142
+ end
143
+
144
+ def payloadsize=(size)
145
+ self.klass=size
146
+ end
147
+
148
+ def options(args)
149
+ if (args==nil)
150
+ return @options
151
+ elsif args.kind_of?Fixnum
152
+ # return list of options with that code
153
+ ret = []
154
+ @options.each do |option|
155
+ if (option.code == args)
156
+ ret.push(option)
157
+ end
158
+ end
159
+ return ret
160
+ end
161
+ end
162
+
163
+ def options=(options)
164
+ @options = options
165
+ end
166
+
167
+ def from_data(data)
168
+ @options = data
169
+ end
170
+
171
+ def from_string(input)
172
+ raise NotImplementedError
173
+ end
174
+
175
+ def get_ip_addr(opt, family, source_netmask)
176
+ pad_format_string = family == IPV4_ADDRESS_FAMILY ? 'x3C' : 'x15C'
177
+ ip_addr = [0].pack(pad_format_string)
178
+
179
+ num_to_copy = (source_netmask + 7) / 8
180
+ num_to_copy.times { |index| ip_addr[index] = opt.data[index+4] }
181
+ ip_addr
182
+ end
183
+
184
+ def get_client_subnet(opt)
185
+ family = opt.data[1].unpack('C')[0]
186
+ return "Unsupported(family=#{family})" unless ADDRESS_FAMILIES.include?(family)
187
+
188
+ source_netmask = opt.data[2].unpack('C')[0]
189
+ scope_netmask = opt.data[3].unpack('C')[0]
190
+
191
+ case family
192
+ when IPV4_ADDRESS_FAMILY
193
+ return "#{IPAddr::ntop(get_ip_addr(opt,family,source_netmask))}/#{source_netmask}/#{scope_netmask}"
194
+ when IPV6_ADDRESS_FAMILY
195
+ new_ipv6 = IPAddr.new(IPAddr::ntop(get_ip_addr(opt,family,source_netmask)), Socket::AF_INET6)
196
+ return "#{new_ipv6}/#{source_netmask}/#{scope_netmask}"
197
+ end
198
+ end
199
+
200
+ def set_client_subnet(subnet)
201
+ family = IPV4_ADDRESS_FAMILY
202
+ scope_netmask = 0
203
+ ip, source_netmask = subnet.split('/')
204
+ source_netmask = source_netmask.to_i
205
+ if subnet == "0.0.0.0/0"
206
+ edns_client_subnet = RR::OPT::Option.new(
207
+ EDNS_SUBNET_OPTION, [family, source_netmask, scope_netmask].pack("xcc*"))
208
+ else
209
+ ip_address = IPAddr.new(ip)
210
+ family = IPV6_ADDRESS_FAMILY if ip_address.ipv6?
211
+ num_addr_bytes = source_netmask / 8
212
+ num_addr_bytes = num_addr_bytes + 1 if source_netmask % 8 > 0
213
+ edns_client_subnet = RR::OPT::Option.new(EDNS_SUBNET_OPTION, [family, source_netmask, scope_netmask].pack("xcc*") +
214
+ ip_address.hton.slice(0, num_addr_bytes))
215
+ end
216
+ self.options = [edns_client_subnet]
217
+ end
218
+
219
+ def edns_client_subnet
220
+ return nil if @options.nil?
221
+ subnet_option = @options.detect { |option| option.code == EDNS_SUBNET_OPTION }
222
+ subnet_option ? get_client_subnet(subnet_option) : nil
223
+ end
224
+
225
+ def to_s
226
+ ret = "OPT pseudo-record : payloadsize #{payloadsize}, xrcode #{xrcode.code}, version #{version}, flags #{flags}\n"
227
+ if @options
228
+ @options.each do |opt|
229
+ if opt.code == EDNS_SUBNET_OPTION
230
+ ret = ret + "CLIENT-SUBNET: #{get_client_subnet(opt)}"
231
+ else
232
+ ret = ret + " " + opt.to_s
233
+ end
234
+ end
235
+ end
236
+ ret = ret + "\n"
237
+ return ret
238
+ end
239
+
240
+ def encode_rdata(msg, canonical=false)
241
+ if (@options)
242
+ @options.each do |opt|
243
+ msg.put_pack('n', opt.code)
244
+ msg.put_pack('n', opt.data.length)
245
+ msg.put_bytes(opt.data)
246
+ end
247
+ end
248
+ end
249
+
250
+ def self.decode_rdata(msg)#:nodoc: all
251
+ if (msg.has_remaining)
252
+ options = []
253
+ while (msg.has_remaining) do
254
+ code = msg.get_unpack('n')[0]
255
+ len = msg.get_unpack('n')[0]
256
+ data = msg.get_bytes(len)
257
+ options.push(Option.new(code, data))
258
+ end
259
+ end
260
+ return self.new(0, 0, options)
261
+ end
262
+
263
+ class Option
264
+ attr_accessor :code, :data
265
+ def initialize(code, data)
266
+ @code = code
267
+ @data = data
268
+ end
269
+ end
270
+ end
271
+ end
272
+ end
@@ -1,71 +1,71 @@
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
- module IN
19
- class PX < RR
20
- ClassHash[[TypeValue = Types::PX, ClassValue = Classes::IN]] = self #:nodoc: all
21
-
22
- #The preference given to this RR.
23
- attr_accessor :preference
24
- #The RFC822 part of the RFC1327 mapping information.
25
- attr_accessor :map822
26
- #The X.400 part of the RFC1327 mapping information.
27
- attr_accessor :mapx400
28
-
29
- def from_hash(hash) #:nodoc: all
30
- @preference = hash[:preference]
31
- @map822 = Name.create(hash[:map822])
32
- @mapx400 = Name.create(hash[:mapx400])
33
- end
34
-
35
- def from_data(data) #:nodoc: all
36
- @preference, @map822, @mapx400 = data
37
- end
38
-
39
- def from_string(input) #:nodoc: all
40
- if (input.length > 0)
41
- names = input.split(" ")
42
- @preference = names[0].to_i
43
- @map822 = Name.create(names[1])
44
- @mapx400 = Name.create(names[2])
45
- end
46
- end
47
-
48
- def rdata_to_string #:nodoc: all
49
- if (@preference!=nil)
50
- return "#{@preference} #{@map822.to_s(true)} #{@mapx400.to_s(true)}"
51
- else
52
- return ""
53
- end
54
- end
55
-
56
- def encode_rdata(msg, canonical=false) #:nodoc: all
57
- msg.put_pack('n', @preference)
58
- msg.put_name(@map822, canonical)
59
- msg.put_name(@mapx400, canonical)
60
- end
61
-
62
- def self.decode_rdata(msg) #:nodoc: all
63
- preference, = msg.get_unpack('n')
64
- map822 = msg.get_name
65
- mapx400 = msg.get_name
66
- return self.new([preference, map822, mapx400])
67
- end
68
- end
69
- end
70
- 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
+ module Dnsruby
17
+ class RR
18
+ module IN
19
+ class PX < RR
20
+ ClassHash[[TypeValue = Types::PX, ClassValue = Classes::IN]] = self #:nodoc: all
21
+
22
+ # The preference given to this RR.
23
+ attr_accessor :preference
24
+ # The RFC822 part of the RFC1327 mapping information.
25
+ attr_accessor :map822
26
+ # The X.400 part of the RFC1327 mapping information.
27
+ attr_accessor :mapx400
28
+
29
+ def from_hash(hash) #:nodoc: all
30
+ @preference = hash[:preference]
31
+ @map822 = Name.create(hash[:map822])
32
+ @mapx400 = Name.create(hash[:mapx400])
33
+ end
34
+
35
+ def from_data(data) #:nodoc: all
36
+ @preference, @map822, @mapx400 = data
37
+ end
38
+
39
+ def from_string(input) #:nodoc: all
40
+ if (input.length > 0)
41
+ names = input.split(" ")
42
+ @preference = names[0].to_i
43
+ @map822 = Name.create(names[1])
44
+ @mapx400 = Name.create(names[2])
45
+ end
46
+ end
47
+
48
+ def rdata_to_string #:nodoc: all
49
+ if (@preference!=nil)
50
+ return "#{@preference} #{@map822.to_s(true)} #{@mapx400.to_s(true)}"
51
+ else
52
+ return ""
53
+ end
54
+ end
55
+
56
+ def encode_rdata(msg, canonical=false) #:nodoc: all
57
+ msg.put_pack('n', @preference)
58
+ msg.put_name(@map822, canonical)
59
+ msg.put_name(@mapx400, canonical)
60
+ end
61
+
62
+ def self.decode_rdata(msg) #:nodoc: all
63
+ preference, = msg.get_unpack('n')
64
+ map822 = msg.get_name
65
+ mapx400 = msg.get_name
66
+ return self.new([preference, map822, mapx400])
67
+ end
68
+ end
69
+ end
70
+ end
71
71
  end
@@ -1,75 +1,75 @@
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 Responsible Person (RP) resource records.
19
- #RFC 1183 Section 2.2
20
- class RP < RR
21
- ClassValue = nil #:nodoc: all
22
- TypeValue = Types::RP #:nodoc: all
23
-
24
- #Returns a domain name that specifies the mailbox for the responsible person.
25
- attr_reader :mailbox
26
- #A domain name that specifies a TXT record containing further
27
- #information about the responsible person.
28
- attr_reader :txtdomain
29
-
30
- def txtdomain=(s)
31
- @txtdomain = Name.create(s)
32
- end
33
-
34
- def mailbox=(s)
35
- @mailbox = Name.create(s)
36
- end
37
-
38
- def from_hash(hash)
39
- @mailbox = Name.create(hash[:mailbox])
40
- @txtdomain = Name.create(hash[:txtdomain])
41
- end
42
-
43
- def from_data(data) #:nodoc: all
44
- @mailbox, @txtdomain= data
45
- end
46
-
47
- def from_string(input) #:nodoc: all
48
- if (input.length > 0)
49
- names = input.split(" ")
50
- @mailbox = Name.create(names[0])
51
- @txtdomain = Name.create(names[1])
52
- end
53
- end
54
-
55
- def rdata_to_string #:nodoc: all
56
- if (@mailbox!=nil)
57
- return "#{@mailbox.to_s(true)} #{@txtdomain.to_s(true)}"
58
- else
59
- return ""
60
- end
61
- end
62
-
63
- def encode_rdata(msg, canonical=false) #:nodoc: all
64
- msg.put_name(@mailbox, canonical)
65
- msg.put_name(@txtdomain, canonical)
66
- end
67
-
68
- def self.decode_rdata(msg) #:nodoc: all
69
- mailbox = msg.get_name
70
- txtdomain = msg.get_name
71
- return self.new([mailbox, txtdomain])
72
- end
73
- end
74
- end
75
- 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
+ module Dnsruby
17
+ class RR
18
+ # Class for DNS Responsible Person (RP) resource records.
19
+ # RFC 1183 Section 2.2
20
+ class RP < RR
21
+ ClassValue = nil #:nodoc: all
22
+ TypeValue = Types::RP #:nodoc: all
23
+
24
+ # Returns a domain name that specifies the mailbox for the responsible person.
25
+ attr_reader :mailbox
26
+ # A domain name that specifies a TXT record containing further
27
+ # information about the responsible person.
28
+ attr_reader :txtdomain
29
+
30
+ def txtdomain=(s)
31
+ @txtdomain = Name.create(s)
32
+ end
33
+
34
+ def mailbox=(s)
35
+ @mailbox = Name.create(s)
36
+ end
37
+
38
+ def from_hash(hash)
39
+ @mailbox = Name.create(hash[:mailbox])
40
+ @txtdomain = Name.create(hash[:txtdomain])
41
+ end
42
+
43
+ def from_data(data) #:nodoc: all
44
+ @mailbox, @txtdomain= data
45
+ end
46
+
47
+ def from_string(input) #:nodoc: all
48
+ if (input.length > 0)
49
+ names = input.split(" ")
50
+ @mailbox = Name.create(names[0])
51
+ @txtdomain = Name.create(names[1])
52
+ end
53
+ end
54
+
55
+ def rdata_to_string #:nodoc: all
56
+ if (@mailbox!=nil)
57
+ return "#{@mailbox.to_s(true)} #{@txtdomain.to_s(true)}"
58
+ else
59
+ return ""
60
+ end
61
+ end
62
+
63
+ def encode_rdata(msg, canonical=false) #:nodoc: all
64
+ msg.put_name(@mailbox, canonical)
65
+ msg.put_name(@txtdomain, canonical)
66
+ end
67
+
68
+ def self.decode_rdata(msg) #:nodoc: all
69
+ mailbox = msg.get_name
70
+ txtdomain = msg.get_name
71
+ return self.new([mailbox, txtdomain])
72
+ end
73
+ end
74
+ end
75
+ end