dnsruby 1.55 → 1.56.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +96 -0
- data/Rakefile +30 -29
- data/demo/axfr.rb +93 -93
- data/demo/check_soa.rb +99 -99
- data/demo/check_zone.rb +59 -59
- data/demo/digdlv.rb +43 -43
- data/demo/digroot.rb +34 -34
- data/demo/example_recurse.rb +14 -14
- data/demo/mresolv.rb +30 -30
- data/demo/mx.rb +31 -31
- data/demo/rubydig.rb +37 -37
- data/demo/to_resolve.txt +3088 -3088
- data/demo/trace_dns.rb +46 -46
- data/lib/dnsruby.rb +161 -526
- data/lib/dnsruby/DNS.rb +305 -0
- data/lib/{Dnsruby/Cache.rb → dnsruby/cache.rb} +152 -152
- data/lib/{Dnsruby → dnsruby}/code_mapper.rb +48 -52
- data/lib/dnsruby/code_mappers.rb +295 -0
- data/lib/{Dnsruby/Config.rb → dnsruby/config.rb} +454 -454
- data/lib/{Dnsruby → dnsruby}/dnssec.rb +91 -91
- data/lib/{Dnsruby/Hosts.rb → dnsruby/hosts.rb} +125 -125
- data/lib/{Dnsruby → dnsruby}/ipv4.rb +26 -26
- data/lib/{Dnsruby → dnsruby}/ipv6.rb +42 -42
- data/lib/{Dnsruby → dnsruby}/key_cache.rb +29 -29
- data/lib/dnsruby/message/decoder.rb +164 -0
- data/lib/dnsruby/message/encoder.rb +75 -0
- data/lib/dnsruby/message/header.rb +249 -0
- data/lib/dnsruby/message/message.rb +629 -0
- data/lib/dnsruby/message/question.rb +86 -0
- data/lib/dnsruby/message/section.rb +96 -0
- data/lib/{Dnsruby → dnsruby}/name.rb +141 -141
- data/lib/dnsruby/packet_sender.rb +661 -0
- data/lib/{Dnsruby/Recursor.rb → dnsruby/recursor.rb} +235 -233
- data/lib/dnsruby/resolv.rb +113 -0
- data/lib/dnsruby/resolver.rb +1192 -0
- data/lib/dnsruby/resource/A.rb +56 -0
- data/lib/dnsruby/resource/AAAA.rb +54 -0
- data/lib/{Dnsruby → dnsruby}/resource/AFSDB.rb +68 -68
- data/lib/{Dnsruby → dnsruby}/resource/CERT.rb +105 -105
- data/lib/{Dnsruby → dnsruby}/resource/DHCID.rb +54 -54
- data/lib/dnsruby/resource/DLV.rb +27 -0
- data/lib/{Dnsruby → dnsruby}/resource/DNSKEY.rb +372 -372
- data/lib/{Dnsruby → dnsruby}/resource/DS.rb +255 -255
- data/lib/{Dnsruby → dnsruby}/resource/HINFO.rb +71 -71
- data/lib/{Dnsruby → dnsruby}/resource/HIP.rb +29 -29
- data/lib/{Dnsruby → dnsruby}/resource/IN.rb +30 -30
- data/lib/{Dnsruby → dnsruby}/resource/IPSECKEY.rb +31 -31
- data/lib/{Dnsruby → dnsruby}/resource/ISDN.rb +62 -62
- data/lib/{Dnsruby → dnsruby}/resource/KX.rb +65 -65
- data/lib/{Dnsruby → dnsruby}/resource/LOC.rb +263 -263
- data/lib/{Dnsruby → dnsruby}/resource/MINFO.rb +69 -69
- data/lib/{Dnsruby → dnsruby}/resource/MX.rb +65 -65
- data/lib/{Dnsruby → dnsruby}/resource/NAPTR.rb +98 -98
- data/lib/{Dnsruby → dnsruby}/resource/NSAP.rb +171 -171
- data/lib/dnsruby/resource/NSEC.rb +275 -0
- data/lib/dnsruby/resource/NSEC3.rb +332 -0
- data/lib/dnsruby/resource/NSEC3PARAM.rb +135 -0
- data/lib/dnsruby/resource/OPT.rb +272 -0
- data/lib/{Dnsruby → dnsruby}/resource/PX.rb +70 -70
- data/lib/{Dnsruby → dnsruby}/resource/RP.rb +75 -75
- data/lib/dnsruby/resource/RR.rb +421 -0
- data/lib/dnsruby/resource/RRSIG.rb +275 -0
- data/lib/dnsruby/resource/RRSet.rb +190 -0
- data/lib/{Dnsruby → dnsruby}/resource/RT.rb +67 -67
- data/lib/{Dnsruby → dnsruby}/resource/SOA.rb +94 -94
- data/lib/dnsruby/resource/SPF.rb +29 -0
- data/lib/dnsruby/resource/SRV.rb +112 -0
- data/lib/{Dnsruby → dnsruby}/resource/SSHFP.rb +14 -14
- data/lib/dnsruby/resource/TKEY.rb +163 -0
- data/lib/dnsruby/resource/TSIG.rb +593 -0
- data/lib/{Dnsruby → dnsruby}/resource/TXT.rb +191 -191
- data/lib/dnsruby/resource/X25.rb +55 -0
- data/lib/{Dnsruby → dnsruby}/resource/domain_name.rb +25 -25
- data/lib/{Dnsruby → dnsruby}/resource/generic.rb +80 -80
- data/lib/dnsruby/resource/resource.rb +25 -0
- data/lib/{Dnsruby → dnsruby}/select_thread.rb +148 -148
- data/lib/{Dnsruby/SingleResolver.rb → dnsruby/single_resolver.rb} +60 -60
- data/lib/{Dnsruby → dnsruby}/single_verifier.rb +344 -344
- data/lib/dnsruby/the_log.rb +44 -0
- data/lib/dnsruby/update.rb +278 -0
- data/lib/dnsruby/validator_thread.rb +124 -0
- data/lib/dnsruby/version.rb +3 -0
- data/lib/{Dnsruby → dnsruby}/zone_reader.rb +93 -93
- data/lib/{Dnsruby → dnsruby}/zone_transfer.rb +377 -377
- data/test/spec_helper.rb +16 -0
- data/test/tc_axfr.rb +31 -34
- data/test/tc_cache.rb +32 -32
- data/test/tc_dlv.rb +28 -28
- data/test/tc_dns.rb +73 -76
- data/test/tc_dnskey.rb +31 -32
- data/test/tc_dnsruby.rb +50 -44
- data/test/tc_ds.rb +36 -36
- data/test/tc_escapedchars.rb +252 -255
- data/test/tc_hash.rb +17 -21
- data/test/tc_header.rb +48 -57
- data/test/tc_hip.rb +19 -22
- data/test/tc_ipseckey.rb +18 -21
- data/test/tc_keith.rb +300 -0
- data/test/tc_message.rb +87 -0
- data/test/tc_misc.rb +83 -87
- data/test/tc_name.rb +81 -84
- data/test/tc_naptr.rb +18 -21
- data/test/tc_nsec.rb +55 -55
- data/test/tc_nsec3.rb +23 -24
- data/test/tc_nsec3param.rb +20 -21
- data/test/tc_packet.rb +90 -93
- data/test/tc_packet_unique_push.rb +48 -51
- data/test/tc_question.rb +30 -33
- data/test/tc_queue.rb +16 -17
- data/test/tc_recur.rb +16 -17
- data/test/tc_res_config.rb +38 -41
- data/test/tc_res_env.rb +29 -32
- data/test/tc_res_file.rb +26 -29
- data/test/tc_res_opt.rb +62 -65
- data/test/tc_resolver.rb +287 -242
- data/test/tc_rr-opt.rb +70 -63
- data/test/tc_rr-txt.rb +68 -71
- data/test/tc_rr-unknown.rb +45 -48
- data/test/tc_rr.rb +76 -70
- data/test/tc_rrset.rb +21 -22
- data/test/tc_rrsig.rb +19 -20
- data/test/tc_single_resolver.rb +294 -297
- data/test/tc_soak.rb +199 -202
- data/test/tc_soak_base.rb +29 -34
- data/test/tc_sshfp.rb +20 -23
- data/test/tc_tcp.rb +32 -35
- data/test/tc_tkey.rb +41 -44
- data/test/tc_tsig.rb +81 -84
- data/test/tc_update.rb +108 -111
- data/test/tc_validator.rb +29 -29
- data/test/tc_verifier.rb +81 -82
- data/test/ts_dnsruby.rb +16 -15
- data/test/ts_offline.rb +62 -63
- data/test/ts_online.rb +115 -115
- metadata +155 -90
- data/README +0 -59
- data/lib/Dnsruby/DNS.rb +0 -305
- data/lib/Dnsruby/PacketSender.rb +0 -656
- data/lib/Dnsruby/Resolver.rb +0 -1189
- data/lib/Dnsruby/TheLog.rb +0 -44
- data/lib/Dnsruby/message.rb +0 -1230
- data/lib/Dnsruby/resource/A.rb +0 -56
- data/lib/Dnsruby/resource/AAAA.rb +0 -54
- data/lib/Dnsruby/resource/DLV.rb +0 -27
- data/lib/Dnsruby/resource/NSEC.rb +0 -298
- data/lib/Dnsruby/resource/NSEC3.rb +0 -340
- data/lib/Dnsruby/resource/NSEC3PARAM.rb +0 -135
- data/lib/Dnsruby/resource/OPT.rb +0 -213
- data/lib/Dnsruby/resource/RRSIG.rb +0 -275
- data/lib/Dnsruby/resource/SPF.rb +0 -29
- data/lib/Dnsruby/resource/SRV.rb +0 -112
- data/lib/Dnsruby/resource/TKEY.rb +0 -163
- data/lib/Dnsruby/resource/TSIG.rb +0 -593
- data/lib/Dnsruby/resource/X25.rb +0 -55
- data/lib/Dnsruby/resource/resource.rb +0 -678
- data/lib/Dnsruby/update.rb +0 -278
- data/lib/Dnsruby/validator_thread.rb +0 -124
@@ -0,0 +1,190 @@
|
|
1
|
+
module Dnsruby
|
2
|
+
|
3
|
+
# RFC2181, section 5
|
4
|
+
# "It is however possible for most record types to exist
|
5
|
+
# with the same label, class and type, but with different data. Such a
|
6
|
+
# group of records is hereby defined to be a Resource Record Set
|
7
|
+
# (RRSet)."
|
8
|
+
# This class also stores the RRSIG records which cover the RRSet
|
9
|
+
class RRSet
|
10
|
+
include Comparable
|
11
|
+
# The number of RRSIGs stored in this RRSet
|
12
|
+
attr_reader :num_sigs
|
13
|
+
def initialize(rrs = [])
|
14
|
+
if (!rrs.instance_of?Array)
|
15
|
+
rrs = [rrs]
|
16
|
+
end
|
17
|
+
@rrs = []
|
18
|
+
@num_sigs = 0
|
19
|
+
rrs.each {|rr| add(rr)}
|
20
|
+
end
|
21
|
+
def self.new_from_string(string)
|
22
|
+
rr_strings = string.split("\n")
|
23
|
+
rrs = rr_strings.map { |s| Dnsruby::RR.new_from_string(s) }
|
24
|
+
|
25
|
+
Dnsruby::RRSet.new(rrs)
|
26
|
+
end # The RRSIGs stored with this RRSet
|
27
|
+
def sigs
|
28
|
+
return @rrs[@rrs.length-@num_sigs, @num_sigs]
|
29
|
+
end
|
30
|
+
# The RRs (not RRSIGs) stored in this RRSet
|
31
|
+
def rrs
|
32
|
+
return @rrs[0, @rrs.length-@num_sigs]
|
33
|
+
end
|
34
|
+
def privateAdd(r) #:nodoc:
|
35
|
+
if @rrs.include?r
|
36
|
+
return true
|
37
|
+
end
|
38
|
+
new_pos = @rrs.length - @num_sigs
|
39
|
+
if ((@num_sigs == @rrs.length) && @num_sigs > 0) # if we added RRSIG first
|
40
|
+
if (((r.type != @rrs.last.type_covered) && (r.type != Types.RRSIG))||
|
41
|
+
((r.type == Types.RRSIG) && (r.type_covered != @rrs.last.type_covered)))
|
42
|
+
return false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
if (r.type == Types::RRSIG)
|
46
|
+
new_pos = @rrs.length
|
47
|
+
@num_sigs += 1
|
48
|
+
end
|
49
|
+
@rrs.insert(new_pos, r)
|
50
|
+
return true
|
51
|
+
end
|
52
|
+
|
53
|
+
# Add the RR to this RRSet
|
54
|
+
# Takes a copy of the RR by default. To suppress this, pass false
|
55
|
+
# as the second parameter.
|
56
|
+
def add(rin, do_clone = true)
|
57
|
+
if (rin.instance_of?RRSet)
|
58
|
+
ret = false
|
59
|
+
[rin.rrs, rin.sigs].each {|rr| ret = add(rr)}
|
60
|
+
return ret
|
61
|
+
end
|
62
|
+
# r = RR.create(r.to_s) # clone the record
|
63
|
+
r = nil
|
64
|
+
if do_clone
|
65
|
+
r = rin.clone
|
66
|
+
else
|
67
|
+
r = rin
|
68
|
+
end
|
69
|
+
if (@rrs.size() == 0) # && !(r.type == Types.RRSIG))
|
70
|
+
return privateAdd(r)
|
71
|
+
end
|
72
|
+
# Check the type, klass and ttl are correct
|
73
|
+
first = @rrs[0]
|
74
|
+
if (!r.sameRRset(first))
|
75
|
+
return false
|
76
|
+
# raise ArgumentError.new("record does not match rrset")
|
77
|
+
end
|
78
|
+
|
79
|
+
if (!(r.type == Types::RRSIG) && (!(first.type == Types::RRSIG)))
|
80
|
+
if (r.ttl != first.ttl) # RFC2181, section 5.2
|
81
|
+
if (r.ttl > first.ttl)
|
82
|
+
r.ttl=(first.ttl)
|
83
|
+
else
|
84
|
+
@rrs.each do |rr|
|
85
|
+
rr.ttl = r.ttl
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
return privateAdd(r)
|
92
|
+
# return true
|
93
|
+
end
|
94
|
+
|
95
|
+
def <=>(other)
|
96
|
+
# return 1 if ((!other) || !(other.name) || !(other.type))
|
97
|
+
# return -1 if (!@name)
|
98
|
+
if (name.canonical == other.name.canonical)
|
99
|
+
return type.code <=> other.type.code
|
100
|
+
else
|
101
|
+
return name <=> other.name
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def sort_canonical
|
106
|
+
# Make a list, for all the RRs, where each RR contributes
|
107
|
+
# the canonical RDATA encoding
|
108
|
+
canonical_rrs = {}
|
109
|
+
self.rrs.each do |rr|
|
110
|
+
data = MessageEncoder.new {|msg|
|
111
|
+
rr.encode_rdata(msg, true)
|
112
|
+
}.to_s
|
113
|
+
canonical_rrs[data] = rr
|
114
|
+
end
|
115
|
+
|
116
|
+
return_rrs = RRSet.new
|
117
|
+
canonical_rrs.keys.sort.each { |rdata|
|
118
|
+
return_rrs.add(canonical_rrs[rdata], false)
|
119
|
+
}
|
120
|
+
return return_rrs
|
121
|
+
end
|
122
|
+
|
123
|
+
def ==(other)
|
124
|
+
return false unless other.instance_of?RRSet
|
125
|
+
return false if (other.sigs.length != self.sigs.length)
|
126
|
+
return false if (other.rrs.length != self.rrs.length)
|
127
|
+
return false if (other.ttl != self.ttl)
|
128
|
+
otherrrs = other.rrs
|
129
|
+
self.rrs.each {|rr|
|
130
|
+
return false if (!otherrrs.include?rr)
|
131
|
+
}
|
132
|
+
othersigs= other.sigs
|
133
|
+
self.sigs.each {|sig|
|
134
|
+
return false if (!othersigs.include?sig)
|
135
|
+
}
|
136
|
+
return true
|
137
|
+
end
|
138
|
+
# Delete the RR from this RRSet
|
139
|
+
def delete(rr)
|
140
|
+
@rrs.delete(rr)
|
141
|
+
end
|
142
|
+
def each
|
143
|
+
@rrs.each do |rr|
|
144
|
+
yield rr
|
145
|
+
end
|
146
|
+
end
|
147
|
+
def [](index)
|
148
|
+
return @rrs[index]
|
149
|
+
end
|
150
|
+
# Return the type of this RRSet
|
151
|
+
def type
|
152
|
+
if (@rrs[0])
|
153
|
+
return @rrs[0].type
|
154
|
+
end
|
155
|
+
return nil
|
156
|
+
end
|
157
|
+
# Return the klass of this RRSet
|
158
|
+
def klass
|
159
|
+
return @rrs[0].klass
|
160
|
+
end
|
161
|
+
# Return the ttl of this RRSet
|
162
|
+
def ttl
|
163
|
+
return @rrs[0].ttl
|
164
|
+
end
|
165
|
+
def ttl=(ttl)
|
166
|
+
[rrs, sigs].each {|rrs|
|
167
|
+
rrs.each {|rr|
|
168
|
+
rr.ttl = ttl
|
169
|
+
}
|
170
|
+
}
|
171
|
+
end
|
172
|
+
def name
|
173
|
+
if (@rrs[0])
|
174
|
+
return @rrs[0].name
|
175
|
+
else
|
176
|
+
return nil
|
177
|
+
end
|
178
|
+
end
|
179
|
+
def to_s
|
180
|
+
ret = ""
|
181
|
+
each {|rec|
|
182
|
+
ret += rec.to_s + "\n"
|
183
|
+
}
|
184
|
+
return ret
|
185
|
+
end
|
186
|
+
def length
|
187
|
+
return @rrs.length
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -1,67 +1,67 @@
|
|
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 DNS Route Through (RT) resource records.
|
19
|
-
#RFC 1183 Section 3.3
|
20
|
-
class RT < RR
|
21
|
-
ClassValue = nil #:nodoc: all
|
22
|
-
TypeValue = Types::RT #:nodoc: all
|
23
|
-
|
24
|
-
#The preference for this route.
|
25
|
-
attr_accessor :preference
|
26
|
-
|
27
|
-
#The domain name of the intermediate host.
|
28
|
-
attr_accessor :intermediate
|
29
|
-
|
30
|
-
def from_hash(hash) #:nodoc: all
|
31
|
-
@preference = hash[:preference]
|
32
|
-
@intermediate = Name.create(hash[:intermediate])
|
33
|
-
end
|
34
|
-
|
35
|
-
def from_data(data) #:nodoc: all
|
36
|
-
@preference, @intermediate = data
|
37
|
-
end
|
38
|
-
|
39
|
-
def from_string(input) #:nodoc: all
|
40
|
-
if (input.length > 0)
|
41
|
-
names = input.split(" ")
|
42
|
-
@preference = names[0].to_i
|
43
|
-
@intermediate = Name.create(names[1])
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def rdata_to_string #:nodoc: all
|
48
|
-
if (@preference!=nil)
|
49
|
-
return "#{@preference} #{@intermediate.to_s(true)}"
|
50
|
-
else
|
51
|
-
return ""
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def encode_rdata(msg, canonical = false) #:nodoc: all
|
56
|
-
msg.put_pack('n', @preference)
|
57
|
-
msg.put_name(@intermediate, canonical)
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.decode_rdata(msg) #:nodoc: all
|
61
|
-
preference, = msg.get_unpack('n')
|
62
|
-
intermediate = msg.get_name
|
63
|
-
return self.new([preference, intermediate])
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
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 DNS Route Through (RT) resource records.
|
19
|
+
# RFC 1183 Section 3.3
|
20
|
+
class RT < RR
|
21
|
+
ClassValue = nil #:nodoc: all
|
22
|
+
TypeValue = Types::RT #:nodoc: all
|
23
|
+
|
24
|
+
# The preference for this route.
|
25
|
+
attr_accessor :preference
|
26
|
+
|
27
|
+
# The domain name of the intermediate host.
|
28
|
+
attr_accessor :intermediate
|
29
|
+
|
30
|
+
def from_hash(hash) #:nodoc: all
|
31
|
+
@preference = hash[:preference]
|
32
|
+
@intermediate = Name.create(hash[:intermediate])
|
33
|
+
end
|
34
|
+
|
35
|
+
def from_data(data) #:nodoc: all
|
36
|
+
@preference, @intermediate = data
|
37
|
+
end
|
38
|
+
|
39
|
+
def from_string(input) #:nodoc: all
|
40
|
+
if (input.length > 0)
|
41
|
+
names = input.split(" ")
|
42
|
+
@preference = names[0].to_i
|
43
|
+
@intermediate = Name.create(names[1])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def rdata_to_string #:nodoc: all
|
48
|
+
if (@preference!=nil)
|
49
|
+
return "#{@preference} #{@intermediate.to_s(true)}"
|
50
|
+
else
|
51
|
+
return ""
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def encode_rdata(msg, canonical = false) #:nodoc: all
|
56
|
+
msg.put_pack('n', @preference)
|
57
|
+
msg.put_name(@intermediate, canonical)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.decode_rdata(msg) #:nodoc: all
|
61
|
+
preference, = msg.get_unpack('n')
|
62
|
+
intermediate = msg.get_name
|
63
|
+
return self.new([preference, intermediate])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -1,95 +1,95 @@
|
|
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 SOA < RR
|
19
|
-
ClassValue = nil #:nodoc: all
|
20
|
-
TypeValue = Types::SOA #:nodoc: all
|
21
|
-
|
22
|
-
#The domain name of the original or primary nameserver for
|
23
|
-
#this zone.
|
24
|
-
attr_accessor :mname
|
25
|
-
#A domain name that specifies the mailbox for the person
|
26
|
-
#responsible for this zone.
|
27
|
-
attr_accessor :rname
|
28
|
-
#The zone's serial number.
|
29
|
-
attr_accessor :serial
|
30
|
-
#The zone's refresh interval.
|
31
|
-
#How often, in seconds, a secondary nameserver is to check for
|
32
|
-
#updates from the primary nameserver.
|
33
|
-
attr_accessor :refresh
|
34
|
-
#The zone's retry interval.
|
35
|
-
#How often, in seconds, a secondary nameserver is to retry, after a
|
36
|
-
#failure to check for a refresh
|
37
|
-
attr_accessor :retry
|
38
|
-
#The zone's expire interval.
|
39
|
-
#How often, in seconds, a secondary nameserver is to use the data
|
40
|
-
#before refreshing from the primary nameserver
|
41
|
-
attr_accessor :expire
|
42
|
-
#The minimum (default) TTL for records in this zone.
|
43
|
-
attr_accessor :minimum
|
44
|
-
|
45
|
-
def from_data(data) #:nodoc: all
|
46
|
-
@mname, @rname, @serial, @refresh, @retry, @expire, @minimum = data
|
47
|
-
end
|
48
|
-
|
49
|
-
def from_hash(hash)
|
50
|
-
@mname = Name.create(hash[:mname])
|
51
|
-
@rname = Name.create(hash[:rname])
|
52
|
-
@serial = hash[:serial].to_i
|
53
|
-
@refresh = hash[:refresh].to_i
|
54
|
-
@retry = hash[:retry].to_i
|
55
|
-
@expire = hash[:expire].to_i
|
56
|
-
@minimum = hash[:minimum].to_i
|
57
|
-
end
|
58
|
-
|
59
|
-
def from_string(input)
|
60
|
-
if (input.length > 0)
|
61
|
-
names = input.split(" ")
|
62
|
-
@mname = Name.create(names[0])
|
63
|
-
@rname = Name.create(names[1])
|
64
|
-
@serial = names[2].to_i
|
65
|
-
@refresh = names[3].to_i
|
66
|
-
@retry = names[4].to_i
|
67
|
-
@expire = names[5].to_i
|
68
|
-
@minimum = names[6].to_i
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def rdata_to_string #:nodoc: all
|
73
|
-
if (@mname!=nil)
|
74
|
-
return "#{@mname.to_s(true)} #{@rname.to_s(true)} #{@serial} #{@refresh} #{@retry} #{@expire} #{@minimum}"
|
75
|
-
else
|
76
|
-
return ""
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def encode_rdata(msg, canonical=false) #:nodoc: all
|
81
|
-
msg.put_name(@mname, canonical)
|
82
|
-
msg.put_name(@rname, canonical)
|
83
|
-
msg.put_pack('NNNNN', @serial, @refresh, @retry, @expire, @minimum)
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.decode_rdata(msg) #:nodoc: all
|
87
|
-
mname = msg.get_name
|
88
|
-
rname = msg.get_name
|
89
|
-
serial, refresh, retry_, expire, minimum = msg.get_unpack('NNNNN')
|
90
|
-
return self.new(
|
91
|
-
[mname, rname, serial, refresh, retry_, expire, minimum])
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
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 SOA < RR
|
19
|
+
ClassValue = nil #:nodoc: all
|
20
|
+
TypeValue = Types::SOA #:nodoc: all
|
21
|
+
|
22
|
+
# The domain name of the original or primary nameserver for
|
23
|
+
# this zone.
|
24
|
+
attr_accessor :mname
|
25
|
+
# A domain name that specifies the mailbox for the person
|
26
|
+
# responsible for this zone.
|
27
|
+
attr_accessor :rname
|
28
|
+
# The zone's serial number.
|
29
|
+
attr_accessor :serial
|
30
|
+
# The zone's refresh interval.
|
31
|
+
# How often, in seconds, a secondary nameserver is to check for
|
32
|
+
# updates from the primary nameserver.
|
33
|
+
attr_accessor :refresh
|
34
|
+
# The zone's retry interval.
|
35
|
+
# How often, in seconds, a secondary nameserver is to retry, after a
|
36
|
+
# failure to check for a refresh
|
37
|
+
attr_accessor :retry
|
38
|
+
# The zone's expire interval.
|
39
|
+
# How often, in seconds, a secondary nameserver is to use the data
|
40
|
+
# before refreshing from the primary nameserver
|
41
|
+
attr_accessor :expire
|
42
|
+
# The minimum (default) TTL for records in this zone.
|
43
|
+
attr_accessor :minimum
|
44
|
+
|
45
|
+
def from_data(data) #:nodoc: all
|
46
|
+
@mname, @rname, @serial, @refresh, @retry, @expire, @minimum = data
|
47
|
+
end
|
48
|
+
|
49
|
+
def from_hash(hash)
|
50
|
+
@mname = Name.create(hash[:mname])
|
51
|
+
@rname = Name.create(hash[:rname])
|
52
|
+
@serial = hash[:serial].to_i
|
53
|
+
@refresh = hash[:refresh].to_i
|
54
|
+
@retry = hash[:retry].to_i
|
55
|
+
@expire = hash[:expire].to_i
|
56
|
+
@minimum = hash[:minimum].to_i
|
57
|
+
end
|
58
|
+
|
59
|
+
def from_string(input)
|
60
|
+
if (input.length > 0)
|
61
|
+
names = input.split(" ")
|
62
|
+
@mname = Name.create(names[0])
|
63
|
+
@rname = Name.create(names[1])
|
64
|
+
@serial = names[2].to_i
|
65
|
+
@refresh = names[3].to_i
|
66
|
+
@retry = names[4].to_i
|
67
|
+
@expire = names[5].to_i
|
68
|
+
@minimum = names[6].to_i
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def rdata_to_string #:nodoc: all
|
73
|
+
if (@mname!=nil)
|
74
|
+
return "#{@mname.to_s(true)} #{@rname.to_s(true)} #{@serial} #{@refresh} #{@retry} #{@expire} #{@minimum}"
|
75
|
+
else
|
76
|
+
return ""
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def encode_rdata(msg, canonical=false) #:nodoc: all
|
81
|
+
msg.put_name(@mname, canonical)
|
82
|
+
msg.put_name(@rname, canonical)
|
83
|
+
msg.put_pack('NNNNN', @serial, @refresh, @retry, @expire, @minimum)
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.decode_rdata(msg) #:nodoc: all
|
87
|
+
mname = msg.get_name
|
88
|
+
rname = msg.get_name
|
89
|
+
serial, refresh, retry_, expire, minimum = msg.get_unpack('NNNNN')
|
90
|
+
return self.new(
|
91
|
+
[mname, rname, serial, refresh, retry_, expire, minimum])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
95
|
end
|