dnsruby 1.60.1 → 1.61.4
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.
- checksums.yaml +5 -5
- data/.travis.yml +6 -7
- data/.yardopts +7 -0
- data/README.md +7 -4
- data/RELEASE_NOTES.md +46 -0
- data/Rakefile +1 -0
- data/demo/digroot.rb +2 -0
- data/dnsruby.gemspec +15 -8
- data/lib/dnsruby/code_mappers.rb +3 -0
- data/lib/dnsruby/config.rb +24 -4
- data/lib/dnsruby/dnssec.rb +4 -0
- data/lib/dnsruby/message/encoder.rb +2 -2
- data/lib/dnsruby/message/header.rb +15 -15
- data/lib/dnsruby/name.rb +18 -2
- data/lib/dnsruby/packet_sender.rb +14 -2
- data/lib/dnsruby/recursor.rb +10 -1
- data/lib/dnsruby/resolver.rb +12 -0
- data/lib/dnsruby/resource/CAA.rb +6 -4
- data/lib/dnsruby/resource/CDNSKEY.rb +17 -0
- data/lib/dnsruby/resource/CDS.rb +35 -0
- data/lib/dnsruby/resource/DNSKEY.rb +33 -6
- data/lib/dnsruby/resource/IN.rb +4 -1
- data/lib/dnsruby/resource/NAPTR.rb +9 -7
- data/lib/dnsruby/resource/URI.rb +57 -0
- data/lib/dnsruby/resource/generic.rb +3 -0
- data/lib/dnsruby/select_thread.rb +1 -2
- data/lib/dnsruby/single_verifier.rb +27 -4
- data/lib/dnsruby/update.rb +65 -48
- data/lib/dnsruby/validator_thread.rb +4 -4
- data/lib/dnsruby/version.rb +1 -1
- data/lib/dnsruby/zone_transfer.rb +5 -1
- data/test/localdns.rb +29 -0
- data/test/tc_caa.rb +0 -1
- data/test/tc_dns.rb +11 -1
- data/test/tc_dnskey.rb +29 -0
- data/test/tc_encoding.rb +31 -0
- data/test/tc_hs.rb +4 -3
- data/test/tc_long_labels.rb +46 -0
- data/test/tc_name.rb +19 -0
- data/test/tc_resolv.rb +5 -4
- data/test/tc_resolver.rb +27 -1
- data/test/tc_rr-opt.rb +9 -3
- data/test/tc_rr.rb +33 -0
- data/test/tc_soak.rb +33 -67
- data/test/tc_tcp_pipelining.rb +27 -19
- data/test/tc_update.rb +12 -0
- data/test/tc_verifier.rb +15 -0
- data/test/test_dnsserver.rb +110 -17
- metadata +50 -44
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0af7c6de9311c48936130f68339d222dc18675d7ad52db92eec7474bae5ee05c
|
|
4
|
+
data.tar.gz: cc926e5123a7e691b88261d93891b7f28efbc54d01ca549e1fdabc6d9ee62f1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c09d09948564591075f2caccc23d0592ec04644d592815400cc78e1664354af47e9185276fce7c64fb81a18ef4fbbfd53520314419e5085a879dd8df0565527f
|
|
7
|
+
data.tar.gz: 535c00b339938ffe3e1479286477889398dc1154f43a2eae4defcb7e08a0a04d23033b501163f3815e2793af67d9445448170bfbd516d34702a5df93f4a22b4d
|
data/.travis.yml
CHANGED
|
@@ -2,13 +2,12 @@ language: ruby
|
|
|
2
2
|
cache: bundler
|
|
3
3
|
sudo: false
|
|
4
4
|
|
|
5
|
+
before_install: gem install bundler
|
|
6
|
+
|
|
5
7
|
script: "bundle exec rake test"
|
|
6
8
|
|
|
7
9
|
rvm:
|
|
8
|
-
- 2.
|
|
9
|
-
- 2.
|
|
10
|
-
- 2.
|
|
11
|
-
|
|
12
|
-
- ruby-head
|
|
13
|
-
# - jruby-head
|
|
14
|
-
# - ree
|
|
10
|
+
- 2.6.6
|
|
11
|
+
- 2.5.8
|
|
12
|
+
- 2.7.1
|
|
13
|
+
|
data/.yardopts
ADDED
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
[](https://travis-ci.org/alexdalitz/dnsruby)
|
|
2
2
|
[](https://coveralls.io/r/alexdalitz/dnsruby?branch=master)
|
|
3
3
|
|
|
4
|
+
<img src="http://caerkettontech.com/dnsruby/DNSRuby-colour-mid.png" width="200" height="200" />
|
|
5
|
+
|
|
4
6
|
Dnsruby
|
|
5
7
|
=======
|
|
6
8
|
|
|
@@ -16,10 +18,10 @@ queries. It is therefore suitable for high volume DNS applications.
|
|
|
16
18
|
|
|
17
19
|
The following is a (non-exhaustive) list of features :
|
|
18
20
|
|
|
19
|
-
- Implemented RRs : A, AAAA, AFSDB, ANY, CERT, CNAME, DNAME,
|
|
20
|
-
HINFO, ISDN, LOC, MB, MG, MINFO, MR, MX, NAPTR, NS, NSAP,
|
|
21
|
-
OPT, PTR, PX, RP, RT, SOA, SPF, SRV, TKEY, TSIG, TXT,
|
|
22
|
-
X25, DNSKEY, RRSIG, NSEC, NSEC3, NSEC3PARAM, DS, DLV
|
|
21
|
+
- Implemented RRs : A, AAAA, AFSDB, ANY, CAA, CERT, CNAME, DNAME,
|
|
22
|
+
GPOS, HINFO, ISDN, LOC, MB, MG, MINFO, MR, MX, NAPTR, NS, NSAP,
|
|
23
|
+
NXT, OPT, PTR, PX, RP, RT, SOA, SPF, SRV, TKEY, TSIG, TXT,
|
|
24
|
+
WKS, X25, DNSKEY, RRSIG, NSEC, NSEC3, NSEC3PARAM, DS, DLV
|
|
23
25
|
|
|
24
26
|
- Generic RR types supported (RFC3597)
|
|
25
27
|
|
|
@@ -91,3 +93,4 @@ Contact/Links
|
|
|
91
93
|
| Github | https://github.com/alexdalitz/dnsruby |
|
|
92
94
|
| Google Group | https://groups.google.com/forum/#!forum/dnsruby |
|
|
93
95
|
| Rubygems | http://rubygems.org/gems/dnsruby/ |
|
|
96
|
+
| Documentation | https://www.rubydoc.info/gems/dnsruby/ |
|
data/RELEASE_NOTES.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
+
## v1.61.4
|
|
4
|
+
|
|
5
|
+
* Dnsruby::Name : document .punycode
|
|
6
|
+
* gemspec enhancement
|
|
7
|
+
* add yard build file
|
|
8
|
+
* fix create name include url special characters
|
|
9
|
+
* Fix uninitialized constant error when using via Rails
|
|
10
|
+
* Implement ECDSAP256SHA256 (13) / ECDSAP384SHA384 (14) algorithms for DNSKEY
|
|
11
|
+
* Reinitialize all IANA TAR keys with Dnssec.reset
|
|
12
|
+
|
|
13
|
+
## v1.61.3
|
|
14
|
+
|
|
15
|
+
* TCP timeout and port changes
|
|
16
|
+
|
|
17
|
+
## v1.61.2
|
|
18
|
+
|
|
19
|
+
* Add new root key
|
|
20
|
+
|
|
21
|
+
## v1.61.1
|
|
22
|
+
|
|
23
|
+
* Add Addressable as a gem runtime dependency
|
|
24
|
+
|
|
25
|
+
## v1.61.0
|
|
26
|
+
|
|
27
|
+
* Add URI, CDS and CDNSKEY records
|
|
28
|
+
* Supply port to DNS.new as optiona parameter
|
|
29
|
+
* Supply timeout to zone transfer connect
|
|
30
|
+
* Fix multi-line strings
|
|
31
|
+
* Try absolute name as candidate in DNS even if not dot supplied
|
|
32
|
+
* Do not try to generate candidates if no domain is given
|
|
33
|
+
* Handle new OpenSSL interface as well as old
|
|
34
|
+
* Handle new DSA interface
|
|
35
|
+
* fix encode error select thread issue
|
|
36
|
+
* handle encoding errors
|
|
37
|
+
* add punycode support
|
|
38
|
+
* Make sure dnssec is enabled in verifier and also in digroot demo
|
|
39
|
+
* Other minor fixes and changes to test code and infrastructure
|
|
40
|
+
|
|
41
|
+
## v1.60.2
|
|
42
|
+
|
|
43
|
+
* Fix deletion of TXT records with spaces in dynamic updates (thanks Sean Dilda)
|
|
44
|
+
* Fix use of non-default ports in Dnsruby::Resolver (thanks Thomas Morgan)
|
|
45
|
+
* Fix NAPTR encoding for null rdata dynamic update packets
|
|
46
|
+
* Fix CAA resource record encoding
|
|
47
|
+
* Avoid changing ruby global thread abort behavior (thanks Brent Cook)
|
|
48
|
+
|
|
3
49
|
## v1.60.1
|
|
4
50
|
|
|
5
51
|
* DNSSEC validation switched OFF by default (but can still be switched on)
|
data/Rakefile
CHANGED
data/demo/digroot.rb
CHANGED
data/dnsruby.gemspec
CHANGED
|
@@ -15,6 +15,7 @@ SPEC = Gem::Specification.new do |s|
|
|
|
15
15
|
stub resolver. It aims to comply with all DNS RFCs, including
|
|
16
16
|
DNSSEC NSEC3 support.'
|
|
17
17
|
s.license = "Apache License, Version 2.0"
|
|
18
|
+
|
|
18
19
|
s.files = `git ls-files -z`.split("\x0")
|
|
19
20
|
|
|
20
21
|
s.post_install_message = \
|
|
@@ -23,22 +24,28 @@ DNSSEC NSEC3 support.'
|
|
|
23
24
|
For general discussion (please tell us how you use dnsruby): https://groups.google.com/forum/#!forum/dnsruby"
|
|
24
25
|
|
|
25
26
|
s.test_file = "test/ts_offline.rb"
|
|
26
|
-
s.has_rdoc = true
|
|
27
27
|
s.extra_rdoc_files = ["DNSSEC", "EXAMPLES", "README.md", "EVENTMACHINE"]
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
s.metadata = {
|
|
30
|
+
'yard.run' => 'yard',
|
|
31
|
+
'bug_tracker_uri' => 'https://github.com/alexdalitz/dnsruby/issues',
|
|
32
|
+
'changelog_uri' => 'https://github.com/alexdalitz/dnsruby/blob/master/RELEASE_NOTES.md',
|
|
33
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/dnsruby/',
|
|
34
|
+
'homepage_uri' => 'https://github.com/alexdalitz/dnsruby',
|
|
35
|
+
'source_code_uri' => 'https://github.com/alexdalitz/dnsruby',
|
|
36
|
+
}
|
|
33
37
|
|
|
34
|
-
s.add_development_dependency 'rake', '
|
|
38
|
+
s.add_development_dependency 'rake', '>= 12.3.3'
|
|
35
39
|
s.add_development_dependency 'minitest', '~> 5.4'
|
|
36
|
-
s.add_development_dependency 'rubydns', '~>
|
|
37
|
-
s.add_development_dependency 'nio4r', '~>
|
|
40
|
+
s.add_development_dependency 'rubydns', '~> 2.0.1'
|
|
41
|
+
s.add_development_dependency 'nio4r', '~> 2.0'
|
|
38
42
|
s.add_development_dependency 'minitest-display', '>= 0.3.0'
|
|
43
|
+
s.add_development_dependency('yard', '~> 0.9')
|
|
39
44
|
|
|
40
45
|
if RUBY_VERSION >= "1.9.3"
|
|
41
46
|
s.add_development_dependency 'coveralls', '~> 0.7'
|
|
42
47
|
end
|
|
48
|
+
|
|
49
|
+
s.add_runtime_dependency 'simpleidn', '~> 0.1'
|
|
43
50
|
end
|
|
44
51
|
|
data/lib/dnsruby/code_mappers.rb
CHANGED
|
@@ -162,6 +162,8 @@ module Dnsruby
|
|
|
162
162
|
NSEC3PARAM= 51 # RFC still pending at time of writing
|
|
163
163
|
TLSA = 52 # RFC 6698
|
|
164
164
|
HIP = 55 # RFC 5205
|
|
165
|
+
CDS = 59 # RFC 7344
|
|
166
|
+
CDNSKEY = 60 # RFC 7344
|
|
165
167
|
SPF = 99 # RFC 4408
|
|
166
168
|
UINFO = 100 # non-standard
|
|
167
169
|
UID = 101 # non-standard
|
|
@@ -174,6 +176,7 @@ module Dnsruby
|
|
|
174
176
|
MAILB = 253 # RFC 1035 (MB, MG, MR)
|
|
175
177
|
MAILA = 254 # RFC 1035 (obsolete - see MX)
|
|
176
178
|
ANY = 255 # RFC 1035
|
|
179
|
+
URI = 256 # RFC 7553
|
|
177
180
|
CAA = 257 # RFC 6844
|
|
178
181
|
DLV = 32769 # RFC 4431 (informational)
|
|
179
182
|
update()
|
data/lib/dnsruby/config.rb
CHANGED
|
@@ -38,6 +38,7 @@ module Dnsruby
|
|
|
38
38
|
# a query is performed (or a config parameter requested on) a Resolver which has
|
|
39
39
|
# not yet been configured.
|
|
40
40
|
class Config
|
|
41
|
+
DEFAULT_PORT = 53
|
|
41
42
|
# --
|
|
42
43
|
# @TODO@ Switches for :
|
|
43
44
|
#
|
|
@@ -101,6 +102,7 @@ module Dnsruby
|
|
|
101
102
|
dom=""
|
|
102
103
|
nd = 1
|
|
103
104
|
@ndots = 1
|
|
105
|
+
@port = DEFAULT_PORT
|
|
104
106
|
@apply_search_list = true
|
|
105
107
|
@apply_domain = true
|
|
106
108
|
config_hash = Config.default_config_hash
|
|
@@ -122,6 +124,7 @@ module Dnsruby
|
|
|
122
124
|
ns = config_hash[:nameserver] if config_hash.include? :nameserver
|
|
123
125
|
s = config_hash[:search] if config_hash.include? :search
|
|
124
126
|
nd = config_hash[:ndots] if config_hash.include? :ndots
|
|
127
|
+
p = config_hash[:port] if config_hash.include? :port
|
|
125
128
|
@apply_search_list = config_hash[:apply_search_list] if config_hash.include? :apply_search_list
|
|
126
129
|
@apply_domain= config_hash[:apply_domain] if config_hash.include? :apply_domain
|
|
127
130
|
dom = config_hash[:domain] if config_hash.include? :domain
|
|
@@ -132,6 +135,7 @@ module Dnsruby
|
|
|
132
135
|
@configured = true
|
|
133
136
|
send("search=",s)
|
|
134
137
|
send("ndots=",nd)
|
|
138
|
+
send("port=",p)
|
|
135
139
|
send("domain=",dom)
|
|
136
140
|
}
|
|
137
141
|
Dnsruby.log.info{to_s}
|
|
@@ -159,6 +163,15 @@ module Dnsruby
|
|
|
159
163
|
end
|
|
160
164
|
end
|
|
161
165
|
|
|
166
|
+
# Set port
|
|
167
|
+
def port=(p)
|
|
168
|
+
@configured = true
|
|
169
|
+
@port=p if p
|
|
170
|
+
if !@port.kind_of?(Integer)
|
|
171
|
+
raise ArgumentError.new("invalid port config: #{@port.inspect}")
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
162
175
|
# Set the default search path
|
|
163
176
|
def search=(s)
|
|
164
177
|
@configured = true
|
|
@@ -303,6 +316,7 @@ module Dnsruby
|
|
|
303
316
|
search = nil
|
|
304
317
|
domain = nil
|
|
305
318
|
ndots = 1
|
|
319
|
+
port = DEFAULT_PORT
|
|
306
320
|
open(filename) {|f|
|
|
307
321
|
f.each {|line|
|
|
308
322
|
line.sub!(/[#;].*/, '')
|
|
@@ -312,6 +326,8 @@ module Dnsruby
|
|
|
312
326
|
}
|
|
313
327
|
next unless keyword
|
|
314
328
|
case keyword
|
|
329
|
+
when 'port'
|
|
330
|
+
port = args[0].to_i
|
|
315
331
|
when 'nameserver'
|
|
316
332
|
nameserver += args
|
|
317
333
|
when 'domain'
|
|
@@ -337,7 +353,7 @@ module Dnsruby
|
|
|
337
353
|
end
|
|
338
354
|
}
|
|
339
355
|
}
|
|
340
|
-
return { :nameserver => nameserver, :domain => domain, :search => search, :ndots => ndots }
|
|
356
|
+
return { :nameserver => nameserver, :domain => domain, :search => search, :ndots => ndots, :port => port }
|
|
341
357
|
end
|
|
342
358
|
|
|
343
359
|
def inspect #:nodoc: all
|
|
@@ -357,6 +373,7 @@ module Dnsruby
|
|
|
357
373
|
ret += " domain : #{domain_string}, search : "
|
|
358
374
|
search.each {|s| ret += s + ", " }
|
|
359
375
|
ret += " ndots : #{@ndots}"
|
|
376
|
+
ret += " port : #{@port}"
|
|
360
377
|
return ret
|
|
361
378
|
end
|
|
362
379
|
|
|
@@ -423,18 +440,21 @@ module Dnsruby
|
|
|
423
440
|
end
|
|
424
441
|
end
|
|
425
442
|
|
|
426
|
-
def generate_candidates(
|
|
443
|
+
def generate_candidates(name_in) #:nodoc: all
|
|
427
444
|
if !@configured
|
|
428
445
|
parse_config
|
|
429
446
|
end
|
|
430
447
|
candidates = []
|
|
431
|
-
name = Name.create(
|
|
448
|
+
name = Name.create(name_in)
|
|
432
449
|
if name.absolute?
|
|
433
450
|
candidates = [name]
|
|
434
451
|
else
|
|
452
|
+
candidates.push(Name.create(name_in.to_s + "."))
|
|
435
453
|
if (@apply_domain)
|
|
436
454
|
if @ndots > name.length - 1
|
|
437
|
-
|
|
455
|
+
if (@domain != nil)
|
|
456
|
+
candidates.push(Name.create(name.to_a+@domain))
|
|
457
|
+
end
|
|
438
458
|
end
|
|
439
459
|
end
|
|
440
460
|
if (!@apply_search_list)
|
data/lib/dnsruby/dnssec.rb
CHANGED
|
@@ -82,6 +82,9 @@ module Dnsruby
|
|
|
82
82
|
@@root_key = RR.create(". IN DS 19036 8 2 49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5")
|
|
83
83
|
@@root_verifier.add_root_ds(@@root_key)
|
|
84
84
|
|
|
85
|
+
@@root_key_new = RR.create(". IN DS 20326 8 2 E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D")
|
|
86
|
+
@@root_verifier.add_root_ds(@@root_key_new)
|
|
87
|
+
|
|
85
88
|
@@dlv_verifier = SingleVerifier.new(SingleVerifier::VerifierType::DLV)
|
|
86
89
|
|
|
87
90
|
# @TODO@ Could add a new one of these for each anchor.
|
|
@@ -125,6 +128,7 @@ module Dnsruby
|
|
|
125
128
|
@@validation_policy = ValidationPolicy::LOCAL_ANCHORS_THEN_ROOT
|
|
126
129
|
@@root_verifier = SingleVerifier.new(SingleVerifier::VerifierType::ROOT)
|
|
127
130
|
@@root_verifier.add_root_ds(@@root_key)
|
|
131
|
+
@@root_verifier.add_root_ds(@@root_key_new)
|
|
128
132
|
|
|
129
133
|
@@dlv_verifier = SingleVerifier.new(SingleVerifier::VerifierType::DLV)
|
|
130
134
|
|
|
@@ -18,7 +18,7 @@ class MessageEncoder #:nodoc: all
|
|
|
18
18
|
begin
|
|
19
19
|
@data << d.pack(template)
|
|
20
20
|
rescue Encoding::CompatibilityError => e
|
|
21
|
-
raise Dnsruby::
|
|
21
|
+
raise Dnsruby::EncodeError.new("IDN support currently requires punycode string")
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -36,7 +36,7 @@ class MessageEncoder #:nodoc: all
|
|
|
36
36
|
self.put_pack("C", d.length)
|
|
37
37
|
@data << d
|
|
38
38
|
rescue Encoding::CompatibilityError => e
|
|
39
|
-
raise Dnsruby::
|
|
39
|
+
raise Dnsruby::EncodeError.new("IDN support currently requires punycode string")
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
@@ -190,29 +190,29 @@ class Header
|
|
|
190
190
|
retval = ";; id = #{@id}\n"
|
|
191
191
|
|
|
192
192
|
if (@opcode == OpCode::Update)
|
|
193
|
-
retval += ";; qr = #{@qr} "
|
|
194
|
-
"opcode = #{@opcode.string} "
|
|
193
|
+
retval += ";; qr = #{@qr} " \
|
|
194
|
+
"opcode = #{@opcode.string} "\
|
|
195
195
|
"rcode = #{@rcode.string}\n"
|
|
196
196
|
|
|
197
|
-
retval += ";; zocount = #{@qdcount} "
|
|
198
|
-
"prcount = #{@ancount} "
|
|
199
|
-
"upcount = #{@nscount} "
|
|
197
|
+
retval += ";; zocount = #{@qdcount} "\
|
|
198
|
+
"prcount = #{@ancount} " \
|
|
199
|
+
"upcount = #{@nscount} " \
|
|
200
200
|
"adcount = #{@arcount}\n"
|
|
201
201
|
else
|
|
202
|
-
retval += ";; qr = #{@qr} "
|
|
203
|
-
"opcode = #{@opcode.string} "
|
|
204
|
-
"aa = #{@aa} "
|
|
205
|
-
"tc = #{@tc} "
|
|
202
|
+
retval += ";; qr = #{@qr} " \
|
|
203
|
+
"opcode = #{@opcode.string} " \
|
|
204
|
+
"aa = #{@aa} " \
|
|
205
|
+
"tc = #{@tc} " \
|
|
206
206
|
"rd = #{@rd}\n"
|
|
207
207
|
|
|
208
|
-
retval += ";; ra = #{@ra} "
|
|
209
|
-
"ad = #{@ad} "
|
|
210
|
-
"cd = #{@cd} "
|
|
208
|
+
retval += ";; ra = #{@ra} " \
|
|
209
|
+
"ad = #{@ad} " \
|
|
210
|
+
"cd = #{@cd} " \
|
|
211
211
|
"rcode = #{rcode.string}\n"
|
|
212
212
|
|
|
213
|
-
retval += ";; qdcount = #{@qdcount} "
|
|
214
|
-
"ancount = #{@ancount} "
|
|
215
|
-
"nscount = #{@nscount} "
|
|
213
|
+
retval += ";; qdcount = #{@qdcount} " \
|
|
214
|
+
"ancount = #{@ancount} " \
|
|
215
|
+
"nscount = #{@nscount} " \
|
|
216
216
|
"arcount = #{@arcount}\n"
|
|
217
217
|
end
|
|
218
218
|
|
data/lib/dnsruby/name.rb
CHANGED
|
@@ -26,7 +26,8 @@ module Dnsruby
|
|
|
26
26
|
# * Name#wild?
|
|
27
27
|
# * Name#subdomain_of?(other)
|
|
28
28
|
# * Name#labels
|
|
29
|
-
#
|
|
29
|
+
#
|
|
30
|
+
require 'simpleidn'
|
|
30
31
|
class Name
|
|
31
32
|
include Comparable
|
|
32
33
|
MaxNameLength=255
|
|
@@ -52,6 +53,7 @@ module Dnsruby
|
|
|
52
53
|
if (arg=="")
|
|
53
54
|
return Name.new([],false)
|
|
54
55
|
end
|
|
56
|
+
arg = punycode(arg)
|
|
55
57
|
return Name.new(split_escaped(arg), /\.\z/ =~ arg ? true : false)
|
|
56
58
|
# return Name.new(Label.split(arg), /\.\z/ =~ arg ? true : false)
|
|
57
59
|
when Array
|
|
@@ -61,6 +63,20 @@ module Dnsruby
|
|
|
61
63
|
end
|
|
62
64
|
end
|
|
63
65
|
|
|
66
|
+
# Convert IDN domain from Unicode UTF-8 to ASCII punycode
|
|
67
|
+
# @param [Object|String] d Unicode domain with emoji inside
|
|
68
|
+
# @return [String] ASCII punycode domain
|
|
69
|
+
# @example
|
|
70
|
+
# Dnsruby::Name.punycode('🏳.cf')
|
|
71
|
+
# => "xn--en8h.cf"
|
|
72
|
+
def self.punycode(d)
|
|
73
|
+
begin
|
|
74
|
+
return SimpleIDN.to_ascii(d)
|
|
75
|
+
rescue
|
|
76
|
+
return d
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
64
80
|
def self.split_escaped(arg) #:nodoc: all
|
|
65
81
|
encodedlabels = name2encodedlabels(arg)
|
|
66
82
|
return encodedlabels
|
|
@@ -317,7 +333,7 @@ module Dnsruby
|
|
|
317
333
|
i=0;
|
|
318
334
|
|
|
319
335
|
while (i < length )
|
|
320
|
-
c=presentation.unpack("x#{i}C1")
|
|
336
|
+
c=presentation.unpack("x#{i}C1")[0]
|
|
321
337
|
if (c == 46) # ord('.')
|
|
322
338
|
endstring = presentation[i+1, presentation.length-(i+1)]
|
|
323
339
|
return Label.new(wire),endstring
|
|
@@ -331,7 +331,14 @@ module Dnsruby
|
|
|
331
331
|
client_query_id = Time.now + rand(10000) # is this safe?!
|
|
332
332
|
end
|
|
333
333
|
|
|
334
|
-
|
|
334
|
+
begin
|
|
335
|
+
query_packet = make_query_packet(msg, use_tcp)
|
|
336
|
+
rescue EncodeError => err
|
|
337
|
+
Dnsruby.log.error { "#{err}" }
|
|
338
|
+
st = SelectThread.instance
|
|
339
|
+
st.push_exception_to_select(client_query_id, client_queue, err, nil)
|
|
340
|
+
return
|
|
341
|
+
end
|
|
335
342
|
|
|
336
343
|
if (msg.do_caching && (msg.class != Update))
|
|
337
344
|
# Check the cache!!
|
|
@@ -449,7 +456,7 @@ module Dnsruby
|
|
|
449
456
|
socket, new_socket = tcp_pipeline_socket(src_port)
|
|
450
457
|
src_port = @tcp_pipeline_local_port
|
|
451
458
|
else
|
|
452
|
-
socket =
|
|
459
|
+
socket = Socket.tcp(@server, @port, src_address, src_port, connect_timeout: @packet_timeout)
|
|
453
460
|
new_socket = true
|
|
454
461
|
end
|
|
455
462
|
rescue Errno::EBADF, Errno::ENETUNREACH => e
|
|
@@ -622,6 +629,11 @@ module Dnsruby
|
|
|
622
629
|
# Should send error back up to Resolver here, and then NOT QUERY AGAIN!!!
|
|
623
630
|
return sig_value
|
|
624
631
|
end
|
|
632
|
+
if ((response.header.get_header_rcode == RCode.FORMERR) &&
|
|
633
|
+
(query.header.arcount == 0))
|
|
634
|
+
# Raise an error
|
|
635
|
+
return true
|
|
636
|
+
end
|
|
625
637
|
# Should check that question section is same as question that was sent! RFC 5452
|
|
626
638
|
# If it's not an update...
|
|
627
639
|
if (query.class == Update)
|