dnsruby 1.43 → 1.44

Sign up to get free protection for your applications and to get access to all the features.
@@ -79,13 +79,15 @@ module Dnsruby
79
79
  # from the wire, already decoded
80
80
  types =t
81
81
  elsif (t.instance_of?String)
82
- if t[t.length-1, t.length]!=")"
83
- t = t + " )"
82
+ if (index = t.index";")
83
+ t = t[0, index]
84
+ end
85
+ if (index = t.index")")
86
+ t = t[0, index]
84
87
  end
85
88
  # List of mnemonics
86
89
  types=[]
87
90
  mnemonics = t.split(" ")
88
- mnemonics.pop
89
91
  mnemonics.each do |m|
90
92
  type = Types.new(m)
91
93
  types.push(type)
@@ -261,6 +263,7 @@ module Dnsruby
261
263
  len = len + data[1].length
262
264
  end
263
265
  self.types=(input[len, input.length-len])
266
+ @types = NSEC.get_types(input[len, input.length-len])
264
267
  end
265
268
  end
266
269
 
@@ -131,10 +131,15 @@ module Dnsruby
131
131
 
132
132
  n = Name.create(name)
133
133
  out = n.canonical
134
+ begin
134
135
  (0..iterations).each {
135
136
  out =NSEC3.h(out + salt, hash_alg);
136
137
  }
137
138
  return Base32.encode32hex(out).downcase
139
+ rescue ArgumentError
140
+ TheLog.error("Unknown hash algorithm #{hash_alg} used for NSEC3 hash")
141
+ return "Unknown NSEC3 hash algorithm"
142
+ end
138
143
  end
139
144
 
140
145
  def h(x) # :nodoc: all
@@ -142,11 +147,10 @@ module Dnsruby
142
147
  end
143
148
 
144
149
  def NSEC3.h(x, hash_alg) # :nodoc: all
145
- if Nsec3HashAlgorithms.SHA_1 == hash_alg
150
+ if (Nsec3HashAlgorithms.SHA_1 == hash_alg)
146
151
  return Digest::SHA1.digest(x)
147
152
  end
148
- TheLog.error("Unknown hash algorithm #{hash_alg} used for NSEC3 hash")
149
- return "Unknown NSEC3 hash algorithm"
153
+ raise ArgumentError.new("Unknown hash algorithm")
150
154
  end
151
155
 
152
156
  def hash_alg=(a)
@@ -264,9 +268,7 @@ module Dnsruby
264
268
  self.hash_alg=(data[0]).to_i
265
269
  self.flags=(data[1]).to_i
266
270
  self.iterations=(data[2]).to_i
267
- # self.salt=NSEC3.decode_salt(data[3])
268
271
  self.salt=(data[3])
269
- # self.salt_length=(@salt.length)
270
272
 
271
273
  len = data[0].length + data[1].length + data[2].length + data[3].length + 4
272
274
  # There may or may not be brackets around next_hashed
@@ -185,7 +185,6 @@ module Dnsruby
185
185
  msg.put_pack('n', opt.data.length)
186
186
  msg.put_bytes(opt.data)
187
187
  end
188
- msg.put_array(@options)
189
188
  end
190
189
  end
191
190
 
@@ -179,8 +179,8 @@ module Dnsruby
179
179
  self.signature=buf.unpack("m*")[0]
180
180
  end
181
181
  end
182
-
183
- def get_time(input)
182
+
183
+ def RRSIG.get_time(input)
184
184
  if (input.kind_of?Fixnum)
185
185
  return input
186
186
  end
@@ -217,6 +217,10 @@ module Dnsruby
217
217
  end
218
218
  end
219
219
 
220
+ def get_time(input)
221
+ return RRSIG.get_time(input)
222
+ end
223
+
220
224
  def format_time(time)
221
225
  return Time.at(time).gmtime.strftime("%Y%m%d%H%M%S")
222
226
  end
@@ -276,7 +276,7 @@ module Dnsruby
276
276
  if (ret = res.check_response(msg, bytes, query, client_queue, id, tcp))
277
277
  remove_id(id)
278
278
  exception = msg.get_exception
