dnsruby 1.48 → 1.49

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,6 +41,9 @@ module Dnsruby
41
41
  @cache = Hash.new
42
42
  }
43
43
  end
44
+ def length
45
+ return @cache.length
46
+ end
44
47
  def add(message)
45
48
  q = message.question[0]
46
49
  key = CacheKey.new(q.qname, q.qtype, q.qclass).to_s
@@ -423,10 +423,10 @@ module Dnsruby
423
423
  # Add the Config nameservers
424
424
  @config.nameserver.each do |ns|
425
425
  res = PacketSender.new({:server=>ns, :dnssec=>@dnssec,
426
- :use_tcp=>@use_tcp, :no_tcp=>@no_tcp, :packet_timeout=>@packet_timeout,
427
- :tsig => @tsig, :ignore_truncation=>@ignore_truncation,
428
- :src_address=>@src_address, :src_port=>@src_port,
429
- :recurse=>@recurse, :udp_size=>@udp_size})
426
+ :use_tcp=>@use_tcp, :no_tcp=>@no_tcp, :packet_timeout=>@packet_timeout,
427
+ :tsig => @tsig, :ignore_truncation=>@ignore_truncation,
428
+ :src_address=>@src_address, :src_port=>@src_port,
429
+ :recurse=>@recurse, :udp_size=>@udp_size})
430
430
  @single_resolvers.push(res) if res
431
431
  end
432
432
  }
@@ -615,8 +615,8 @@ module Dnsruby
615
615
  def Resolver.port_in_range(p)
616
616
  if ((p == 0) || ((p >= 50000) && (p <= 65535)))
617
617
  # @TODO@ IANA port bitmap - use 50000 - 65535 for now
618
- # ((Iana::IANA_PORTS.index(p)) == nil &&
619
- # (p > 1024) && (p < 65535)))
618
+ # ((Iana::IANA_PORTS.index(p)) == nil &&
619
+ # (p > 1024) && (p < 65535)))
620
620
  return true
621
621
  end
622
622
  return false
@@ -1073,10 +1073,12 @@ module Dnsruby
1073
1073
  timeouts = @timeouts[client_query_id]
1074
1074
  if (!(error.to_s=~/Errno::EMFILE/))
1075
1075
  Dnsruby.log.debug{"Removing #{resolver.server} from resolver list for this query"}
1076
- timeouts[1].each do |key, value|
1077
- res = value[0]
1078
- if (res == resolver)
1079
- timeouts[1].delete(key)
1076
+ if (timeouts)
1077
+ timeouts[1].each do |key, value|
1078
+ res = value[0]
1079
+ if (res == resolver)
1080
+ timeouts[1].delete(key)
1081
+ end
1080
1082
  end
1081
1083
  end
1082
1084
  # Also stick it to the back of the list for future queries
@@ -1085,7 +1087,7 @@ module Dnsruby
1085
1087
  Dnsruby.log.debug{"NOT Removing #{resolver.server} due to Errno::EMFILE"}
1086
1088
  end
1087
1089
  # - if it was the last server, then return an error to the client (and clean up)
1088
- if (outstanding.empty? && timeouts && timeouts[1].values.empty?)
1090
+ if (outstanding.empty? && ((!timeouts) || (timeouts && timeouts[1].values.empty?)))
1089
1091
  # if (outstanding.empty?)
1090
1092
  Dnsruby.log.debug{"Sending error to client"}
1091
1093
  send_result_and_stop_querying(client_queue, client_query_id, select_queue, response, error)
@@ -58,6 +58,8 @@ module Dnsruby
58
58
  @@queued_responses=[]
59
59
  @@queued_validation_responses=[]
60
60
  @@wakeup_sockets = get_socket_pair
61
+ @@sockets << @@wakeup_sockets[1]
62
+
61
63
  # Suppress reverse lookups
62
64
  BasicSocket.do_not_reverse_lookup = true
63
65
  # end
