dnsruby 1.60.0 → 1.60.1

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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/RELEASE_NOTES.md +14 -0
  3. data/lib/dnsruby/bit_mapping.rb +1 -1
  4. data/lib/dnsruby/code_mapper.rb +3 -3
  5. data/lib/dnsruby/code_mappers.rb +4 -2
  6. data/lib/dnsruby/config.rb +1 -1
  7. data/lib/dnsruby/dnssec.rb +1 -1
  8. data/lib/dnsruby/packet_sender.rb +8 -5
  9. data/lib/dnsruby/resolver.rb +6 -6
  10. data/lib/dnsruby/resource/APL.rb +146 -0
  11. data/lib/dnsruby/resource/CAA.rb +70 -0
  12. data/lib/dnsruby/resource/IN.rb +4 -1
  13. data/lib/dnsruby/resource/MX.rb +3 -0
  14. data/lib/dnsruby/resource/OPT.rb +1 -1
  15. data/lib/dnsruby/resource/RRSIG.rb +1 -1
  16. data/lib/dnsruby/resource/TLSA.rb +149 -0
  17. data/lib/dnsruby/resource/domain_name.rb +1 -1
  18. data/lib/dnsruby/resource/generic.rb +1 -0
  19. data/lib/dnsruby/version.rb +1 -1
  20. data/lib/dnsruby/zone_transfer.rb +5 -2
  21. data/test/run-tests-individually +347 -0
  22. data/test/spec_helper.rb +3 -3
  23. data/test/tc_caa.rb +49 -0
  24. data/test/tc_cache.rb +6 -16
  25. data/test/tc_dlv.rb +3 -2
  26. data/test/tc_dns.rb +3 -1
  27. data/test/tc_ds.rb +4 -1
  28. data/test/tc_escapedchars.rb +3 -1
  29. data/test/tc_gpos.rb +2 -2
  30. data/test/tc_header.rb +3 -1
  31. data/test/tc_hip.rb +3 -1
  32. data/test/tc_hs.rb +0 -2
  33. data/test/tc_ipseckey.rb +3 -1
  34. data/test/tc_message.rb +0 -16
  35. data/test/tc_name.rb +3 -1
  36. data/test/tc_naptr.rb +3 -1
  37. data/test/tc_nsec.rb +3 -3
  38. data/test/tc_nsec3.rb +3 -1
  39. data/test/tc_nsec3param.rb +3 -1
  40. data/test/tc_nxt.rb +2 -2
  41. data/test/tc_packet.rb +3 -2
  42. data/test/tc_packet_unique_push.rb +3 -1
  43. data/test/tc_ptrin.rb +2 -1
  44. data/test/tc_question.rb +3 -1
  45. data/test/tc_res_env.rb +3 -1
  46. data/test/tc_res_opt.rb +3 -1
  47. data/test/tc_resolv.rb +1 -2
  48. data/test/tc_resolver.rb +18 -19
  49. data/test/tc_rr-opt.rb +3 -2
  50. data/test/tc_rr-txt.rb +3 -1
  51. data/test/tc_rr-unknown.rb +3 -1
  52. data/test/tc_rr.rb +15 -1
  53. data/test/tc_single_resolver.rb +4 -1
  54. data/test/tc_soak.rb +2 -1
  55. data/test/tc_soak_base.rb +2 -0
  56. data/test/tc_sshfp.rb +3 -1
  57. data/test/tc_tlsa.rb +191 -0
  58. data/test/tc_tsig.rb +3 -1
  59. data/test/tc_update.rb +6 -3
  60. data/test/tc_validator.rb +3 -2
  61. data/test/tc_zone_reader.rb +4 -2
  62. data/test/ts_offline.rb +1 -0
  63. data/test/ts_online.rb +6 -7
  64. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9cbbb2842379ff348cbf0c96c37b83b6d1d083b
4
- data.tar.gz: 8671561563ae35728ea271a47b8d83755f2a2922
3
+ metadata.gz: cfb5e0f9d0b657bba3a0ad8d8edde456e253d638
4
+ data.tar.gz: 4c80209c7c2e6823e1958e9c79c0665805c0f9a0
5
5
  SHA512:
