dnsruby 1.61.2 → 1.61.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +23 -0
  3. data/.yardopts +7 -0
  4. data/Gemfile +0 -2
  5. data/README.md +2 -1
  6. data/RELEASE_NOTES.md +32 -1
  7. data/Rakefile +2 -0
  8. data/dnsruby.gemspec +14 -9
  9. data/lib/dnsruby.rb +4 -4
  10. data/lib/dnsruby/DNS.rb +1 -1
  11. data/lib/dnsruby/config.rb +13 -13
  12. data/lib/dnsruby/dnssec.rb +1 -0
  13. data/lib/dnsruby/hosts.rb +8 -4
  14. data/lib/dnsruby/message/encoder.rb +2 -2
  15. data/lib/dnsruby/message/header.rb +0 -3
  16. data/lib/dnsruby/name.rb +13 -15
  17. data/lib/dnsruby/packet_sender.rb +12 -16
  18. data/lib/dnsruby/recursor.rb +6 -5
  19. data/lib/dnsruby/resolver.rb +14 -17
  20. data/lib/dnsruby/resource/CAA.rb +2 -2
  21. data/lib/dnsruby/resource/DNSKEY.rb +18 -0
  22. data/lib/dnsruby/resource/NSEC3PARAM.rb +1 -1
  23. data/lib/dnsruby/resource/TLSA.rb +3 -3
  24. data/lib/dnsruby/resource/TXT.rb +11 -1
  25. data/lib/dnsruby/select_thread.rb +6 -7
  26. data/lib/dnsruby/single_verifier.rb +14 -3
  27. data/lib/dnsruby/validator_thread.rb +4 -4
  28. data/lib/dnsruby/version.rb +1 -1
  29. data/lib/dnsruby/zone_reader.rb +2 -2
  30. data/lib/dnsruby/zone_transfer.rb +0 -1
  31. data/test/localdns.rb +29 -0
  32. data/test/spec_helper.rb +6 -0
  33. data/test/tc_caa.rb +0 -1
  34. data/test/tc_dns.rb +7 -2
  35. data/test/tc_dnskey.rb +29 -0
  36. data/test/tc_encoding.rb +31 -0
  37. data/test/tc_hs.rb +4 -3
  38. data/test/tc_long_labels.rb +46 -0
  39. data/test/tc_name.rb +19 -0
  40. data/test/tc_resolv.rb +5 -4
  41. data/test/tc_resolver.rb +12 -12
  42. data/test/tc_rr-opt.rb +8 -5
  43. data/test/tc_rr-txt.rb +7 -1
  44. data/test/tc_soak.rb +31 -69
  45. data/test/tc_tcp.rb +2 -2
  46. data/test/tc_tcp_pipelining.rb +26 -25
  47. data/test/tc_verifier.rb +15 -0
  48. data/test/test_dnsserver.rb +110 -17
  49. data/test/test_utils.rb +0 -2
  50. data/test/ts_offline.rb +8 -8
  51. metadata +40 -51
  52. data/.travis.yml +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8d3ce250a7bae010d93f3e4b364176a3beba389a
4
- data.tar.gz: 4890c4e357d535500da2d0ca1e08ada1be6361d6
2
+ SHA256:
3
+ metadata.gz: d267eba6aca51b53799b98294feea8a6394293e86d27b0054daf81f5da532f8e
4
+ data.tar.gz: 5ed7a4a3c9c91407c79e7a2470546430ab13df880a22a8ed0d002d4bafb3cc3b
5
5
  SHA512:
6
- metadata.gz: ac49a57892a98ead8142743679af87aee1e7ff32c7ed396d33b645991d2b2b5ed7afc5a6dc5ebc1d80fc65b2ec2524ef836d14c5bdb443f6f1d7cf6bbdd7823a
7
- data.tar.gz: f072918e90de725a7f062513eba3f0b06686a85ed1dc44efc550732e125482948b2725eead67e2e7f83e25f2454fd10a29b3f36dbda32d06437c231a673622cb
6
+ metadata.gz: 910c119b759313510f8fb2397ce48b9ac652a6d9c9e176d5eae93148a77664d7fe4b0b40a1c1c447beefcfe652807f6b1a7493314dd8dd71032e7ec2a56e7e99
7
+ data.tar.gz: 539eec74d5805ac121cb9b23d881ddb4bc98c755f90d88b07eedf864fef376ccceca076bf0d3c3bb8bdc858ff629133862253bad48a00ca205c6ad819b8cc97f
@@ -0,0 +1,23 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: [ '2.5', '2.6', '2.7', '3.0' ]
11
+ name: Ruby ${{ matrix.ruby }} tests
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Setup Ruby
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ - name: Bundle install
19
+ run: |
20
+ gem install bundler
21
+ bundle install --jobs 4 --retry 3
22
+ - name: Run tests
23
+ run: bundle exec rake test
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ -
2
+ --main README.md
3
+ LICENSE
4
+ DNSSEC
5
+ EXAMPLES
6
+ EVENTMACHINE
7
+ RELEASE_NOTES.md
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- gem "addressable", "~> 2.5"
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/alexdalitz/dnsruby.svg?branch=master)](https://travis-ci.org/alexdalitz/dnsruby)
1
+ [![Build Status](https://github.com/alexdalitz/dnsruby/actions/workflows/ci.yml/badge.svg)]
2
2
  [![Coverage Status](https://img.shields.io/coveralls/alexdalitz/dnsruby.svg)](https://coveralls.io/r/alexdalitz/dnsruby?branch=master)
3
3
 
4
4
  <img src="http://caerkettontech.com/dnsruby/DNSRuby-colour-mid.png" width="200" height="200" />
@@ -93,3 +93,4 @@ Contact/Links
93
93
  | Github | https://github.com/alexdalitz/dnsruby |
94
94
  | Google Group | https://groups.google.com/forum/#!forum/dnsruby |
95
95
  | Rubygems | http://rubygems.org/gems/dnsruby/ |
96
+ | Documentation | https://www.rubydoc.info/gems/dnsruby/ |
data/RELEASE_NOTES.md CHANGED
@@ -1,6 +1,37 @@
1
1
  # Release Notes
2
2
 
3
- ##v1.61.2
3
+ ## v1.61.7
4
+
5
+ * Fix namespace issue from v1.61.6
6
+
7
+ ## v1.61.6
8
+
9
+ * RD bit not set on Recursor queries (thanks Sean Dilda!)
10
+ * Handle quoted strings followed by unquoted strings in TXT records
11
+ * do not worry about rogue repeated Ids - just log an error and get on with life
12
+ * Clear Ruby warnings
13
+ * Use GitHub Actions rather than Travis
14
+
15
+ ## v1.61.5
16
+
17
+ * CAA record fixes - add contactphone and contactemail
18
+ * Fix eprecation warnings
19
+
20
+ ## v1.61.4
21
+
22
+ * Dnsruby::Name : document .punycode
23
+ * gemspec enhancement
24
+ * add yard build file
25
+ * fix create name include url special characters
26
+ * Fix uninitialized constant error when using via Rails
27
+ * Implement ECDSAP256SHA256 (13) / ECDSAP384SHA384 (14) algorithms for DNSKEY
28
+ * Reinitialize all IANA TAR keys with Dnssec.reset
29
+
30
+ ## v1.61.3
31
+
32
+ * TCP timeout and port changes
33
+
34
+ ## v1.61.2
4
35
 
5
36
  * Add new root key
6
37
 
data/Rakefile CHANGED
@@ -22,6 +22,7 @@ def create_task(task_name, test_suite_filespec)
22
22
  t.name = task_name
23
23
  t.test_files = FileList[test_suite_filespec]
24
24
  t.verbose = true
25
+ t.warning = false
25
26
  end
26
27
  end
27
28
 
@@ -32,3 +33,4 @@ create_task(:soak, 'test/tc_soak.rb')
32
33
  create_task(:message, 'test/tc_message.rb')
33
34
  create_task(:cache, 'test/tc_cache.rb')
34
35
  create_task(:pipe, 'test/tc_tcp_pipelining.rb')
36
+ create_task(:resolv, 'test/tc_resolv.rb')
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,24 +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
- unless /java/ === RUBY_PLATFORM
30
- s.add_development_dependency 'pry', '~> 0.10'
31
- s.add_development_dependency 'pry-byebug', '~> 2.0' if RUBY_VERSION >= '2'
32
- end
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', '~> 10', '>= 10.3.2'
38
+ s.add_development_dependency 'rake', '>= 12.3.3'
35
39
  s.add_development_dependency 'minitest', '~> 5.4'
36
- s.add_development_dependency 'rubydns', '~> 1.0'
37
- s.add_development_dependency 'nio4r', '~> 1.1'
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
43
48
 
44
- s.add_runtime_dependency 'addressable', '~> 2.5'
49
+ s.add_runtime_dependency 'simpleidn', '~> 0.1'
45
50
  end
46
51
 
data/lib/dnsruby.rb CHANGED
@@ -25,10 +25,6 @@ require 'dnsruby/DNS'
25
25
  require 'dnsruby/hosts'
26
26
  require 'dnsruby/update'
27
27
  require 'dnsruby/zone_transfer'
28
- require 'dnsruby/dnssec'
29
- require 'dnsruby/zone_reader'
30
- require 'dnsruby/resolv'
31
-
32
28
 
33
29
  # = Dnsruby library
34
30
  # Dnsruby is a thread-aware DNS stub resolver library written in Ruby.
@@ -239,3 +235,7 @@ module Dnsruby
239
235
  class ZoneSerialError < ResolvError
240
236
  end
241
237
  end
238
+
239
+ require 'dnsruby/dnssec'
240
+ require 'dnsruby/zone_reader'
241
+ require 'dnsruby/resolv'
data/lib/dnsruby/DNS.rb CHANGED
@@ -290,7 +290,7 @@ module Dnsruby
290
290
  msg.do_caching = do_caching
291
291
  @resolver.do_validation = false
292
292
  @resolver.send_async(msg, q)
293
- id, ret, exception = q.pop
293
+ _id, ret, exception = q.pop
294
294
  if (exception == nil && ret && ret.rcode == RCode.NOERROR)
295
295
  return ret, ret.question[0].qname
296
296
  end
@@ -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
  #
@@ -84,13 +85,10 @@ module Dnsruby
84
85
  def initialize()
85
86
  @mutex = Mutex.new
86
87
  @configured = false
87
- # parse_config
88
88
  end
89
89
  # Reset the config to default values
90
90
  def Config.reset
91
- c = Config.new
92
91
  @configured = false
93
- # c.parse_config
94
92
  end
95
93
 
96
94
  def parse_config(config_info=nil) #:nodoc: all
@@ -101,7 +99,7 @@ module Dnsruby
101
99
  dom=""
102
100
  nd = 1
103
101
  @ndots = 1
104
- @port = 53
102
+ @port = DEFAULT_PORT
105
103
  @apply_search_list = true
106
104
  @apply_domain = true
107
105
  config_hash = Config.default_config_hash
@@ -165,7 +163,7 @@ module Dnsruby
165
163
  # Set port
166
164
  def port=(p)
167
165
  @configured = true
168
- @port=p
166
+ @port=p if p
169
167
  if !@port.kind_of?(Integer)
170
168
  raise ArgumentError.new("invalid port config: #{@port.inspect}")
171
169
  end
@@ -206,13 +204,13 @@ module Dnsruby
206
204
  if (String ===n)
207
205
  # Make sure we can make a Name or an address from it
208
206
  begin
209
- a = IPv4.create(n)
207
+ IPv4.create(n)
210
208
  rescue ArgumentError
211
209
  begin
212
- a = IPv6.create(n)
210
+ IPv6.create(n)
213
211
  rescue ArgumentError
214
212
  begin
215
- a = Name.create(n)
213
+ Name.create(n)
216
214
  rescue ArgumentError
217
215
  raise ArgumentError.new("Can't interpret #{n} as IPv4, IPv6 or Name")
218
216
  end
@@ -315,14 +313,16 @@ module Dnsruby
315
313
  search = nil
316
314
  domain = nil
317
315
  ndots = 1
318
- port = 53
316
+ port = DEFAULT_PORT
319
317
  open(filename) {|f|
320
318
  f.each {|line|
321
319
  line.sub!(/[#;].*/, '')
322
320
  keyword, *args = line.split(/\s+/)
323
- args.each { |arg|
324
- arg.untaint
325
- }
321
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.8")
322
+ args.each { |arg|
323
+ arg.untaint
324
+ }
325
+ end
326
326
  next unless keyword
327
327
  case keyword
328
328
  when 'port'
@@ -471,4 +471,4 @@ module Dnsruby
471
471
  return candidates
472
472
  end
473
473
  end
474
- end
474
+ end
@@ -128,6 +128,7 @@ module Dnsruby
128
128
  @@validation_policy = ValidationPolicy::LOCAL_ANCHORS_THEN_ROOT
129
129
  @@root_verifier = SingleVerifier.new(SingleVerifier::VerifierType::ROOT)
130
130
  @@root_verifier.add_root_ds(@@root_key)
131
+ @@root_verifier.add_root_ds(@@root_key_new)
131
132
 
132
133
  @@dlv_verifier = SingleVerifier.new(SingleVerifier::VerifierType::DLV)
133
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
- addr.untaint
61
- hostname.untaint
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
- n.untaint
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
@@ -17,7 +17,7 @@ class MessageEncoder #:nodoc: all
17
17
  def put_pack(template, *d)
18
18
  begin
19
19
  @data << d.pack(template)
20
- rescue Encoding::CompatibilityError => e
20
+ rescue Encoding::CompatibilityError
21
21
  raise Dnsruby::EncodeError.new("IDN support currently requires punycode string")
22
22
  end
23
23
  end
@@ -35,7 +35,7 @@ class MessageEncoder #:nodoc: all
35
35
  begin
36
36
  self.put_pack("C", d.length)
37
37
  @data << d
38
- rescue Encoding::CompatibilityError => e
38
+ rescue Encoding::CompatibilityError
39
39
  raise Dnsruby::EncodeError.new("IDN support currently requires punycode string")
40
40
  end
41
41
  end
@@ -31,9 +31,6 @@ class Header
31
31
  # and is allowed to set the bit by policy.)
32
32
  attr_accessor :ad
33
33
 
34
- # The query response flag
35
- attr_accessor :qr
36
-
37
34
  # Recursion available flag
38
35
  attr_accessor :ra
39
36
 
data/lib/dnsruby/name.rb CHANGED
@@ -27,7 +27,7 @@ module Dnsruby
27
27
  # * Name#subdomain_of?(other)
28
28
  # * Name#labels
29
29
  #
30
- require 'addressable'
30
+ require 'simpleidn'
31
31
  class Name
32
32
  include Comparable
33
33
  MaxNameLength=255
@@ -63,20 +63,18 @@ module Dnsruby
63
63
  end
64
64
  end
65
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"
66
72
  def self.punycode(d)
67
- begin
68
- c = Addressable::URI.parse("http://" + d.to_s)
69
- ret = c.normalized_host.sub("http://", "")
70
- if (!d.end_with?".")
71
- return ret.chomp(".")
72
- end
73
- if (!ret.end_with?".")
74
- return ret + "."
75
- end
76
- return ret
77
- rescue Exception => e
78
- return d
79
- end
73
+ begin
74
+ return SimpleIDN.to_ascii(d)
75
+ rescue
76
+ return d
77
+ end
80
78
  end
81
79
 
82
80
  def self.split_escaped(arg) #:nodoc: all
@@ -261,7 +259,7 @@ module Dnsruby
261
259
  # in: dName a string with a domain name in presentation format (1035
262
260
  # sect 5.1)
263
261
  # out: an array of labels in wire format.
264
- def self.name2encodedlabels (dName) #:nodoc: all
262
+ def self.name2encodedlabels(dName) #:nodoc: all
265
263
  # Check for "\" in the name : If there, then decode properly - otherwise, cheat and split on "."
266
264
  if (dName.index("\\"))
267
265
  names=[]
@@ -204,26 +204,22 @@ module Dnsruby
204
204
  @tcp_pipelining_max_queries = :infinite
205
205
  @use_counts = {}
206
206
 
207
- if (arg==nil)
208
- # Get default config
209
- config = Config.new
210
- # @server = config.nameserver[0]
211
- elsif (arg.kind_of? String)
212
- @server=arg
213
- elsif (arg.kind_of? Name)
214
- @server=arg
215
- elsif (arg.kind_of? Hash)
207
+ if arg.nil?
208
+ elsif arg.kind_of? String
209
+ @server = arg
210
+ elsif arg.kind_of? Name
211
+ @server = arg
212
+ elsif arg.kind_of? Hash
216
213
  arg.keys.each do |attr|
217
214
  begin
218
- if (((attr.to_s == "src_address")||(attr.to_s == "src_address6")) &&
219
- ((arg[attr] == nil) || (arg[attr] == "")))
215
+ if ((attr.to_s == "src_address" || attr.to_s == "src_address6") &&
216
+ (arg[attr] == nil || arg[attr] == ""))
220
217
  else
221
- send(attr.to_s+"=", arg[attr])
218
+ send(attr.to_s + "=", arg[attr])
222
219
  end
223
220
  rescue Exception => e
224
221
  Dnsruby.log.error { "PacketSender : Argument #{attr}, #{arg[attr]} not valid : #{e}\n" }
225
222
  end
226
- # end
227
223
  end
228
224
  end
229
225
  # Check server is IP
@@ -235,12 +231,12 @@ module Dnsruby
235
231
 
236
232
  def check_ipv6
237
233
  begin
238
- i = IPv4.create(@server)
234
+ IPv4.create(@server)
239
235
  # @src_address = '0.0.0.0'
240
236
  @ipv6=false
241
237
  rescue Exception
242
238
  begin
243
- i = IPv6.create(@server)
239
+ IPv6.create(@server)
244
240
  # @src_address6 = '::'
245
241
  @ipv6=true
246
242
  rescue Exception
@@ -456,7 +452,7 @@ module Dnsruby
456
452
  socket, new_socket = tcp_pipeline_socket(src_port)
457
453
  src_port = @tcp_pipeline_local_port
458
454
  else
459
- socket = TCPSocket.new(@server, @port, src_address, src_port)
455
+ socket = Socket.tcp(@server, @port, src_address, src_port, connect_timeout: @packet_timeout)
460
456
  new_socket = true
461
457
  end
462
458
  rescue Errno::EBADF, Errno::ENETUNREACH => e