279
- if (ret.instance_of?TsigError)
279
+ if (ret.kind_of?TsigError)
280
280
  exception = ret
281
281
  end
282
282
  Dnsruby.log.debug{"Pushing response to client queue"}
@@ -68,7 +68,7 @@ module Dnsruby
68
68
  # Process the next line of the file
69
69
  # Returns a string representing the normalised line.
70
70
  def process_line(line, do_prefix_hack = false)
71
- return nil if (line.index(';') == 0)
71
+ return nil if (line[0,1] == ";")
72
72
  return nil if (line.strip.length == 0)
73
73
  return nil if (!line || (line.length == 0))
74
74
  @in_quoted_section = false if !@continued_line
data/lib/dnsruby.rb CHANGED
@@ -104,7 +104,7 @@ require 'Dnsruby/TheLog'
104
104
  module Dnsruby
105
105
 
106
106
  # @TODO@ Remember to update version in dnsruby.gemspec!
107
- VERSION = 1.43
107
+ VERSION = 1.44
108
108
  def Dnsruby.version
109
109
  return VERSION
110
110
  end
@@ -462,6 +462,10 @@ module Dnsruby
462
462
  class TsigError < OtherResolvError
463
463
  end
464
464
 
465
+ # Sent a signed packet, got an unsigned response
466
+ class TsigNotSignedResponseError < TsigError
467
+ end
468
+
465
469
  #Indicates an error in decoding an incoming DNS message
466
470
  class DecodeError < ResolvError
467
471
  end
data/test/tc_nsec3.rb CHANGED
@@ -127,6 +127,15 @@ class Nsec3Test < Test::Unit::TestCase
127
127
  assert(nsec.to_s.include?(Types.TYPE65534.string))
128
128
  end
129
129
 
130
+ def test_types
131
+ rr = RR.create("tfkha3ph6qs16qu3oqtmnfc5tbckpjl7.archi.amt. 1209600 IN NSEC3 1 1 5 - 1tmmto81uc71moj44cli3m6avs5l44l3 NSEC3 CNAME RRSIG ; flags: optout")
132
+ assert(rr.types.include?Types::NSEC3)
133
+ assert(rr.types.include?Types::CNAME)
134
+ assert(rr.types.include?Types::RRSIG)
135
+ rr = RR.create("929p027vb26s89h6fv5j7hmsis4tcr1p.tjeb.nl. 3600 IN NSEC3 1 0 5 beef 9rs4nbe7128ap5i6v196ge2iag5b7rcq A AAAA RRSIG
136
+ ")
137
+ end
138
+
130
139
  def test_rfc_examples
131
140
  print "IMPLEMENT NSEC3 validation!\n"
132
141
  return
data/test/tc_rrsig.rb CHANGED
@@ -32,8 +32,8 @@ class RrsigTest < Test::Unit::TestCase
32
32
  assert_equal(Dnsruby::Algorithms::RSASHA1, rrsig.algorithm)
33
33
  assert_equal(3, rrsig.labels)
34
34
  assert_equal(86400, rrsig.original_ttl)
35
- assert_equal(Time.mktime(2003,03,22,17,31, 03).to_i, rrsig.expiration)
36
- assert_equal(Time.mktime(2003,02,20,17,31,03).to_i, rrsig.inception)
35
+ assert_equal(Time.gm(2003,03,22,17,31, 03).to_i, rrsig.expiration)
36
+ assert_equal(Time.gm(2003,02,20,17,31,03).to_i, rrsig.inception)
37
37
  assert_equal(2642, rrsig.key_tag)
38
38
  assert_equal(Dnsruby::Name.create("example.com."), rrsig.signers_name)
39
39
  assert_equal("oJB1W6WNGv+ldvQ3WDG0MQkg5IEhjRip8WTr" +
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.43"
4
+ version: "1.44"
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: 2010-02-02 00:00:00 +00:00
12
+ date: 2010-03-03 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -25,6 +25,7 @@ extra_rdoc_files:
25
25
  - README
26
26
  - EVENTMACHINE
27
27
  files:
28
+ - Rakefile
28
29
  - test/custom.txt
29
30
  - test/resolv.conf
30
31
  - test/tc_axfr.rb