@@ -75,7 +77,7 @@ module Dnsruby
75
77
  srv = nil
76
78
  begin
77
79
  srv = TCPServer.new('localhost', 0)
78
- rescue Errno::EADDRNOTAVAIL # OSX Snow Leopard issue - need to use explicit IP
80
+ rescue Errno::EADDRNOTAVAIL, SocketError # OSX Snow Leopard issue - need to use explicit IP
79
81
  begin
80
82
  srv = TCPServer.new('127.0.0.1', 0)
81
83
  rescue Error # Try IPv6
@@ -164,7 +166,6 @@ module Dnsruby
164
166
  timeouts = @@timeouts.values
165
167
  has_observer = !@@observers.empty?
166
168
  }
167
- sockets << @@wakeup_sockets[1]
168
169
  if (timeouts.length > 0)
169
170
  timeouts.sort!
170
171
  timeout = timeouts[0] - Time.now
@@ -176,7 +176,7 @@ module Dnsruby
176
176
  else
177
177
  if (c == ";")
178
178
  if (!quoted)
179
- return line[0, pos]
179
+ return line[0, pos+1]
180
180
  end
181
181
  end
182
182
  end
@@ -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.48
107
+ VERSION = 1.49
108
108
  def Dnsruby.version
109
109
  return VERSION
110
110
  end
@@ -53,8 +53,9 @@ class TestDlv < Test::Unit::TestCase
53
53
  ret = res.query("ns2.nic.se", Dnsruby::Types.A)
54
54
  assert(ret.security_level == Dnsruby::Message::SecurityLevel::SECURE)
55
55
 
56
- ret = res.query("b.ns.nic.cz", Dnsruby::Types.A)
57
- assert(ret.security_level == Dnsruby::Message::SecurityLevel::SECURE)
56
+ # .cz no longer in dlv?
57
+ # ret = res.query("b.ns.nic.cz", Dnsruby::Types.A)
58
+ # assert(ret.security_level == Dnsruby::Message::SecurityLevel::SECURE)
58
59
 
59
60
  # Test .gov
60
61
  # Dnsruby::TheLog.level = Logger::DEBUG
@@ -141,5 +141,10 @@ class TestRrTest < Test::Unit::TestCase
141
141
  def test_nasty_txt
142
142
  t = RR.create('txt2.t.net-dns.org. 60 IN TXT "Net-DNS\; complicated $tuff" "sort of \" text\; and binary \000 data"')
143
143
  assert(t.rdata.to_s == '"Net-DNS\; complicated $tuff" "sort of \" text\; and binary \000 data"', t.to_s)
144
+
145
+ r1 = RR.create("auto._domainkey.cacert.org. 43200 IN TXT \"v=DKIM1\;g=*\;k=rsa\;p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDNFxiNr+NHJwih3OPhGr4iwLE+BBDu72YrMSzUnU1FF50CW7iOtuhg796UZ6xrZ5VuhAix6YmmzcvF2UxYzoD/XpfZ4MzBu0ND4/nkt9/YOTyIBzwQqn9uMNve0Y76Zsel89dIJtOI+y+lfnFExV0jKwe53gzmxMVpMSSCcZPGwIDAQAB\" ; ----- DKIM auto for cacert.org")
146
+ r2 = RR.create("auto._domainkey.cacert.org. 43200 IN TXT \"v=DKIM1;g=*;k=rsa;p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDNFxiNr+NHJwih3OPhGr4iwLE+BBDu72YrMSzUnU1FF50CW7iOtuhg796UZ6xrZ5VuhAix6YmmzcvF2UxYzoD/XpfZ4MzBu0ND4/nkt9/YOTyIBzwQqn9uMNve0Y76Zsel89dIJtOI+y+lfnFExV0jKwe53gzmxMVpMSSCcZPGwIDAQAB\"")
147
+ assert(r1.to_s == r2.to_s)
144
148
  end
149
+
145
150
  end
@@ -269,33 +269,66 @@ class VerifierTest < Test::Unit::TestCase
269
269
  end
