dnsruby 1.41 → 1.42

Sign up to get free protection for your applications and to get access to all the features.
@@ -254,7 +254,7 @@ module Dnsruby
254
254
  end
255
255
  end
256
256
  else
257
- warn "Server ["+(@@nameservers)[0].to_s+"] did not give answers"
257
+ warn "Server ["+(@@nameservers)[0].to_s+".] did not give answers"
258
258
  end
259
259
 
260
260
  # Disable recursion flag.
@@ -98,6 +98,9 @@ module Dnsruby
98
98
 
99
99
  # The current Config
100
100
  attr_reader :config
101
+
102
+ # Does this Resolver cache answers, and attempt to retrieve answer from the cache?
103
+ attr_reader :do_caching
101
104
 
102
105
  # The array of SingleResolvers used for sending query messages
103
106
  # attr_accessor :single_resolvers # :nodoc:
@@ -331,7 +334,7 @@ module Dnsruby
331
334
  if (@single_resolvers.length == 0)
332
335
  Thread.start {
333
336
  sleep(@query_timeout == 0 ? 1 : @query_timeout)
334
- args[1].push([client_query_id, nil, ResolvTimeout.new])
337
+ args[1].push([client_query_id, nil, ResolvTimeout.new("Query timed out - no nameservers configured")])
335
338
  }
336
339
  end
337
340
  return client_query_id
@@ -625,7 +628,8 @@ module Dnsruby
625
628
  #Pass in either a Dnsruby::RR::TSIG, or a key_name and key (or just a key)
626
629
  #Pass in nil to stop tsig signing.
627
630
  #* res.tsig=(tsig_rr)
628
- #* res.tsig=(key_name, key)
631
+ #* res.tsig=(key_name, key) # defaults to hmac-md5
632
+ #* res.tsig=(key_name, key, alg) # e.g. alg = "hmac-sha1"
629
633
  #* res.tsig=nil # Stop the resolver from signing
630
634
  def tsig=(t)
631
635
  @tsig=t
@@ -639,7 +643,11 @@ module Dnsruby
639
643
  if (args[0].instance_of?RR::TSIG)
640
644
  tsig = args[0]
641
645
  elsif (args[0].instance_of?Array)
642
- tsig = RR.new_from_hash({:type => Types.TSIG, :klass => Classes.ANY, :name => args[0][0], :key => args[0][1]})
646
+ if (args[0].length > 2)
647
+ tsig = RR.new_from_hash({:type => Types.TSIG, :klass => Classes.ANY, :name => args[0][0], :key => args[0][1], :algorithm => args[0][2]})
648
+ else
649
+ tsig = RR.new_from_hash({:type => Types.TSIG, :klass => Classes.ANY, :name => args[0][0], :key => args[0][1]})
650
+ end
643
651
  end
644
652
  else
645
653
  # Dnsruby.log.debug{"TSIG signing switched off"}
@@ -647,6 +655,8 @@ module Dnsruby
647
655
  end
648
656
  elsif (args.length ==2)
649
657
  tsig = RR.new_from_hash({:type => Types.TSIG, :klass => Classes.ANY, :name => args[0], :key => args[1]})
658
+ elsif (args.length ==3)
659
+ tsig = RR.new_from_hash({:type => Types.TSIG, :klass => Classes.ANY, :name => args[0], :key => args[1], :algorithm => args[2]})
650
660
  else
651
661
  raise ArgumentError.new("Wrong number of arguments to tsig=")
652
662
  end
@@ -210,7 +210,8 @@ module Dnsruby
210
210
  msg.security_level = Message::SecurityLevel.SECURE
211
211
  return true
212
212
  end
213
- rescue VerifyError
213
+ rescue VerifyError => e
214
+ msg.security_error = e
214
215
  end
215
216
  end
216
217
 
@@ -254,6 +255,7 @@ module Dnsruby
254
255
  end
255
256
  # Set the message security level!
256
257
  msg.security_level = last_level
258
+ msg.security_error = last_error
257
259
  raise VerifyError.new(last_error) if (last_level < 0)
258
260
  return (msg.security_level.code > Message::SecurityLevel::UNCHECKED)
259
261
  end
@@ -323,13 +323,15 @@ module Dnsruby
323
323
 
