dnsruby 1.38 → 1.39
Sign up to get free protection for your applications and to get access to all the features.
- data/demo/digdlv.rb +1 -1
- data/lib/Dnsruby/resource/IN.rb +1 -1
- data/lib/Dnsruby/resource/NAPTR.rb +7 -7
- data/lib/Dnsruby/resource/NSEC.rb +4 -0
- data/lib/Dnsruby/resource/NSEC3.rb +5 -1
- data/lib/Dnsruby/resource/SSHFP.rb +91 -0
- data/lib/Dnsruby/resource/generic.rb +2 -1
- data/test/tc_nsec3.rb +12 -0
- data/test/tc_sshfp.rb +41 -0
- metadata +4 -2
data/demo/digdlv.rb
CHANGED
data/lib/Dnsruby/resource/IN.rb
CHANGED
@@ -19,7 +19,7 @@ module Dnsruby
|
|
19
19
|
NS, CNAME, DNAME, DNSKEY, SOA, PTR, HINFO, MINFO, MX, TXT,
|
20
20
|
ISDN, MB, MG, MR, NAPTR, NSAP, OPT, RP, RT, X25,
|
21
21
|
SPF, CERT, LOC, TSIG, TKEY, ANY, RRSIG, NSEC, DS, NSEC3,
|
22
|
-
NSEC3PARAM, DLV
|
22
|
+
NSEC3PARAM, DLV, SSHFP
|
23
23
|
] #:nodoc: all
|
24
24
|
|
25
25
|
# module IN contains ARPA Internet specific RRs
|
@@ -52,16 +52,16 @@ module Dnsruby
|
|
52
52
|
values = input.split(" ")
|
53
53
|
@order = values [0].to_i
|
54
54
|
@preference = values [1].to_i
|
55
|
-
@flags = values [2]
|
56
|
-
@service = values [3]
|
57
|
-
@regexp = values [4]
|
55
|
+
@flags = values [2].gsub!("\"", "")
|
56
|
+
@service = values [3].gsub!("\"", "")
|
57
|
+
@regexp = values [4].gsub!("\"", "")
|
58
58
|
@replacement = Name.create(values[5])
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
def rdata_to_string #:nodoc: all
|
63
63
|
if (@order!=nil)
|
64
|
-
return "#{@order} #{@preference} #{@flags} #{@service} #{@regexp} #{@replacement}"
|
64
|
+
return "#{@order} #{@preference} \"#{@flags}\" \"#{@service}\" \"#{@regexp}\" #{@replacement}"
|
65
65
|
else
|
66
66
|
return ""
|
67
67
|
end
|
@@ -79,9 +79,9 @@ module Dnsruby
|
|
79
79
|
def self.decode_rdata(msg) #:nodoc: all
|
80
80
|
order, = msg.get_unpack('n')
|
81
81
|
preference, = msg.get_unpack('n')
|
82
|
-
flags
|
83
|
-
service
|
84
|
-
regexp
|
82
|
+
flags = msg.get_string
|
83
|
+
service = msg.get_string
|
84
|
+
regexp = msg.get_string
|
85
85
|
replacement = msg.get_name
|
86
86
|
return self.new([order, preference, flags, service, regexp, replacement])
|
87
87
|
end
|
@@ -164,7 +164,11 @@ module Dnsruby
|
|
164
164
|
end
|
165
165
|
|
166
166
|
def types=(t)
|
167
|
+
if (t && t.length > 0)
|
167
168
|
@types = NSEC.get_types(t)
|
169
|
+
else
|
170
|
+
@types = []
|
171
|
+
end
|
168
172
|
end
|
169
173
|
|
170
174
|
def add_type(t)
|
@@ -256,7 +260,7 @@ module Dnsruby
|
|
256
260
|
|
257
261
|
def from_string(input)
|
258
262
|
if (input.length > 0)
|
259
|
-
data = input.split
|
263
|
+
data = input.split
|
260
264
|
self.hash_alg=(data[0]).to_i
|
261
265
|
self.flags=(data[1]).to_i
|
262
266
|
self.iterations=(data[2]).to_i
|
@@ -0,0 +1,91 @@
|
|
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 SSHFP < RR
|
19
|
+
ClassValue = nil #:nodoc: all
|
20
|
+
TypeValue = Types::SSHFP #:nodoc: all
|
21
|
+
|
22
|
+
attr_accessor :alg
|
23
|
+
attr_accessor :fptype
|
24
|
+
attr_accessor :fp
|
25
|
+
|
26
|
+
class Algorithms < CodeMapper
|
27
|
+
RSA = 1
|
28
|
+
DSS = 2
|
29
|
+
update()
|
30
|
+
end
|
31
|
+
|
32
|
+
class FpTypes < CodeMapper
|
33
|
+
SHA1 = 1
|
34
|
+
update()
|
35
|
+
end
|
36
|
+
|
37
|
+
def from_data(data) #:nodoc: all
|
38
|
+
alg, fptype, @fp = data
|
39
|
+
@alg = Algorithms.new(alg)
|
40
|
+
@fptype = FpTypes.new(fptype)
|
41
|
+
end
|
42
|
+
|
43
|
+
def from_hash(hash)
|
44
|
+
if hash[:alg]
|
45
|
+
@alg = Algorithms.new(hash[:alg])
|
46
|
+
end
|
47
|
+
if hash[:fptype]
|
48
|
+
@fptype = FpTypes.new(hash[:fptype])
|
49
|
+
end
|
50
|
+
if hash[:fp]
|
51
|
+
@fp = hash[:fp]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def from_string(input)
|
56
|
+
if (input.length > 0)
|
57
|
+
names = input.split(" ")
|
58
|
+
begin
|
59
|
+
@alg = Algorithms.new(names[0].to_i)
|
60
|
+
rescue ArgumentError
|
61
|
+
@alg = Algorithms.new(names[0])
|
62
|
+
end
|
63
|
+
begin
|
64
|
+
@fptype = FpTypes.new(names[1].to_i)
|
65
|
+
rescue ArgumentError
|
66
|
+
@fptype = FpTypes.new(names[1])
|
67
|
+
end
|
68
|
+
@fp = [names[2]].pack("H*")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def rdata_to_string
|
73
|
+
ret = "#{@alg.code} #{@fptype.code} "
|
74
|
+
ret += @fp.unpack("H*")[0]
|
75
|
+
return ret
|
76
|
+
end
|
77
|
+
|
78
|
+
def encode_rdata(msg, canonical=false) #:nodoc: all
|
79
|
+
msg.put_pack("c", @alg.code)
|
80
|
+
msg.put_pack("c", @fptype.code)
|
81
|
+
msg.put_bytes(@fp)
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.decode_rdata(msg) #:nodoc: all
|
85
|
+
alg, fptype = msg.get_unpack("cc")
|
86
|
+
fp = msg.get_bytes
|
87
|
+
return self.new([alg, fptype, fp])
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/test/tc_nsec3.rb
CHANGED
@@ -20,6 +20,8 @@ require 'dnsruby'
|
|
20
20
|
class Nsec3Test < Test::Unit::TestCase
|
21
21
|
INPUT = "2t7b4g4vsa5smi47k61mv5bv1a22bojr.example. 3600 IN NSEC3 1 1 12 aabbccdd ( " +
|
22
22
|
"2vptu5timamqttgl4luu9kg21e0aor3s A RRSIG )"
|
23
|
+
INPUT2 = "2t7b4g4vsa5smi47k61mv5bv1a22bojr.example. 3600 IN NSEC3 1 1 12 aabbccdd " +
|
24
|
+
"2vptu5timamqttgl4luu9kg21e0aor3s"
|
23
25
|
include Dnsruby
|
24
26
|
def test_nsec_from_string
|
25
27
|
nsec = Dnsruby::RR.create(INPUT)
|
@@ -32,6 +34,16 @@ class Nsec3Test < Test::Unit::TestCase
|
|
32
34
|
|
33
35
|
nsec2 = Dnsruby::RR.create(nsec.to_s)
|
34
36
|
assert(nsec2.to_s == nsec.to_s)
|
37
|
+
|
38
|
+
nsec = Dnsruby::RR.create(INPUT2)
|
39
|
+
assert_equal([], nsec.types)
|
40
|
+
assert(nsec.opt_out?)
|
41
|
+
assert_equal(12, nsec.iterations)
|
42
|
+
assert_equal("aabbccdd", nsec.salt)
|
43
|
+
assert_equal(Dnsruby::Nsec3HashAlgorithms.SHA_1, nsec.hash_alg)
|
44
|
+
|
45
|
+
nsec2 = Dnsruby::RR.create(nsec.to_s)
|
46
|
+
assert(nsec2.to_s == nsec.to_s)
|
35
47
|
end
|
36
48
|
|
37
49
|
def test_base32
|
data/test/tc_sshfp.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
#--
|
3
|
+
#Copyright 2007 Nominet UK
|
4
|
+
#
|
5
|
+
#Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
#you may not use this file except in compliance with the License.
|
7
|
+
#You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
#Unless required by applicable law or agreed to in writing, software
|
12
|
+
#distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
#See the License for the specific language governing permissions and
|
15
|
+
#limitations under the License.
|
16
|
+
#++
|
17
|
+
require 'rubygems'
|
18
|
+
require 'test/unit'
|
19
|
+
require 'dnsruby'
|
20
|
+
include Dnsruby
|
21
|
+
class TestSSHFP < Test::Unit::TestCase
|
22
|
+
def test_sshfp
|
23
|
+
txt = "apt-blade6.nominet.org.uk. 85826 IN SSHFP 1 1 6D4CF7C68E3A959990855099E15D6E0D4DEA4FFF"
|
24
|
+
sshfp = RR.create(txt)
|
25
|
+
assert(sshfp.type == Types.SSHFP)
|
26
|
+
assert(sshfp.alg == RR::SSHFP::Algorithms.RSA)
|
27
|
+
assert(sshfp.fptype == RR::SSHFP::FpTypes.SHA1)
|
28
|
+
assert(sshfp.fp.unpack("H*")[0].upcase == "6D4CF7C68E3A959990855099E15D6E0D4DEA4FFF")
|
29
|
+
|
30
|
+
m = Dnsruby::Message.new
|
31
|
+
m.add_additional(sshfp)
|
32
|
+
data = m.encode
|
33
|
+
m2 = Dnsruby::Message.decode(data)
|
34
|
+
sshfp2 = m2.additional()[0]
|
35
|
+
assert(sshfp.fptype == sshfp2.fptype)
|
36
|
+
assert(sshfp.alg == sshfp2.alg)
|
37
|
+
assert(sshfp.fp == sshfp2.fp)
|
38
|
+
assert(sshfp == sshfp2)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.39"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AlexD
|
@@ -9,7 +9,7 @@ autorequire: dnsruby
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-16 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- test/tc_single_resolver.rb
|
62
62
|
- test/tc_soak.rb
|
63
63
|
- test/tc_soak_base.rb
|
64
|
+
- test/tc_sshfp.rb
|
64
65
|
- test/tc_tcp.rb
|
65
66
|
- test/tc_tkey.rb
|
66
67
|
- test/tc_tsig.rb
|
@@ -116,6 +117,7 @@ files:
|
|
116
117
|
- lib/Dnsruby/resource/SOA.rb
|
117
118
|
- lib/Dnsruby/resource/SPF.rb
|
118
119
|
- lib/Dnsruby/resource/SRV.rb
|
120
|
+
- lib/Dnsruby/resource/SSHFP.rb
|
119
121
|
- lib/Dnsruby/resource/TKEY.rb
|
120
122
|
- lib/Dnsruby/resource/TSIG.rb
|
121
123
|
- lib/Dnsruby/resource/TXT.rb
|