270
270
 
271
271
  def test_naptr
272
- key = Dnsruby::RR.create("all.rr.org. 2678400 IN DNSKEY 256 3 7 AwEAAcW1ZJxnMxZAAfsQ0JJQPHOlVNeGzs/AWVSGXiIYsg9UUSsvRTiK/Wy2wD7XC6osZpgy4Blhm846wktPbCwHpkxxbjxpaMABjbhH14gRol1Gpzf+gOr8vpdii8c2y6VMN9kIXZyaZUWcshLii19ysSGlqY1a1g2XZjogFtvzDHjH ;{id = 43068 (zsk), size = 1024b}")
273
- verifier = Dnsruby::SingleVerifier.new(Dnsruby::SingleVerifier::VerifierType::ANCHOR)
274
- key_rrset = Dnsruby::RRSet.new(key)
275
- verifier.add_trusted_key(key_rrset);
276
- 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}")
277
- naptr = Dnsruby::RR.create('all.rr.org. 86400 IN NAPTR 100 10 "" "" "!^urn:cid:.+@([^\\\\.]+\\\\.)(.*)$!\\\\2!i" .')
278
- rrset = Dnsruby::RRSet.new(naptr)
279
- rrset.add(sig)
280
- verifier.verify_rrset(rrset, key_rrset)
272
+ begin
273
+ begin
274
+ require 'rubygems'
275
+ rescue LoadError
276
+ end
277
+ require 'timecop'
278
+ rescue LoadError
279
+ return
280
+ end
281
+ Timecop.travel(2010, 03, 24, 0, 0, 0) {
282
+ key = Dnsruby::RR.create("all.rr.org. 2678400 IN DNSKEY 256 3 7 AwEAAcW1ZJxnMxZAAfsQ0JJQPHOlVNeGzs/AWVSGXiIYsg9UUSsvRTiK/Wy2wD7XC6osZpgy4Blhm846wktPbCwHpkxxbjxpaMABjbhH14gRol1Gpzf+gOr8vpdii8c2y6VMN9kIXZyaZUWcshLii19ysSGlqY1a1g2XZjogFtvzDHjH ;{id = 43068 (zsk), size = 1024b}")
283
+ verifier = Dnsruby::SingleVerifier.new(Dnsruby::SingleVerifier::VerifierType::ANCHOR)
284
+ key_rrset = Dnsruby::RRSet.new(key)
285
+ verifier.add_trusted_key(key_rrset);
286
+ 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}")
287
+ naptr = Dnsruby::RR.create('all.rr.org. 86400 IN NAPTR 100 10 "" "" "!^urn:cid:.+@([^\\\\.]+\\\\.)(.*)$!\\\\2!i" .')
288
+ rrset = Dnsruby::RRSet.new(naptr)
289
+ rrset.add(sig)
290
+ verifier.verify_rrset(rrset, key_rrset)
291
+ }
281
292
  end
282
293
 
283
294
  def test_txt_rr
