dnsruby 1.60.1 → 1.60.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/RELEASE_NOTES.md +8 -0
- data/lib/dnsruby/resolver.rb +1 -0
- data/lib/dnsruby/resource/CAA.rb +6 -4
- data/lib/dnsruby/resource/NAPTR.rb +9 -7
- data/lib/dnsruby/select_thread.rb +0 -1
- data/lib/dnsruby/update.rb +65 -48
- data/lib/dnsruby/version.rb +1 -1
- data/test/tc_update.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 286d5426865cf680082a434f91ceb9004ef616ca
|
4
|
+
data.tar.gz: b6dfef1f6420e1246c074c86de4ddac5260ba02a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d447b1b997edfad80524e859f7088143e6b48dc3da6fdbf942777ff8d1f8ad40d09944b8679965ea1623804ecc92c54814d271d7faec73e858a5836d14196173
|
7
|
+
data.tar.gz: 5f4c06324994a7c07b2257cfaef48b2f482305189fad014a846cf88ccd91988e480949c3279f824e401724a1be7fd83d8427fc766a2b486f898c04430bcdab51
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Release Notes
|
2
2
|
|
3
|
+
## v1.60.2
|
4
|
+
|
5
|
+
* Fix deletion of TXT records with spaces in dynamic updates (thanks Sean Dilda)
|
6
|
+
* Fix use of non-default ports in Dnsruby::Resolver (thanks Thomas Morgan)
|
7
|
+
* Fix NAPTR encoding for null rdata dynamic update packets
|
8
|
+
* Fix CAA resource record encoding
|
9
|
+
* Avoid changing ruby global thread abort behavior (thanks Brent Cook)
|
10
|
+
|
3
11
|
## v1.60.1
|
4
12
|
|
5
13
|
* DNSSEC validation switched OFF by default (but can still be switched on)
|
data/lib/dnsruby/resolver.rb
CHANGED
data/lib/dnsruby/resource/CAA.rb
CHANGED
@@ -54,15 +54,17 @@ module Dnsruby
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def encode_rdata(msg, canonical=false) #:nodoc: all
|
57
|
-
msg.put_pack('
|
57
|
+
msg.put_pack('C', flag)
|
58
58
|
msg.put_string(@property_tag)
|
59
|
-
|
59
|
+
# We don't put a length byte on the final string.
|
60
|
+
msg.put_bytes(@property_value)
|
60
61
|
end
|
61
62
|
|
62
63
|
def self.decode_rdata(msg) #:nodoc: all
|
63
|
-
flag, = msg.get_unpack('
|
64
|
+
flag, = msg.get_unpack('C')
|
64
65
|
property_tag = msg.get_string
|
65
|
-
|
66
|
+
# The final string has no length byte - its length is implicit as the remainder of the packet length
|
67
|
+
property_value = msg.get_bytes
|
66
68
|
return self.new("#{flag} #{property_tag} \"#{property_value}\"")
|
67
69
|
end
|
68
70
|
end
|
@@ -52,7 +52,7 @@ module Dnsruby
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def from_string(input) #:nodoc: all
|
55
|
-
if (input.length > 0)
|
55
|
+
if (input.strip.length > 0)
|
56
56
|
values = input.split(" ")
|
57
57
|
@order = values [0].to_i
|
58
58
|
@preference = values [1].to_i
|
@@ -76,12 +76,14 @@ module Dnsruby
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def encode_rdata(msg, canonical=false) #:nodoc: all
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
79
|
+
if (@order != nil)
|
80
|
+
msg.put_pack('n', @order)
|
81
|
+
msg.put_pack('n', @preference)
|
82
|
+
msg.put_string(@flags)
|
83
|
+
msg.put_string(@service)
|
84
|
+
msg.put_string(@regexp)
|
85
|
+
msg.put_name(@replacement, true)
|
86
|
+
end
|
85
87
|
end
|
86
88
|
|
87
89
|
def self.decode_rdata(msg) #:nodoc: all
|
data/lib/dnsruby/update.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# --
|
2
2
|
# Copyright 2007 Nominet UK
|
3
|
-
#
|
3
|
+
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
# you may not use this file except in compliance with the License.
|
6
6
|
# You may obtain a copy of the License at
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Unless required by applicable law or agreed to in writing, software
|
11
11
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -20,81 +20,81 @@ module Dnsruby
|
|
20
20
|
|
21
21
|
# The first example below shows a complete program; subsequent examples
|
22
22
|
# show only the creation of the update packet.
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# == Add a new host
|
25
|
-
#
|
25
|
+
#
|
26
26
|
# require 'Dnsruby'
|
27
|
-
#
|
27
|
+
#
|
28
28
|
# # Create the update packet.
|
29
29
|
# update = Dnsruby::Update.new('example.com')
|
30
|
-
#
|
30
|
+
#
|
31
31
|
# # Prerequisite is that no A records exist for the name.
|
32
32
|
# update.absent('foo.example.com.', 'A')
|
33
|
-
#
|
33
|
+
#
|
34
34
|
# # Add two A records for the name.
|
35
35
|
# update.add('foo.example.com.', 'A', 86400, '192.168.1.2')
|
36
36
|
# update.add('foo.example.com.', 'A', 86400, '172.16.3.4')
|
37
|
-
#
|
37
|
+
#
|
38
38
|
# # Send the update to the zone's primary master.
|
39
39
|
# res = Dnsruby::Resolver.new({:nameserver => 'primary-master.example.com'})
|
40
|
-
#
|
40
|
+
#
|
41
41
|
# begin
|
42
42
|
# reply = res.send_message(update)
|
43
43
|
# print "Update succeeded\n"
|
44
44
|
# rescue Exception => e
|
45
45
|
# print 'Update failed: #{e}\n'
|
46
46
|
# end
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# == Add an MX record for a name that already exists
|
49
|
-
#
|
49
|
+
#
|
50
50
|
# update = Dnsruby::Update.new('example.com')
|
51
51
|
# update.present('example.com')
|
52
|
-
# update.add('example.com', Dnsruby::Types.MX, 10, 'mailhost.example.com')
|
53
|
-
#
|
52
|
+
# update.add('example.com', Dnsruby::Types.MX, 86400, 10, 'mailhost.example.com')
|
53
|
+
#
|
54
54
|
# == Add a TXT record for a name that doesn't exist
|
55
|
-
#
|
55
|
+
#
|
56
56
|
# update = Dnsruby::Update.new('example.com')
|
57
57
|
# update.absent('info.example.com')
|
58
58
|
# update.add('info.example.com', Types.TXT, 86400, "yabba dabba doo"')
|
59
|
-
#
|
59
|
+
#
|
60
60
|
# == Delete all A records for a name
|
61
|
-
#
|
61
|
+
#
|
62
62
|
# update = Dnsruby::Update.new('example.com')
|
63
63
|
# update.present('foo.example.com', 'A')
|
64
64
|
# update.delete('foo.example.com', 'A')
|
65
|
-
#
|
65
|
+
#
|
66
66
|
# == Delete all RRs for a name
|
67
|
-
#
|
67
|
+
#
|
68
68
|
# update = Dnsruby::Update.new('example.com')
|
69
69
|
# update.present('byebye.example.com')
|
70
70
|
# update.delete('byebye.example.com')
|
71
|
-
#
|
71
|
+
#
|
72
72
|
# == Perform a signed update
|
73
|
-
#
|
73
|
+
#
|
74
74
|
# key_name = 'tsig-key'
|
75
75
|
# key = 'awwLOtRfpGE+rRKF2+DEiw=='
|
76
|
-
#
|
76
|
+
#
|
77
77
|
# update = Dnsruby::Update.new('example.com')
|
78
|
-
# update.add('foo.example.com', 'A', 86400, 10.1.2.3'))
|
79
|
-
# update.add('bar.example.com', 'A', 86400, 10.4.5.6'))
|
78
|
+
# update.add('foo.example.com', 'A', 86400, '10.1.2.3'))
|
79
|
+
# update.add('bar.example.com', 'A', 86400, '10.4.5.6'))
|
80
80
|
# res.tsig=(key_name,key)
|
81
|
-
#
|
81
|
+
#
|
82
82
|
class Update < Message
|
83
83
|
# Returns a Dnsruby::Update object suitable for performing a DNS
|
84
84
|
# dynamic update. Specifically, it creates a message with the header
|
85
85
|
# opcode set to UPDATE and the zone record type to SOA (per RFC 2136,
|
86
86
|
# Section 2.3).
|
87
|
-
#
|
87
|
+
#
|
88
88
|
# Programs must use the push method to add RRs to the prerequisite,
|
89
89
|
# update, and additional sections before performing the update.
|
90
|
-
#
|
90
|
+
#
|
91
91
|
# Arguments are the zone name and the class. If the zone is omitted,
|
92
92
|
# the default domain will be taken from the resolver configuration.
|
93
93
|
# If the class is omitted, it defaults to IN.
|
94
94
|
# packet = Dnsruby::Update.new
|
95
95
|
# packet = Dnsruby::Update.new('example.com')
|
96
96
|
# packet = Dnsruby::Update.new('example.com', 'HS')
|
97
|
-
#
|
97
|
+
#
|
98
98
|
def initialize(zone=nil, klass=nil)
|
99
99
|
|
100
100
|
# sort out the zone section (RFC2136, section 2.3)
|
@@ -115,25 +115,25 @@ module Dnsruby
|
|
115
115
|
end
|
116
116
|
|
117
117
|
# Ways to create the prerequisite records (exists, notexists, inuse, etc. - RFC2136, section 2.4)
|
118
|
-
#
|
118
|
+
#
|
119
119
|
# (1) RRset exists (value independent). At least one RR with a
|
120
120
|
# specified NAME and TYPE (in the zone and class specified by
|
121
121
|
# the Zone Section) must exist.
|
122
|
-
#
|
122
|
+
#
|
123
123
|
# update.present(name, type)
|
124
|
-
#
|
124
|
+
#
|
125
125
|
# (2) RRset exists (value dependent). A set of RRs with a
|
126
126
|
# specified NAME and TYPE exists and has the same members
|
127
127
|
# with the same RDATAs as the RRset specified here in this
|
128
128
|
# Section.
|
129
|
-
#
|
129
|
+
#
|
130
130
|
# update.present(name, type, rdata)
|
131
|
-
#
|
131
|
+
#
|
132
132
|
# (4) Name is in use. At least one RR with a specified NAME (in
|
133
133
|
# the zone and class specified by the Zone Section) must exist.
|
134
134
|
# Note that this prerequisite is NOT satisfied by empty
|
135
135
|
# nonterminals.
|
136
|
-
#
|
136
|
+
#
|
137
137
|
# update.present(name)
|
138
138
|
def present(*args)
|
139
139
|
ttl = 0
|
@@ -159,18 +159,18 @@ module Dnsruby
|
|
159
159
|
|
160
160
|
# Ways to create the prerequisite records (exists, notexists, inuse, etc. - RFC2136, section 2.4)
|
161
161
|
# Can be called with one arg :
|
162
|
-
#
|
162
|
+
#
|
163
163
|
# update.absent(name)
|
164
164
|
# (5) Name is not in use. No RR of any type is owned by a
|
165
165
|
# specified NAME. Note that this prerequisite IS satisfied by
|
166
166
|
# empty nonterminals.
|
167
|
-
#
|
167
|
+
#
|
168
168
|
# Or with two :
|
169
|
-
#
|
169
|
+
#
|
170
170
|
# update.absent(name, type)
|
171
171
|
# (3) RRset does not exist. No RRs with a specified NAME and TYPE
|
172
172
|
# (in the zone and class denoted by the Zone Section) can exist.
|
173
|
-
#
|
173
|
+
#
|
174
174
|
def absent(*args)
|
175
175
|
ttl = 0
|
176
176
|
rdata = ""
|
@@ -191,16 +191,16 @@ module Dnsruby
|
|
191
191
|
|
192
192
|
# Ways to create the update records (add, delete, RFC2136, section 2.5)
|
193
193
|
# " 2.5.1 - Add To An RRset
|
194
|
-
#
|
194
|
+
#
|
195
195
|
# RRs are added to the Update Section whose NAME, TYPE, TTL, RDLENGTH
|
196
196
|
# and RDATA are those being added, and CLASS is the same as the zone
|
197
197
|
# class. Any duplicate RRs will be silently ignored by the primary
|
198
198
|
# master."
|
199
|
-
#
|
199
|
+
#
|
200
200
|
# update.add(rr)
|
201
201
|
# update.add([rr1, rr2])
|
202
202
|
# update.add(name, type, ttl, rdata)
|
203
|
-
#
|
203
|
+
#
|
204
204
|
def add(*args)
|
205
205
|
zoneclass=zone()[0].zclass
|
206
206
|
case args[0]
|
@@ -244,17 +244,17 @@ module Dnsruby
|
|
244
244
|
end
|
245
245
|
|
246
246
|
# Ways to create the update records (add, delete, RFC2136, section 2.5)
|
247
|
-
#
|
247
|
+
#
|
248
248
|
# 2.5.2 - Delete An RRset
|
249
249
|
# update.delete(name, type)
|
250
|
-
#
|
251
|
-
#
|
250
|
+
#
|
251
|
+
#
|
252
252
|
# 2.5.3 - Delete All RRsets From A Name
|
253
253
|
# update.delete(name)
|
254
|
-
#
|
254
|
+
#
|
255
255
|
# 2.5.4 - Delete An RR From An RRset
|
256
256
|
# update.delete(name, type, rdata)
|
257
|
-
#
|
257
|
+
#
|
258
258
|
def delete(*args)
|
259
259
|
ttl = 0
|
260
260
|
klass = Classes.ANY
|
@@ -268,11 +268,28 @@ module Dnsruby
|
|
268
268
|
resource = RR.create("#{args[0]} #{ttl} #{klass} #{args[1]} #{rdata}")
|
269
269
|
add_update(resource)
|
270
270
|
when 3 # name, type, rdata
|
271
|
-
|
271
|
+
name = args[0]
|
272
|
+
type = args[1]
|
273
|
+
rdata = args[2]
|
274
|
+
if (Types.new(type) == Types.TXT)
|
275
|
+
instring = "#{name} #{ttl} IN #{type} ";
|
276
|
+
if (String === rdata)
|
277
|
+
instring += " '#{rdata}'"
|
278
|
+
elsif (Array === rdata)
|
279
|
+
rdata.length.times {|rcounter|
|
280
|
+
instring += " '#{rdata[rcounter]}' "
|
281
|
+
}
|
282
|
+
else
|
283
|
+
instring += rdata
|
284
|
+
end
|
285
|
+
resource = RR.create(instring)
|
286
|
+
else
|
287
|
+
resource = RR.create("#{name} #{ttl} IN #{type} #{rdata}")
|
288
|
+
end
|
272
289
|
resource.klass = Classes.NONE
|
273
290
|
add_update(resource)
|
274
291
|
end
|
275
292
|
return resource
|
276
293
|
end
|
277
294
|
end
|
278
|
-
end
|
295
|
+
end
|
data/lib/dnsruby/version.rb
CHANGED
data/test/tc_update.rb
CHANGED
@@ -274,6 +274,18 @@ class TestUpdate < Minitest::Test
|
|
274
274
|
assert(update.to_s.index("test signed update"))
|
275
275
|
end
|
276
276
|
|
277
|
+
def test_delete_txt
|
278
|
+
update = Update.new 'example.com'
|
279
|
+
update.delete 'test.example.com', 'TXT', 'foo bar'
|
280
|
+
|
281
|
+
encoded_msg = Message.decode update.encode
|
282
|
+
rr = encoded_msg.authority.first
|
283
|
+
assert_equal rr.name.to_s, 'test.example.com', 'delete_txt - right name'
|
284
|
+
assert_equal 0, rr.ttl, 'delete_txt - right ttl'
|
285
|
+
assert_equal 'TXT', rr.type.string, 'delete_txt - right type'
|
286
|
+
assert_equal ['foo bar'], rr.rdata, 'delete_txt - right rdata'
|
287
|
+
end
|
288
|
+
|
277
289
|
def test_array
|
278
290
|
update = Update.new
|
279
291
|
update.add("target_name", "TXT", 100, ['"test signed update"', 'item#2'])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.60.
|
4
|
+
version: 1.60.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dalitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|