Class Dnsruby::RRSet
In: lib/Dnsruby/resource/resource.rb
Parent: Object
Message Update ResolvError EncodeError OtherResolvError ServFail FormErr DecodeError NXRRSet YXDomain NotImp NXDomain VerifyError NotAuth YXRRSet NotZone Refused TsigError CodeMapper Types MetaTypes QTypes Nsec3HashAlgorithms Algorithms OpCode Classes ExtendedRCode Modes RCode Comparable Name RRSet TsigNotSignedResponseError Resolver SingleResolver StandardError TimeoutError ResolvTimeout DNS Dnssec Hosts RR\n[lib/Dnsruby/resource/A.rb\nlib/Dnsruby/resource/AAAA.rb\nlib/Dnsruby/resource/AFSDB.rb\nlib/Dnsruby/resource/CERT.rb\nlib/Dnsruby/resource/DHCID.rb\nlib/Dnsruby/resource/DLV.rb\nlib/Dnsruby/resource/DNSKEY.rb\nlib/Dnsruby/resource/DS.rb\nlib/Dnsruby/resource/HINFO.rb\nlib/Dnsruby/resource/HIP.rb\nlib/Dnsruby/resource/IN.rb\nlib/Dnsruby/resource/IPSECKEY.rb\nlib/Dnsruby/resource/ISDN.rb\nlib/Dnsruby/resource/KX.rb\nlib/Dnsruby/resource/LOC.rb\nlib/Dnsruby/resource/MINFO.rb\nlib/Dnsruby/resource/MX.rb\nlib/Dnsruby/resource/NAPTR.rb\nlib/Dnsruby/resource/NSAP.rb\nlib/Dnsruby/resource/NSEC.rb\nlib/Dnsruby/resource/NSEC3.rb\nlib/Dnsruby/resource/NSEC3PARAM.rb\nlib/Dnsruby/resource/OPT.rb\nlib/Dnsruby/resource/PX.rb\nlib/Dnsruby/resource/RP.rb\nlib/Dnsruby/resource/RRSIG.rb\nlib/Dnsruby/resource/RT.rb\nlib/Dnsruby/resource/SOA.rb\nlib/Dnsruby/resource/SPF.rb\nlib/Dnsruby/resource/SRV.rb\nlib/Dnsruby/resource/SSHFP.rb\nlib/Dnsruby/resource/TKEY.rb\nlib/Dnsruby/resource/TSIG.rb\nlib/Dnsruby/resource/TXT.rb\nlib/Dnsruby/resource/X25.rb\nlib/Dnsruby/resource/domain_name.rb\nlib/Dnsruby/resource/generic.rb\nlib/Dnsruby/resource/resource.rb] Recursor IPv6 IPv4 ZoneTransfer MessageDecoder MessageEncoder Question Header TheLog ValidatorThread PacketSender ResolverRuby Config KeyCache Cache SingleVerifier SelectThread Resolv ZoneReader lib/Dnsruby/DNS.rb lib/Dnsruby/dnssec.rb lib/Dnsruby/Hosts.rb lib/Dnsruby/resource/generic.rb lib/Dnsruby/Recursor.rb lib/Dnsruby/update.rb lib/Dnsruby/ipv6.rb lib/Dnsruby/ipv4.rb lib/Dnsruby/code_mapper.rb lib/Dnsruby/zone_transfer.rb lib/Dnsruby/message.rb lib/Dnsruby/TheLog.rb lib/Dnsruby/resource/resource.rb lib/Dnsruby/validator_thread.rb lib/Dnsruby/PacketSender.rb lib/Dnsruby/Resolver.rb lib/Dnsruby/Config.rb lib/Dnsruby/key_cache.rb lib/Dnsruby/Cache.rb lib/Dnsruby/single_verifier.rb lib/Dnsruby/SingleResolver.rb lib/Dnsruby/select_thread.rb lib/Dnsruby/name.rb lib/dnsruby.rb lib/Dnsruby/resource/TKEY.rb lib/Dnsruby/zone_reader.rb Dnsruby dot/m_61_0.png

RFC2181, section 5 "It is however possible for most record types to exist with the same label, class and type, but with different data. Such a group of records is hereby defined to be a Resource Record Set (RRSet)." This class also stores the RRSIG records which cover the RRSet

Methods

<=>   ==   []   add   delete   each   klass   length   name   new   rrs   sigs   sort_canonical   to_s   ttl   ttl=   type  

Included Modules

Comparable

Attributes

num_sigs  [R]  The number of RRSIGs stored in this RRSet

Public Class methods

[Source]

    # File lib/Dnsruby/resource/resource.rb, line 29
29:     def initialize(rrs = [])
30:       if (!rrs.instance_of?Array)
31:         rrs = [rrs]
32:       end
33:       @rrs = []
34:       @num_sigs = 0
35:       rrs.each {|rr| add(rr)}
36:     end