284
- txt = 'txt2.all.rr.org. 86400 IN TXT "Net-DNS\\\\; complicated $tuff" "sort of \\" text\\\\; and binary \\000 data"'
285
- rr = Dnsruby::RR.create(txt)
286
- assert(rr.to_s.index('"Net-DNS\\\\; complicated $tuff" "sort of \\" text\\\\; and binary \\000 data"'), rr.to_s)
295
+ begin
296
+ begin
297
+ require 'rubygems'
298
+ rescue LoadError
299
+ end
300
+ require 'timecop'
301
+ rescue LoadError
302
+ return
303
+ end
304
+ Timecop.travel(2010, 03, 24, 0, 0, 0) {
305
+ txt = 'txt2.all.rr.org. 86400 IN TXT "Net-DNS\\\\; complicated $tuff" "sort of \\" text\\\\; and binary \\000 data"'
306
+ rr = Dnsruby::RR.create(txt)
307
+ assert(rr.to_s.index('"Net-DNS\\\\; complicated $tuff" "sort of \\" text\\\\; and binary \\000 data"'), rr.to_s)
287
308
 
288
- key = Dnsruby::RR.create("all.rr.org. 2678400 IN DNSKEY 256 3 7 AwEAAcW1ZJxnMxZAAfsQ0JJQPHOlVNeGzs/AWVSGXiIYsg9UUSsvRTiK/Wy2wD7XC6osZpgy4Blhm846wktPbCwHpkxxbjxpaMABjbhH14gRol1Gpzf+gOr8vpdii8c2y6VMN9kIXZyaZUWcshLii19ysSGlqY1a1g2XZjogFtvzDHjH ;{id = 43068 (zsk), size = 1024b}")
289
- verifier = Dnsruby::SingleVerifier.new(Dnsruby::SingleVerifier::VerifierType::ANCHOR)
290
- key_rrset = Dnsruby::RRSet.new(key)
291
- verifier.add_trusted_key(key_rrset);
292
- 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}")
293
- txt = Dnsruby::RR.create('txt2.all.rr.org. 86400 IN TXT "Net-DNS\\\\; complicated $tuff" "sort of \\" text\\\\; and binary \\000 data"')
294
- rrset = Dnsruby::RRSet.new(txt)
295
- rrset.add(sig)
296
- verifier.verify_rrset(rrset, key_rrset)
309
+ key = Dnsruby::RR.create("all.rr.org. 2678400 IN DNSKEY 256 3 7 AwEAAcW1ZJxnMxZAAfsQ0JJQPHOlVNeGzs/AWVSGXiIYsg9UUSsvRTiK/Wy2wD7XC6osZpgy4Blhm846wktPbCwHpkxxbjxpaMABjbhH14gRol1Gpzf+gOr8vpdii8c2y6VMN9kIXZyaZUWcshLii19ysSGlqY1a1g2XZjogFtvzDHjH ;{id = 43068 (zsk), size = 1024b}")
310
+ verifier = Dnsruby::SingleVerifier.new(Dnsruby::SingleVerifier::VerifierType::ANCHOR)
311
+ key_rrset = Dnsruby::RRSet.new(key)
312
+ verifier.add_trusted_key(key_rrset);
313
+ 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}")
314
+ txt = Dnsruby::RR.create('txt2.all.rr.org. 86400 IN TXT "Net-DNS\\\\; complicated $tuff" "sort of \\" text\\\\; and binary \\000 data"')
315
+ rrset = Dnsruby::RRSet.new(txt)
316
+ rrset.add(sig)
317
+ verifier.verify_rrset(rrset, key_rrset)
318
+ }
297
319
  end
298
320
 
321
+ # def test_txt_zonefile
322
+ # reader = Dnsruby::ZoneReader.new("cacert.org.")
323
+ # zone = reader.process_file("cacert.txt")
324
+ # reader2 = Dnsruby::ZoneReader.new("cacert.org.")
325
+ # zone2 = reader.process_file("cacert.signed.txt")
326
+ # assert(zone[1].to_s.index("DAQAB\""))
327
+ # assert(zone2[1].to_s.index("DAQAB\""))
328
+ #
329
+ # assert(zone[1].to_s == zone2[1].to_s)
330
+ # end
331
+ #
299
332
  # def test_txt_from_zone
300
333
  # reader = Dnsruby::ZoneReader.new("all.rr.org.")
301
334
  # zone = reader.process_file("zone.txt")
@@ -329,4 +362,5 @@ class VerifierTest < Test::Unit::TestCase
329
362
  # verifier = Dnsruby::SingleVerifier.new(Dnsruby::SingleVerifier::VerifierType::ANCHOR)
330
363
  # verifier.verify_rrset(rrset, key_rrset)
331
364
  # end
332
- end
365
+ end
366
+
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.48"
4
+ version: "1.49"
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-07-23 00:00:00 +01:00
12
+ date: 2010-08-24 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15