Object
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
# 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
# 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
# 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.
# 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
# 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
# File lib/Dnsruby/resource/resource.rb, line 168 168: def klass 169: return @rrs[0].klass 170: end
# File lib/Dnsruby/resource/resource.rb, line 196 196: def length 197: return @rrs.length 198: end
# 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
# 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
# File lib/Dnsruby/resource/resource.rb, line 38 38: def sigs 39: return @rrs[@rrs.length-@num_sigs, @num_sigs] 40: end
# 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
# 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
# File lib/Dnsruby/resource/resource.rb, line 172 172: def ttl 173: return @rrs[0].ttl 174: end
# 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
# 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
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.