Public Instance methods

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 105
105:     def <=>(other)
106:       #      return 1 if ((!other) || !(other.name) || !(other.type))
107:       #      return -1 if (!@name)
108:       if (@name.canonical == other.name.canonical)
109:         return @type.code <=> other.type.code
110:       else
111:         return @name <=> other.name
112:       end
113:     end

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 133
133:     def ==(other)
134:       return false unless other.instance_of?RRSet
135:       return false if (other.sigs.length != self.sigs.length)
136:       return false if (other.rrs.length != self.rrs.length)
137:       return false if (other.ttl != self.ttl)
138:       otherrrs = other.rrs
139:       self.rrs.each {|rr|
140:         return false if (!otherrrs.include?rr)
141:       }
142:       othersigs= other.sigs
143:       self.sigs.each {|sig|
144:         return false if (!othersigs.include?sig)
145:       }
146:       return true
147:     end

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 157
157:     def [](index)
158:       return @rrs[index]
159:     end

Add the RR to this RRSet Takes a copy of the RR by default. To suppress this, pass false as the second parameter.

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 66
 66:     def add(rin, do_clone = true)
 67:       if (rin.instance_of?RRSet)
 68:         ret = false
 69:         [rin.rrs, rin.sigs].each {|rr| ret = add(rr)}
 70:         return ret
 71:       end
 72:       #      r = RR.create(r.to_s) # clone the record
 73:       r = nil
 74:       if do_clone
 75:         r = rin.clone
 76:       else
 77:         r = rin
 78:       end
 79:       if (@rrs.size() == 0) #  && !(r.type == Types.RRSIG))
 80:         return privateAdd(r)
 81:       end
 82:       # Check the type, klass and ttl are correct
 83:       first = @rrs[0]
 84:       if (!r.sameRRset(first))
 85:         return false
 86:         #        raise ArgumentError.new("record does not match rrset")
 87:       end
 88:       
 89:       if (!(r.type == Types::RRSIG) && (!(first.type == Types::RRSIG)))
 90:         if (r.ttl != first.ttl) # RFC2181, section 5.2
 91:           if (r.ttl > first.ttl)
 92:             r.ttl=(first.ttl)
 93:           else
 94:             @rrs.each do |rr|
 95:               rr.ttl = r.ttl
 96:             end
 97:           end
 98:         end
 99:       end
100:       
101:       return privateAdd(r)
102:       #      return true
103:     end

Delete the RR from this RRSet

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 149
149:     def delete(rr)
150:       @rrs.delete(rr)
151:     end

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 152
152:     def each
153:       @rrs.each do |rr|
154:         yield rr
155:       end
156:     end

Return the klass of this RRSet

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 168
168:     def klass
169:       return @rrs[0].klass
170:     end

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 196
196:     def length
197:       return @rrs.length
198:     end

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 182
182:     def name
183:       if (@rrs[0])
184:         return @rrs[0].name
185:       else
186:         return nil
187:       end
188:     end

The RRs (not RRSIGs) stored in this RRSet

[Source]

    # File lib/Dnsruby/resource/resource.rb, line 42
42:     def rrs
43:       return @rrs[0, @rrs.length-@num_sigs]
44:     end

The RRSIGs stored with this RRSet

[Source]

    # File lib/Dnsruby/resource/resource.rb, line 38
38:     def sigs
39:       return @rrs[@rrs.length-@num_sigs, @num_sigs]
40:     end

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 115
115:     def sort_canonical
116:       #Make a list, for all the RRs, where each RR contributes
117:       #the canonical RDATA encoding
118:       canonical_rrs = {}
119:       self.rrs.each do |rr|
120:         data = MessageEncoder.new {|msg|
121:           rr.encode_rdata(msg, true)
122:         }.to_s
123:         canonical_rrs[data] = rr
124:       end
125: 
126:       return_rrs = RRSet.new
127:       canonical_rrs.keys.sort.each { |rdata|
128:         return_rrs.add(canonical_rrs[rdata], false)
129:       }
130:       return return_rrs
131:     end

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 189
189:     def to_s
190:       ret = ""
191:       each {|rec|
192:         ret += rec.to_s + "\n"
193:       }
194:       return ret
195:     end

Return the ttl of this RRSet

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 172
172:     def ttl
173:       return @rrs[0].ttl
174:     end

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 175
175:     def ttl=(ttl)
176:       [rrs, sigs].each {|rrs|
177:         rrs.each {|rr|
178:           rr.ttl = ttl
179:         }
180:       }
181:     end

Return the type of this RRSet

[Source]

     # File lib/Dnsruby/resource/resource.rb, line 161
161:     def type
162:       if (@rrs[0])
163:         return @rrs[0].type
164:       end
165:       return nil
166:     end

[Validate]