dnsruby 1.60.2 → 1.61.5
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 +9 -6
- data/.yardopts +7 -0
- data/README.md +7 -4
- data/RELEASE_NOTES.md +43 -0
- data/Rakefile +1 -0
- data/demo/digroot.rb +2 -0
- data/demo/rubydig.rb +1 -0
- data/dnsruby.gemspec +15 -8
- data/lib/dnsruby/code_mappers.rb +3 -0
- data/lib/dnsruby/config.rb +30 -8
- data/lib/dnsruby/dnssec.rb +4 -0
- data/lib/dnsruby/hosts.rb +8 -4
- 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 +11 -0
- data/lib/dnsruby/resource/CAA.rb +1 -1
- 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/URI.rb +57 -0
- data/lib/dnsruby/resource/generic.rb +3 -0
- data/lib/dnsruby/select_thread.rb +1 -1
- data/lib/dnsruby/single_verifier.rb +27 -4
- 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 +28 -2
- 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_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: fd2234e013517b2d62083f327de9a28e3d8f5f7c49e5204301f576d01e681809
|
4
|
+
data.tar.gz: 5695978850e06ebf1579fc80a7b10aba8e4296dfd210a548fb066cf9762e266d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2575fc3c3d7677fecfcb0479d5d5e77fc941ac57b7b171287ae552ef62d8b5ecb050b42774f996754d2a6a7b1b71b83021d0702446cca8856907120851c4665
|
7
|
+
data.tar.gz: ddaaf6bbb40bf8ce10f8180be766b4a7218b952673fec5cccc3726bf4bd01aceb01f03c5bdb4b1b86df6c30d14016eaff38e7cea69e979ad25d7bdfa1398a5af
|
data/.travis.yml
CHANGED
@@ -2,13 +2,16 @@ 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
|
-
# - rbx-2
|
10
|
+
- 2.6.6
|
11
|
+
- 2.5.8
|
12
|
+
- 2.7.1
|
12
13
|
- ruby-head
|
13
|
-
|
14
|
-
|
14
|
+
|
15
|
+
matrix:
|
16
|
+
allow_failures:
|
17
|
+
- rvm: ruby-head
|
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,48 @@
|
|
1
1
|
# Release Notes
|
2
2
|
|
3
|
+
## v1.61.5
|
4
|
+
|
5
|
+
* CAA record fixes - add contactphone and contactemail
|
6
|
+
* Fix eprecation warnings
|
7
|
+
|
8
|
+
## v1.61.4
|
9
|
+
|
10
|
+
* Dnsruby::Name : document .punycode
|
11
|
+
* gemspec enhancement
|
12
|
+
* add yard build file
|
13
|
+
* fix create name include url special characters
|
14
|
+
* Fix uninitialized constant error when using via Rails
|
15
|
+
* Implement ECDSAP256SHA256 (13) / ECDSAP384SHA384 (14) algorithms for DNSKEY
|
16
|
+
* Reinitialize all IANA TAR keys with Dnssec.reset
|
17
|
+
|
18
|
+
## v1.61.3
|
19
|
+
|
20
|
+
* TCP timeout and port changes
|
21
|
+
|
22
|
+
## v1.61.2
|
23
|
+
|
24
|
+
* Add new root key
|
25
|
+
|
26
|
+
## v1.61.1
|
27
|
+
|
28
|
+
* Add Addressable as a gem runtime dependency
|
29
|
+
|
30
|
+
## v1.61.0
|
31
|
+
|
32
|
+
* Add URI, CDS and CDNSKEY records
|
33
|
+
* Supply port to DNS.new as optiona parameter
|
34
|
+
* Supply timeout to zone transfer connect
|
35
|
+
* Fix multi-line strings
|
36
|
+
* Try absolute name as candidate in DNS even if not dot supplied
|
37
|
+
* Do not try to generate candidates if no domain is given
|
38
|
+
* Handle new OpenSSL interface as well as old
|
39
|
+
* Handle new DSA interface
|
40
|
+
* fix encode error select thread issue
|
41
|
+
* handle encoding errors
|
42
|
+
* add punycode support
|
43
|
+
* Make sure dnssec is enabled in verifier and also in digroot demo
|
44
|
+
* Other minor fixes and changes to test code and infrastructure
|
45
|
+
|
3
46
|
## v1.60.2
|
4
47
|
|
5
48
|
* Fix deletion of TXT records with spaces in dynamic updates (thanks Sean Dilda)
|
data/Rakefile
CHANGED
data/demo/digroot.rb
CHANGED
data/demo/rubydig.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,15 +316,20 @@ 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!(/[#;].*/, '')
|
309
323
|
keyword, *args = line.split(/\s+/)
|
310
|
-
|
311
|
-
|
312
|
-
|
324
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.8")
|
325
|
+
args.each { |arg|
|
326
|
+
arg.untaint
|
327
|
+
}
|
328
|
+
end
|
313
329
|
next unless keyword
|
314
330
|
case keyword
|
331
|
+
when 'port'
|
332
|
+
port = args[0].to_i
|
315
333
|
when 'nameserver'
|
316
334
|
nameserver += args
|
317
335
|
when 'domain'
|
@@ -337,7 +355,7 @@ module Dnsruby
|
|
337
355
|
end
|
338
356
|
}
|
339
357
|
}
|
340
|
-
return { :nameserver => nameserver, :domain => domain, :search => search, :ndots => ndots }
|
358
|
+
return { :nameserver => nameserver, :domain => domain, :search => search, :ndots => ndots, :port => port }
|
341
359
|
end
|
342
360
|
|
343
361
|
def inspect #:nodoc: all
|
@@ -357,6 +375,7 @@ module Dnsruby
|
|
357
375
|
ret += " domain : #{domain_string}, search : "
|
358
376
|
search.each {|s| ret += s + ", " }
|
359
377
|
ret += " ndots : #{@ndots}"
|
378
|
+
ret += " port : #{@port}"
|
360
379
|
return ret
|
361
380
|
end
|
362
381
|
|
@@ -423,18 +442,21 @@ module Dnsruby
|
|
423
442
|
end
|
424
443
|
end
|
425
444
|
|
426
|
-
def generate_candidates(
|
445
|
+
def generate_candidates(name_in) #:nodoc: all
|
427
446
|
if !@configured
|
428
447
|
parse_config
|
429
448
|
end
|
430
449
|
candidates = []
|
431
|
-
name = Name.create(
|
450
|
+
name = Name.create(name_in)
|
432
451
|
if name.absolute?
|
433
452
|
candidates = [name]
|
434
453
|
else
|
454
|
+
candidates.push(Name.create(name_in.to_s + "."))
|
435
455
|
if (@apply_domain)
|
436
456
|
if @ndots > name.length - 1
|
437
|
-
|
457
|
+
if (@domain != nil)
|
458
|
+
candidates.push(Name.create(name.to_a+@domain))
|
459
|
+
end
|
438
460
|
end
|
439
461
|
end
|
440
462
|
if (!@apply_search_list)
|
@@ -452,4 +474,4 @@ module Dnsruby
|
|
452
474
|
return candidates
|
453
475
|
end
|
454
476
|
end
|
455
|
-
end
|
477
|
+
end
|
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
|
|
data/lib/dnsruby/hosts.rb
CHANGED
@@ -57,15 +57,19 @@ module Dnsruby
|
|
57
57
|
line.sub!(/#.*/, '')
|
58
58
|
addr, hostname, *aliases = line.split(/\s+/)
|
59
59
|
next unless addr
|
60
|
-
|
61
|
-
|
60
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.8")
|
61
|
+
addr.untaint
|
62
|
+
hostname.untaint
|
63
|
+
end
|
62
64
|
@addr2name[addr] = [] unless @addr2name.include? addr
|
63
65
|
@addr2name[addr] << hostname
|
64
66
|
@addr2name[addr] += aliases
|
65
67
|
@name2addr[hostname] = [] unless @name2addr.include? hostname
|
66
68
|
@name2addr[hostname] << addr
|
67
69
|
aliases.each {|n|
|
68
|
-
|
70
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.8")
|
71
|
+
n.untaint
|
72
|
+
end
|
69
73
|
@name2addr[n] = [] unless @name2addr.include? n
|
70
74
|
@name2addr[n] << addr
|
71
75
|
}
|
@@ -123,4 +127,4 @@ module Dnsruby
|
|
123
127
|
end
|
124
128
|
end
|
125
129
|
end
|
126
|
-
end
|
130
|
+
end
|
@@ -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
|