dnsruby 1.48 → 1.49
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.
- data/lib/Dnsruby/Cache.rb +3 -0
- data/lib/Dnsruby/Resolver.rb +13 -11
- data/lib/Dnsruby/select_thread.rb +3 -2
- data/lib/Dnsruby/zone_reader.rb +1 -1
- data/lib/dnsruby.rb +1 -1
- data/test/tc_dlv.rb +3 -2
- data/test/tc_rr-txt.rb +5 -0
- data/test/tc_verifier.rb +56 -22
- metadata +2 -2
data/lib/Dnsruby/Cache.rb
CHANGED
data/lib/Dnsruby/Resolver.rb
CHANGED
@@ -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
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
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
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
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
|
data/lib/Dnsruby/zone_reader.rb
CHANGED
data/lib/dnsruby.rb
CHANGED
data/test/tc_dlv.rb
CHANGED
@@ -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
|
-
|
57
|
-
|
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
|
data/test/tc_rr-txt.rb
CHANGED
@@ -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
|
data/test/tc_verifier.rb
CHANGED
@@ -269,33 +269,66 @@ class VerifierTest < Test::Unit::TestCase
|
|
269
269
|
end
|
270
270
|
|
271
271
|
def test_naptr
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
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
|
-
|
285
|
-
|
286
|
-
|
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
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
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.
|
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-
|
12
|
+
date: 2010-08-24 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|