324
324
  # Return the rrsets of the specified type in the message
325
325
  def rrsets(type, klass=Classes::IN)
326
- rrsets = []
326
+ rrsetss = []
327
327
  [@answer, @authority, @additional].each do |section|
328
- if ((rrset = section.rrsets(type, klass)).length > 0)
329
- rrsets.push(rrset)
328
+ if ((rrsets = section.rrsets(type, klass)).length > 0)
329
+ rrsets.each {|rrset|
330
+ rrsetss.push(rrset)
331
+ }
330
332
  end
331
333
  end
332
- return rrsets
334
+ return rrsetss
333
335
  end
334
336
 
335
337
  # Return a hash, with the section as key, and the RRSets in that
@@ -240,7 +240,7 @@ module Dnsruby
240
240
  # sect 5.1)
241
241
  # out: an array of labels in wire format.
242
242
  def self.name2encodedlabels (dName) #:nodoc: all
243
- # Check for "/" in the name : If there, then decode properly - otherwise, cheat and split on "."
243
+ # Check for "\" in the name : If there, then decode properly - otherwise, cheat and split on "."
244
244
  if (dName.index("\\"))
245
245
  names=[]
246
246
  j=0;
@@ -311,7 +311,7 @@ module Dnsruby
311
311
  length=presentation.length;
312
312
 
313
313
  i=0;
314
-
314
+
315
315
  while (i < length )
316
316
  c=presentation.unpack("x#{i}C1") [0]
317
317
  if (c == 46) # ord('.')
@@ -54,14 +54,26 @@ module Dnsruby
54
54
  @preference = values [1].to_i
55
55
  @flags = values [2].gsub!("\"", "")
56
56
  @service = values [3].gsub!("\"", "")
57
- @regexp = values [4].gsub!("\"", "")
57
+ re = values [4].gsub!("\"", "")
58
+ re.gsub!("\\\\", "\\")
59
+ @regexp = re
58
60
  @replacement = Name.create(values[5])
59
61
  end
60
62
  end
61
-
63
+
62
64
  def rdata_to_string #:nodoc: all
63
65
  if (@order!=nil)
64
- return "#{@order} #{@preference} \"#{@flags}\" \"#{@service}\" \"#{@regexp}\" #{@replacement}"
66
+ ret = "#{@order} #{@preference} \"#{@flags}\" \"#{@service}\" \""
67
+ ##{@regexp}
68
+ @regexp.each_byte {|b|
69
+ c = b.chr
70
+ if (c == "\\")
71
+ ret += "\\"
72
+ end
73
+ ret += c
74
+ }
75
+ ret += "\" #{@replacement}"
76
+ return ret
65
77
  else
66
78
  return ""
67
79
  end
@@ -73,7 +85,7 @@ module Dnsruby
73
85
  msg.put_string(@flags)
74
86
  msg.put_string(@service)
75
87
  msg.put_string(@regexp)
76
- msg.put_name(@replacement, canonical)
88
+ msg.put_name(@replacement, true)
77
89
  end
78
90
 
79
91
  def self.decode_rdata(msg) #:nodoc: all
@@ -85,6 +97,6 @@ module Dnsruby
85
97
  replacement = msg.get_name
86
98
  return self.new([order, preference, flags, service, regexp, replacement])
87
99
  end
88
- end
100
+ end
89
101
  end
90
102
  end
@@ -13,7 +13,10 @@
13
13
  #See the License for the specific language governing permissions and
14
14
  #limitations under the License.
15
15
  #++
16
- require 'shellwords'
16
+ begin
17
+ require 'jcode'
18
+ rescue LoadError => e
19
+ end
17
20
  module Dnsruby
18
21
  class RR
19
22
  #Class for DNS Text (TXT) resource records.
@@ -38,28 +41,127 @@ module Dnsruby
38
41
  from_string(hash[:strings])
39
42
  end
40
43
  end
44
+
45
+ ESCAPE_CHARS = {"b" => 8, "t" => 9, "n" => 10, "v" => 11, "f" => 12, "r" => 13}
46
+ ESCAPE_CODES = ESCAPE_CHARS.invert
41
47
 
42
48
  def from_string(input)