6
- metadata.gz: 5d1835489ddf5269acb69de004d0a5c699ab80b7189dcbe1479aa838785d8fe939b3f30bd83ed8e32d23c37f265fb991c31956026528a33524410bb2d4256f4b
7
- data.tar.gz: bd9c08507b6ebeddb5b8b85be6434c2a7245f754c59aba459dc897960b385bee84db3cccc91ceb198f01c011afa1a81d35533de7ba120a9eaca7082393eb46a8
6
+ metadata.gz: 2f53ebb527626d922813c53b4c8cd8daa73ff22721a812ea55963c28201b44da43c7be779316fb9e3041a7183e0c7c3ef99faf73a69fb9fb9845b70ce428f31f
7
+ data.tar.gz: b93907dc484ddd07a0fcd2b8eaeebbc92d261c23bd2046ce7c6159c75a3fe350eae485977b6afcac44bcdf999501d2eb4255f92118f1e8f0e682193d74db9dfa
@@ -1,5 +1,19 @@
1
1
  # Release Notes
2
2
 
3
+ ## v1.60.1
4
+
5
+ * DNSSEC validation switched OFF by default (but can still be switched on)
6
+ * Add APL RR support (thanks Manabu Sonoda)
7
+ * Various test fixes (thanks Keith Bennett)
8
+ * 'include' issues fixed (thanks Keith Bennett!)
9
+ * Fixnum replacement (thanks Keith Bennett)
10
+ * Zone transfer fixes (thanks Manabu Sonoda)
11
+ * Name decoding fix
12
+ * MX record passing error now raised
13
+ * CAA RR support (thanks Richard Luther)
14
+ * TLSA RR support (thanks Manabu Sonoda)
15
+
16
+
3
17
  ## v1.60.0
4
18
 
5
19
  * TCP multi-packet support fixed
@@ -120,7 +120,7 @@ module Dnsruby
120
120
  def assert_non_negative(number)
121
121
  unless number.is_a?(Integer) && number >= 0
122
122
  raise ArgumentError.new(
123
- "Parameter must be a nonnegative Integer (Fixnum, Bignum) " +
123
+ "Parameter must be a nonnegative Integer " +
124
124
  "but is #{number.inspect} (a #{number.class})")
125
125
  end
126
126
  end
@@ -103,7 +103,7 @@ module Dnsruby
103
103
  else
104
104
  unknown_string(arg)
105
105
  end
106
- elsif (arg.kind_of?Fixnum)
106
+ elsif arg.kind_of?(Integer)
107
107
  if (array.values[arg] != nil)
108
108
  @code = arg
109
109
  @string = array.values[@code]
@@ -146,7 +146,7 @@ module Dnsruby
146
146
  end
147
147
 
148
148
  def CodeMapper.to_code(arg)
149
- if (arg.kind_of?Fixnum)
149
+ if arg.kind_of?(Integer)
150
150
  return arg
151
151
  else
152
152
  return @@arrays[self].stringsdown[arg.downcase]
@@ -154,7 +154,7 @@ module Dnsruby
154
154
  end
155
155
 
156
156
  def <=>(other)
157
- if (other.class == Fixnum)
157
+ if other.is_a?(Integer)
158
158
  self.code <=> other
159
159
  else
160
160
  self.code <=> other.code
@@ -150,7 +150,7 @@ module Dnsruby
150
150
  CERT = 37 # RFC 2538
151
151
  DNAME = 39 # RFC 2672
152
152
  OPT = 41 # RFC 2671
153
- # APL = 42 # RFC 3123
153
+ APL = 42 # RFC 3123
154
154
  DS = 43 # RFC 4034
155
155
  SSHFP = 44 # RFC 4255
156
156
  IPSECKEY = 45 # RFC 4025
@@ -160,6 +160,7 @@ module Dnsruby
160
160
  DHCID = 49 # RFC 4701
161
161
  NSEC3 = 50 # RFC still pending at time of writing
162
162
  NSEC3PARAM= 51 # RFC still pending at time of writing
163
+ TLSA = 52 # RFC 6698
163
164
  HIP = 55 # RFC 5205
164
165
  SPF = 99 # RFC 4408
165
166
  UINFO = 100 # non-standard
@@ -173,6 +174,7 @@ module Dnsruby
173
174
  MAILB = 253 # RFC 1035 (MB, MG, MR)
174
175
  MAILA = 254 # RFC 1035 (obsolete - see MX)
175
176
  ANY = 255 # RFC 1035
177
+ CAA = 257 # RFC 6844
176
178
  DLV = 32769 # RFC 4431 (informational)
177
179
  update()
178
180
 
@@ -292,4 +294,4 @@ module Dnsruby
292
294
  add_pair("SHA-1", 1)
293
295
  end
294
296
 