43
- words = Shellwords.shellwords(input)
44
-
45
- @strings=[]
46
-
47
- if (words != nil)
48
- words.each { |string|
49
- string .gsub!(/\\"/, '"')
50
- @strings.push(string)
51
- }
52
- end
49
+ # Need to look out for special characters.
50
+ # Need to split the input up into strings (which are defined by non-escaped " characters)
51
+ # Then need to fix up any \ escape characters (should just be " and ; and binary?)
52
+ # Sadly, it's going to be easiest just to scan through this character by character...
53
+ in_escaped = false
54
+ in_string = false
55
+ count = -1
56
+ strings = []
57
+ current_binary = ""
58
+ current_quote_char = '"'
59
+ unquoted = false
60
+ seen_strings = false
61
+ pos = 0
62
+ input.each_char {|c|
63
+ if (((c == "'") || (c == '"')) && (!in_escaped) && (!unquoted))
64
+ if (!in_string)
65
+ seen_strings = true
66
+ current_quote_char = c
67
+ in_string = true
68
+ count+=1
69
+ strings[count] = ""
70
+ else
71
+ if (c == current_quote_char)
72
+ in_string = false
73
+ else
74
+ strings[count]+=c
75
+ end
76
+ end
77
+ else
78
+ if (seen_strings && !in_string)
79
+ next
80
+ end
81
+ if (pos == 0)
82
+ unquoted = true
83
+ count+=1
84
+ strings[count] = ""
85
+ elsif (unquoted)
86
+ if (c == " ")
87
+ count+=1
88
+ strings[count] = ""
89
+ pos += 1
90
+ next
91
+ end
92
+ end
93
+
94
+ if (c == "\\")
95
+ if (in_escaped)
96
+ in_escaped = false
97
+ strings[count]+=(c)
98
+ else
99
+ in_escaped = true
100
+ end
101
+ else
102
+ if (in_escaped)
103
+ # Build up the binary
104
+ if (c == ";") || (c == '"')
105
+ strings[count]+=c
106
+ in_escaped = false
107
+ elsif (ESCAPE_CHARS[c])
108
+ in_escaped=false
109
+ strings[count]+=ESCAPE_CHARS[c].chr
110
+ elsif (c<"0" || c>"9")
111
+ in_escaped = false
112
+ strings[count]+=c
113
+ else
114
+ # Must be building up three digit string to identify binary value?
115
+ current_binary += c
116
+ if (current_binary.length == 3)
117
+ strings[count]+=current_binary.to_i.chr
118
+ in_escaped = false
119
+ current_binary = ""
120
+ end
121
+ end
122
+ else
123
+ strings[count]+=(c)
124
+ end
125
+ end
126
+ end
127
+ pos += 1
128
+ }
129
+ @strings=strings
53
130
  end
54
131
 
55
132
  def rdata_to_string
56
133
  if (defined?@strings)
57
- temp = @strings.map {|str|
58
- str.gsub(/"/, '\\"')
59
- %<"#{str}">
134
+ temp = []
135
+ @strings.each {|str|
136
+ output = "\""
137
+ # Probably need to scan through each string manually
138
+ # Make sure to remember to escape binary characters.
139
+ # Go through copying to output, and adding "\" characters as necessary?
140
+ str.each_byte {|c|
141
+ if (c == 34) || (c == 92) # || (c == 59)
142
+ output+='\\'
143
+ output+=c.chr
144
+ elsif (c < 32) # c is binary
145
+ if (ESCAPE_CODES[c])
146
+ output += c.chr
147
+ else
148
+ output+= '\\'
149
+ num = c.to_i.to_s
150
+ (3-num.length).times {|i|
151
+ num="0"+num
152
+ }
153
+ output+= num # Need a 3 digit number here.
154
+ end
155
+
156
+ else
157
+ output += c.chr
158
+ end
159
+ }
160
+ output+="\""
161
+ temp.push(output)
60
162
  }
61
163
  return temp.join(' ')
62
- end
164
+ end
63
165
  return ''
64
166
  end
65
167
 
@@ -386,8 +386,6 @@ module Dnsruby
386
386
 
387
387
  if rdata
388
388
  rdata.gsub!(/\s+$/o, "")
389
- rdata.gsub!("(", "")
390
- rdata.gsub!(")", "")
391
389
  end
392
390
 
393
391
  # RFC3597 tweaks
@@ -410,6 +408,14 @@ module Dnsruby
410
408
  if (rrtype == '')
411
409
  rrtype = 'ANY';
412
410
  end
411
+
412
+ if ((rrtype == "NAPTR") || (rrtype == "TXT"))
413
+ else
414
+ if (rdata)
415
+ rdata.gsub!("(", "")
416
+ rdata.gsub!(")", "")
417
+ end
418
+ end
413
419
 
414
420
  if (implemented_rrs.include?(rrtype) && rdata !~/^\s*\\#/o )
415
421
  subclass = _get_subclass(name, rrtype, rrclass, ttl, rdata)
@@ -275,10 +275,10 @@ module Dnsruby
275
275
  if ((msg.answer.size == 0) && (!dsrrset) && (rrset.type == Types.NS)) # (isDelegation)
276
276
  # Now check NSEC(3) records for absence of DS and SOA
277
277
  nsec = msg.authority.rrsets('NSEC')[0]
278
- if (nsec.length == 0)
278
+ if (!nsec || (nsec.length == 0))
279
279
  nsec = msg.authority.rrsets('NSEC3')[0]
280
280
  end
281
- if (nsec.rrs.length > 0)
281
+ if (nsec && (nsec.rrs.length > 0))
282
282
  if (!(nsec.rrs()[0].types.include?'DS') || !(nsec.rrs()[0].types.include?'SOA'))
283
283
  next # delegation which we expect to be unsigned - so don't verify it!
284
284
  end
@@ -49,14 +49,15 @@ module Dnsruby
49
49
  zone = nil
50
50
  IO.foreach(file) { |line|
51
51
  begin
52
- ret = process_line(line)
53
- if (ret)
54
- rr = RR.create(ret)
55
- if (!zone)
56
- zone = []
52
+
53
+ ret = process_line(line)
54
+ if (ret)
55
+ rr = RR.create(ret)
56
+ if (!zone)
57
+ zone = []
58
+ end
59
+ zone.push(rr)
57
60
  end
58
- zone.push(rr)
59
- end
60
61
  rescue Exception => e
61
62
  raise ParseException.new("Error reading line #{line_num} of #{file} : [#{line}]")
62
63
  end
@@ -124,6 +125,10 @@ module Dnsruby
124
125
  # Does a quoted section begin or end in this line?
125
126
  # Are there any semi-colons?
126
127
  # Ary any of the semi-colons inside a quoted section?
128
+ # Handle escape characters
129
+ if (line.index"\\")
130
+ return strip_comments_meticulously(line)
131
+ end
127
132
  while (next_index = line.index(";", last_index + 1))
128
133
  # Have there been any quotes since we last looked?
129
134
  process_quotes(line[last_index, next_index - last_index])
@@ -141,6 +146,44 @@ module Dnsruby
141
146
  return line
142
147
  end
143
148
 
149
+ def strip_comments_meticulously(line)
150
+ # We have escape characters in the text. Go through it character by
151
+ # character and work out what's escaped and quoted and what's not
152
+ escaped = false
153
+ quoted = false
154
+ pos = 0
155
+ line.each_char {|c|
156
+ if (c == "\\")
157
+ if (!escaped)
158
+ escaped = true
159
+ else
160
+ escaped = false
161
+ end
162
+ else
163
+ if (escaped)
164
+ escaped = false
165
+ next
166
+ else
167
+ if (c == "\"")
168
+ if (quoted)
169
+ quoted = false
170
+ else
171
+ quoted = true
172
+ end
173
+ else
174
+ if (c == ";")
175
+ if (!quoted)
176
+ return line[0, pos]
177
+ end
178
+ end
179
+ end
180
+ end
181
+ end
182
+ pos +=1
183
+ }
184
+ return line
185
+ end
186
+
144
187
  def process_quotes(section)
145
188
  # Look through the section of text and set the @in_quoted_section
146
189
  # as it should be at the end of the given section
@@ -161,16 +204,23 @@ module Dnsruby
161
204
  line = @last_name + " " + line
162
205
  end
163
206
  line.chomp!
164
- line.sub!("(", "")
165
- line.sub!(")", "")
166
- line.sub!("@ ", "#{@origin} ")
167
- line.sub!("@\t", "#{@origin} ")
207
+ line.sub!(/\s+@$/, " #{@origin}") # IN CNAME @
208
+ line.sub!(/^@\s+/, "#{@origin} ") # IN CNAME @
209
+ line.sub!(/\s+@\s+/, " #{@origin} ")
168
210
  line.strip!
169
211
 
170
212
 
171
213
  # o We need to identify the domain name in the record, and then
172
214
  split = line.split(' ') # split on whitespace
173
215
  name = split[0].strip
216
+ if (name.index"\\")
217
+ old_name = name
218
+ name = Name.create(name).to_s
219
+ if (/\.\z/ =~ old_name)
220
+ name += "."
221
+ end
222
+ line.sub!(old_name, name)
223
+ end
174
224
  # o add $ORIGIN to it if it is not absolute
175
225
  if !(/\.\z/ =~ name)
176
226
  new_name = name + "." + @origin
@@ -240,6 +290,11 @@ module Dnsruby
240
290
  type_string=prefix_for_rrset_order(type, type_was)
241
291
  @last_name = name
242
292
 
293
+ if !([Types::NAPTR, Types::TXT].include?type_was)
294
+ line.sub!("(", "")
295
+ line.sub!(")", "")
296
+ end
297
+
243
298
  if (is_soa)
244
299
  if (@soa_ttl)
245
300
  # Replace the %MISSING_TTL% text with the SOA TTL from the config
@@ -102,6 +102,12 @@ require 'Dnsruby/TheLog'
102
102
  #* /etc/nsswitch.conf is not supported.
103
103
  #* NSEC3 validation still TBD
104
104
  module Dnsruby
105
+
106
+ # @TODO@ Remember to update version in dnsruby.gemspec!
107
+ VERSION = 1.42
108
+ def Dnsruby.version
109
+ return VERSION
110
+ end
105
111
 
106
112
  @@logger = Logger.new(STDOUT)
107
113
  @@logger.level = Logger::FATAL
@@ -260,6 +266,7 @@ module Dnsruby
260
266
  CERT = 37 # RFC 2538
261
267
  DNAME = 39 # RFC 2672
262
268
  OPT = 41 # RFC 2671
269
+ # APL = 42 # RFC 3123
263
270
  DS = 43 # RFC 4034
264
271
  SSHFP = 44 # RFC 4255
265
272
  IPSECKEY = 45 # RFC 4025
@@ -125,9 +125,9 @@ class TestMisc < Test::Unit::TestCase
125
125
  assert_equal("736f7274206f66202220746578743b20616e642062696e61727920002064617461", temp,"Second Char string in TXT RR read from wireformat")
126
126
 
127
127
 
128
- txtRr2=Dnsruby::RR.create('txt2.t.dnsruby.validation-test-servers.nominet.org.uk. 60 IN TXT "Test1 \" \ more stuff" "Test2"')
128
+ txtRr2=Dnsruby::RR.create('txt2.t.dnsruby.validation-test-servers.nominet.org.uk. 60 IN TXT "Test1 \" \; more stuff" "Test2"')
129
129
 
130
- assert_equal((txtRr2.strings)[0],'Test1 " more stuff', "First arg string in TXT RR read from zonefileformat")
130
+ assert_equal((txtRr2.strings)[0],'Test1 " ; more stuff', "First arg string in TXT RR read from zonefileformat")
131
131
  assert_equal((txtRr2.strings)[1],'Test2',"Second Char string in TXT RR read from zonefileformat")
132
132
 
133
133
 
@@ -45,4 +45,10 @@ class TestNAPTR < Test::Unit::TestCase
45
45
  naptr.flags = "u"
46
46
  end
47
47
 
48
+ def test_string
49
+ txt = 'all.rr.org. 7200 IN NAPTR 100 10 "" "" "/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i" .'
50
+ rr = RR.create(txt)
51
+ assert(rr.to_s.index('"/urn:cid:.+@([^\\\\.]+\\\\.)(.*)$/\\\\2/i"'), '"/urn:cid:.+@([^\\\\.]+\\\\.)(.*)$/\\\\2/i"' + "\n" + rr.to_s)
52
+ end
53
+
48
54
  end
@@ -134,4 +134,9 @@ class TestRrTest < Test::Unit::TestCase
134
134
 
135
135
 
136
136
  end
137
+
138
+ def test_nasty_txt
139
+ t = RR.create('txt2.t.net-dns.org. 60 IN TXT "Net-DNS\; complicated $tuff" "sort of \" text\; and binary \000 data"')
140
+ assert(t.rdata.to_s == '"Net-DNS\; complicated $tuff" "sort of \" text\; and binary \000 data"', t.to_s)
141
+ end
137
142
  end
@@ -20,7 +20,7 @@ require 'dnsruby'
20
20
  class VerifierTest < Test::Unit::TestCase
21
21
 
22
22
  def test_sha2
23
- # @TODO@ Check if OpenSSL supports SHA2
23
+ # Check if OpenSSL supports SHA2
24
24
  have_sha2 = false
25
25
  begin
26
26
  OpenSSL::Digest::SHA256.new
@@ -35,7 +35,7 @@ class VerifierTest < Test::Unit::TestCase
35
35
  print "OpenSSL doesn't support SHA2 - disabling SHA256/SHA512 tests. DNSSEC validation will not work with these type of signatures.\n"
36
36
  end
37
37
  end
38
-
38
+
39
39
  def do_test_sha256
40
40
  key256 = Dnsruby::RR.create("example.net. 3600 IN DNSKEY (256 3 8 AwEAAcFcGsaxxdgiuuGmCkVI
41
41
  my4h99CqT7jwY3pexPGcnUFtR2Fh36BponcwtkZ4cAgtvd4Qs8P
@@ -69,7 +69,7 @@ class VerifierTest < Test::Unit::TestCase
69
69
  verifier = Dnsruby::SingleVerifier.new(nil)
70
70
  verifier.verify_rrset(rrset, key512)
71
71
  end
72
-
72
+
73
73
  def test_se_query
74
74
  # Run some queries on the .se zone
75
75
  Dnsruby::Dnssec.clear_trusted_keys
@@ -243,4 +243,66 @@ class VerifierTest < Test::Unit::TestCase
243
243
  # }
244
244
  assert(verified > 0)
245
245
  end
246
+
247
+ def test_naptr
248
+ key = Dnsruby::RR.create("all.rr.org. 2678400 IN DNSKEY 256 3 7 AwEAAcW1ZJxnMxZAAfsQ0JJQPHOlVNeGzs/AWVSGXiIYsg9UUSsvRTiK/Wy2wD7XC6osZpgy4Blhm846wktPbCwHpkxxbjxpaMABjbhH14gRol1Gpzf+gOr8vpdii8c2y6VMN9kIXZyaZUWcshLii19ysSGlqY1a1g2XZjogFtvzDHjH ;{id = 43068 (zsk), size = 1024b}")
249
+ verifier = Dnsruby::SingleVerifier.new(Dnsruby::SingleVerifier::VerifierType::ANCHOR)
250
+ key_rrset = Dnsruby::RRSet.new(key)
251
+ verifier.add_trusted_key(key_rrset);
252
+ sig = Dnsruby::RR.create("all.rr.org. 86400 IN RRSIG NAPTR 7 3 86400 20100727230632 20090919145743 43068 all.rr.org. RpyBsaLiaZ/OqX5twE0SoMhlVZVAHuAlS4FZqmnAg+udF3EwrY6N/POt3nPCtgwf7tczaxrMK6zWkOldfv37iyIgXIxDQvhoCb7IoffI5TsBL5CWl5n7pg8BNAMpLxd8HIu1DShWvlplpFbBWIaC6tZCR6ft/iP+uhU7dYcqTHg= ;{id = 43068}")
253
+ naptr = Dnsruby::RR.create('all.rr.org. 86400 IN NAPTR 100 10 "" "" "!^urn:cid:.+@([^\\\\.]+\\\\.)(.*)$!\\\\2!i" .')
254
+ rrset = Dnsruby::RRSet.new(naptr)
255
+ rrset.add(sig)
256
+ verifier.verify_rrset(rrset, key_rrset)
257
+ end
258
+
259
+ def test_txt_rr
260
+ txt = 'txt2.all.rr.org. 86400 IN TXT "Net-DNS\\\\; complicated $tuff" "sort of \\" text\\\\; and binary \\000 data"'
261
+ rr = Dnsruby::RR.create(txt)
262
+ assert(rr.to_s.index('"Net-DNS\\\\; complicated $tuff" "sort of \\" text\\\\; and binary \\000 data"'), rr.to_s)
263
+
264
+ key = Dnsruby::RR.create("all.rr.org. 2678400 IN DNSKEY 256 3 7 AwEAAcW1ZJxnMxZAAfsQ0JJQPHOlVNeGzs/AWVSGXiIYsg9UUSsvRTiK/Wy2wD7XC6osZpgy4Blhm846wktPbCwHpkxxbjxpaMABjbhH14gRol1Gpzf+gOr8vpdii8c2y6VMN9kIXZyaZUWcshLii19ysSGlqY1a1g2XZjogFtvzDHjH ;{id = 43068 (zsk), size = 1024b}")
265
+ verifier = Dnsruby::SingleVerifier.new(Dnsruby::SingleVerifier::VerifierType::ANCHOR)
266
+ key_rrset = Dnsruby::RRSet.new(key)
267
+ verifier.add_trusted_key(key_rrset);
268
+ sig = Dnsruby::RR.create("txt2.all.rr.org. 86400 IN RRSIG TXT 7 4 86400 20100813002344 20091006093439 43068 all.rr.org. LJv/ccd2JHyT6TK74Dtu/zH4jdeR4ScyrB8cGwaqeCjwxG4H5FY88Sk/U0JUQyxnUificnyZQwcyXAItn7QjBMHQO4ftVxl/gDCyt6MEXy9JKK/rfvXcAceo5prmlVrb8WxT5YnvPha3CxjK7f+YIs5cqppRVaZTQTxsAsJyJ20= ;{id = 43068}")
269
+ txt = Dnsruby::RR.create('txt2.all.rr.org. 86400 IN TXT "Net-DNS\\\\; complicated $tuff" "sort of \\" text\\\\; and binary \\000 data"')
270
+ rrset = Dnsruby::RRSet.new(txt)
271
+ rrset.add(sig)
272
+ verifier.verify_rrset(rrset, key_rrset)
273
+ end
274
+
275
+ # def test_txt_from_zone
276
+ # reader = Dnsruby::ZoneReader.new("all.rr.org.")
277
+ # zone = reader.process_file("zone.txt")
278
+ # rrset = Dnsruby::RRSet.new
279
+ # key_rrset = Dnsruby::RRSet.new
280
+ # zone.each {|rr|
281
+ # if ( (rr.type == Dnsruby::Types.TXT) || ((rr.type == Dnsruby::Types.RRSIG) && (rr.type_covered == Dnsruby::Types.TXT)))
282
+ # rrset.add(rr)
283
+ # end
284
+ # if (rr.type == Dnsruby::Types.DNSKEY)
285
+ # key_rrset.add(rr)
286
+ # end
287
+ # }
288
+ # verifier = Dnsruby::SingleVerifier.new(Dnsruby::SingleVerifier::VerifierType::ANCHOR)
289
+ # verifier.verify_rrset(rrset, key_rrset)
290
+ # end
291
+
292
+ # def test_naptr_from_zone
293
+ # reader = Dnsruby::ZoneReader.new("all.rr.org.")
294
+ # zone = reader.process_file("zone.txt")
295
+ # rrset = Dnsruby::RRSet.new
296
+ # key_rrset = Dnsruby::RRSet.new
297
+ # zone.each {|rr|
298
+ # if ((rr.type == Dnsruby::Types.NAPTR) || ((rr.type == Dnsruby::Types.RRSIG) && (rr.type_covered == Dnsruby::Types.NAPTR)))
299
+ # rrset.add(rr)
300
+ # end
301
+ # if (rr.type == Dnsruby::Types.DNSKEY)
302
+ # key_rrset.add(rr)
303
+ # end
304
+ # }
305
+ # verifier = Dnsruby::SingleVerifier.new(Dnsruby::SingleVerifier::VerifierType::ANCHOR)
306
+ # verifier.verify_rrset(rrset, key_rrset)
307
+ # end
246
308
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsruby
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.41"
4
+ version: "1.42"
5
5
  platform: ruby
6
6
  authors:
7
7
  - AlexD
@@ -9,7 +9,7 @@ autorequire: dnsruby
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-02 00:00:00 +00:00
12
+ date: 2010-01-08 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15