295
- end
297
+ end
@@ -73,7 +73,7 @@ module Dnsruby
73
73
  # nameserver (String)
74
74
  # domain (String)
75
75
  # search (String)
76
- # ndots (Fixnum)
76
+ # ndots (Integer)
77
77
  #
78
78
  # This method should not normally be called by client code.
79
79
  def set_config_info(config_info)
@@ -261,7 +261,7 @@ module Dnsruby
261
261
  def self.try_validation(last_level, last_error, last_error_level, proc, msg, query) # :nodoc:
262
262
  begin
263
263
  proc.call(msg, query)
264
- last_level = Message::SecurityLevel.new([msg.security_level.code, last_level].max)
264
+ last_level = Message::SecurityLevel.new([msg.security_level.code, last_level.code].max)
265
265
  rescue VerifyError => e
266
266
  if (last_error_level < last_level)
267
267
  last_error = e.to_s
@@ -16,9 +16,12 @@
16
16
  require 'dnsruby/select_thread'
17
17
  require 'ipaddr'
18
18
  # require 'dnsruby/iana_ports'
19
- include Socket::Constants
20
19
  module Dnsruby
20
+
21
21
  class PacketSender # :nodoc: all
22
+
23
+ include Socket::Constants
24
+
22
25
  @@authoritative_cache = Cache.new
23
26
  @@recursive_cache = Cache.new
24
27
 
@@ -402,7 +405,7 @@ module Dnsruby
402
405
  @tcp_pipeline_local_port = src_port
403
406
  src_address = @ipv6 ? @src_address6 : @src_address
404
407
  begin
405
- @pipeline_socket = Socket.new(AF_INET, SOCK_STREAM, 0)
408
+ @pipeline_socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
406
409
  @pipeline_socket.bind(Addrinfo.tcp(src_address, src_port))
407
410
  @pipeline_socket.connect(sockaddr)
408
411
  Dnsruby.log.debug("Creating socket #{src_address}:#{src_port}")
@@ -541,7 +544,7 @@ module Dnsruby
541
544
  end
542
545
 
543
546
  # The source port to send queries from
544
- # Returns either a single Fixnum or an Array
547
+ # Returns either a single Integer or an Array
545
548
  # e.g. "0", or "[60001, 60002, 60007]"
546
549
  #
547
550
  # Defaults to 0 - random port
@@ -552,7 +555,7 @@ module Dnsruby
552
555
  return @src_port
553
556
  end
554
557
 
555
- # Can be a single Fixnum or a Range or an Array
558
+ # Can be a single Integer or a Range or an Array
556
559
  # If an invalid port is selected (one reserved by
557
560
  # IANA), then an ArgumentError will be raised.
558
561
  #
@@ -565,7 +568,7 @@ module Dnsruby
565
568
  add_src_port(p)
566
569
  end
567
570
 
568
- # Can be a single Fixnum or a Range or an Array
571
+ # Can be a single Integer or a Range or an Array
569
572
  # If an invalid port is selected (one reserved by
570
573
  # IANA), then an ArgumentError will be raised.
571
574
  # "0" means "any valid port" - this is only a viable
@@ -77,7 +77,7 @@ module Dnsruby
77
77
  DefaultRetryDelay = 5
78
78
  DefaultPipeLiningMaxQueries = 5
79
79
  DefaultPort = 53
80
- DefaultDnssec = true
80
+ DefaultDnssec = false
81
81
  AbsoluteMinDnssecUdpSize = 1220
82
82
  MinDnssecUdpSize = 4096
83
83
  DefaultUDPSize = MinDnssecUdpSize
@@ -603,7 +603,7 @@ module Dnsruby
603
603
  end
604
604
 
605
605
  # The source port to send queries from
606
- # Returns either a single Fixnum or an Array
606
+ # Returns either a single Integer or an Array
607
607
  # e.g. '0', or '[60001, 60002, 60007]'
608
608
  #
609
609
  # Defaults to 0 - random port
@@ -611,7 +611,7 @@ module Dnsruby
611
611
  @src_port.length == 1 ? @src_port[0] : @src_port
612
612
  end
613
613
 
614
- # Can be a single Fixnum or a Range or an Array
614
+ # Can be a single Integer or a Range or an Array
615
615
  # If an invalid port is selected (one reserved by
616
616
  # IANA), then an ArgumentError will be raised.
617
617
  #
@@ -626,7 +626,7 @@ module Dnsruby
626
626
  end
627
627
  end
628
628
 
629
- # Can be a single Fixnum or a Range or an Array
629
+ # Can be a single Integer or a Range or an Array
630
630
  # If an invalid port is selected (one reserved by
631
631
  # IANA), then an ArgumentError will be raised.
632
632
  # "0" means "any valid port" - this is only a viable
@@ -653,7 +653,7 @@ module Dnsruby
653
653
  end
654
654
 
655
655
  def Resolver.check_port(p, src_port=[])
656
- if p.class != Fixnum
656
+ unless p.is_a?(Integer)
657
657
  tmp_src_ports = Array.new(src_port)
658
658
  p.each do |x|
659
659
  unless Resolver.check_port(x, tmp_src_ports)
@@ -677,7 +677,7 @@ module Dnsruby
677
677
 
678
678
  def Resolver.get_ports_from(p)
679
679
  a = []
680
- if p.class == Fixnum
680
+ if p.is_a?(Integer)
681
681
  a = [p]
682
682
  else
683
683
  p.each do |x|
@@ -0,0 +1,146 @@
1
+ module Dnsruby
2
+ class Prefix
3
+ Regex = %r{\A([!])?([12]):(.*)/(\d+)\z}
4
+ attr_reader :af, :prefix_length, :negative, :address_lenght, :address
5
+ class << self
6
+ def create(prefix) #:nodoc:
7
+ unless md = Regex.match(prefix)
8
+ raise ArgumentError.new('APL format error')
9
+ end
10
+ negative=md[1]
11
+ af = md[2].to_i
12
+ prefix_length = md[4].to_i
13
+ case af
14
+ when 1
15
+ if prefix_length > 32 ||
16
+ prefix_length < 0
17
+ raise ArgumentError.new('APL IPv4 prefix format error')
18
+ end
19
+ address = IPv4.create(md[3])
20
+ when 2
21
+ if prefix_length > 128 ||
22
+ prefix_length < 0
23
+ raise ArgumentError.new('APL IPv6 prefix format error')
24
+ end
25
+ address = IPv6.create(md[3])
26
+ else
27
+ raise ArgumentError.new('APL address family error')
28
+ end
29
+ address_length = (prefix_length / 8.0).ceil
30
+
31
+ Prefix.new(af, prefix_length, negative, address_length, address)
32
+ end
33
+ end
34
+ def initialize(af, prefix_length, negative, address_length, address)
35
+ @af = af
36
+ @prefix_length = prefix_length
37
+ @negative = negative
38
+ @address_length = address_length
39
+ @address = address
40
+ @flag = address_length
41
+ @flag |= 0x80 if @negative
42
+ end
43
+
44
+ def to_s
45
+ "#{@negative}#{@af}:#{@address}/#{@prefix_length}"
46
+ end
47
+
48
+ def put_msg(msg) #:nodoc: all
49
+ msg.put_pack('nCC',@af,@prefix_length,@flag)
50
+ msg.put_bytes(@address.address[0,@address_length])
51
+ end
52
+ end
53
+ class Prefixes
54
+ attr_accessor :prefixes
55
+ class << self
56
+ def create(arg)
57
+ case arg
58
+ when Prefixes
59
+ return arg
60
+ when String
61
+ prefixes = arg.split(/\s/).map { |prefix| Prefix.create(prefix) }
62
+ when Array
63
+ prefixes = arg.map { |prefix| Prefix.create(prefix) }
64
+ else
65
+ raise ArgumentError.new("APL format erro #{arg}")
66
+ end
67
+ Prefixes.new(prefixes)
68
+ end
69
+ def create_from_message(msg)
70
+ prefixes = []
71
+ while(msg.has_remaining?) do
72
+ negative = nil
73
+ af,prefix_length,flag = msg.get_unpack('nCC')
74
+ negative = '!' if 0x80 & flag == 0x80
75
+ address_length = flag & 0x7f
76
+
77
+ case(af)
78
+ when 1
79
+ addr = msg.get_bytes(address_length) + "\0" * (4 - address_length)
80
+ address = IPv4.new(addr)
81
+ when 2
82
+ addr = msg.get_bytes(address_length) + "\0" * (16 - address_length)
83
+ address = IPv6.new(addr)
84
+ else
85
+ raise ArgumentError.new("APL format error")
86
+ end
87
+ prefixes.push(Prefix.new(af, prefix_length, negative, address_length, address))
88
+ end
89
+
90
+ Prefixes.new(prefixes)
91
+ end
92
+ end
93
+ def initialize(prefixes)
94
+ @prefixes = prefixes
95
+ end
96
+
97
+ def to_s
98
+ @prefixes.map(&:to_s).join(' ')
99
+ end
100
+
101
+ def encode_rdata(msg, _canonical = false) #:nodoc: all
102
+ @prefixes.each do |prefix|
103
+ prefix.put_msg(msg)
104
+ end
105
+ end
106
+ end
107
+ class RR
108
+ module IN
109
+ # Class for DNS Address (A) resource records.
110
+ #
111
+ # RFC 1035 Section 3.4.1
112
+ class APL < RR
113
+ ClassHash[[TypeValue = Types::APL, ClassValue = ClassValue]] = self #:nodoc: all
114
+
115
+ # The RR's (Resolv::IPv4) address field
116
+ attr_accessor :prefixes
117
+
118
+ def from_data(data) #:nodoc: all
119
+ @prefixes = Prefixes.create(data)
120
+ end
121
+
122
+ # Create the RR from a hash
123
+ def from_hash(hash)
124
+ @prefixes = Prefixes.create(hash[:prefixes])
125
+ end
126
+
127
+ # Create the RR from a standard string
128
+ def from_string(input)
129
+ @prefixes = Prefixes.create(input)
130
+ end
131
+
132
+ def rdata_to_string
133
+ @prefixes.to_s
134
+ end
135
+
136
+ def encode_rdata(msg, canonical = false) #:nodoc: all
137
+ @prefixes.encode_rdata(msg,canonical)
138
+ end
139
+
140
+ def self.decode_rdata(msg) #:nodoc: all
141
+ new(Prefixes.create_from_message(msg))
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,70 @@
1
+ # --
2
+ # Copyright 2007 Nominet UK
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ # ++
16
+ module Dnsruby
17
+ class RR
18
+ # Class for CAA resource records.
19
+ # RFC 6844
20
+ class CAA < RR
21
+ ClassValue = nil #:nodoc: all
22
+ TypeValue= Types::CAA #:nodoc: all
23
+
24
+ # The property tag for the record (issue|issuewild|iodef)
25
+ attr_accessor :property_tag
26
+ # The value for the property_tag
27
+ attr_accessor :property_value
28
+ # The value for the flag
29
+ attr_accessor :flag
30
+
31
+ def from_hash(hash) #:nodoc: all
32
+ @property_tag = hash[:property_tag]
33
+ @property_value = hash[:property_value]
34
+ @flag = hash[:flag]
35
+ end
36
+
37
+ def from_data(data) #:nodoc: all
38
+ @flag, @property_tag, @property_value = data
39
+ end
40
+
41
+ def flag
42
+ @flag.to_i
43
+ end
44
+
45
+ def from_string(input) #:nodoc: all
46
+ matches = (/(\d+) (issuewild|issue|iodef) "(.+)"$/).match(input)
47
+ @flag = matches[1]
48
+ @property_tag = matches[2]
49
+ @property_value = matches[3]
50
+ end
51
+
52
+ def rdata_to_string #:nodoc: all
53
+ "#{flag} #{@property_tag} \"#{@property_value}\""
54
+ end
55
+
56
+ def encode_rdata(msg, canonical=false) #:nodoc: all
57
+ msg.put_pack('n', flag)
58
+ msg.put_string(@property_tag)
59
+ msg.put_string(@property_value)
60
+ end
61
+
62
+ def self.decode_rdata(msg) #:nodoc: all
63
+ flag, = msg.get_unpack('n')
64
+ property_tag = msg.get_string
65
+ property_value = msg.get_string
66
+ return self.new("#{flag} #{property_tag} \"#{property_value}\"")
67
+ end
68
+ end
69
+ end
70
+ end
@@ -54,7 +54,8 @@ module Dnsruby
54
54
  Types::HIP => HIP,
55
55
  Types::DHCID => DHCID,
56
56
  Types::GPOS => GPOS,
57
- Types::NXT => NXT
57
+ Types::NXT => NXT,
58
+ Types::CAA => CAA,
58
59
  } #:nodoc: all
59
60
 
60
61
  # module IN contains ARPA Internet specific RRs
@@ -103,3 +104,5 @@ require 'dnsruby/resource/AAAA'
103
104
  require 'dnsruby/resource/AFSDB'
104
105
  require 'dnsruby/resource/PX'
105
106
  require 'dnsruby/resource/SRV'
107
+ require 'dnsruby/resource/APL'
108
+ require 'dnsruby/resource/TLSA'