Class | Dnsruby::Message::Section |
In: |
lib/Dnsruby/message.rb
|
Parent: | Array |
# File lib/Dnsruby/message.rb, line 91 91: def initialize(msg = nil) 92: @msg = msg 93: super(0) 94: end
# File lib/Dnsruby/message.rb, line 149 149: def ==(other) 150: return false unless (other.instance_of?Message::Section) 151: return false if (other.rrsets(nil, true).length != self.rrsets(nil, true).length) 152: otherrrsets = other.rrsets(nil, true) 153: self.rrsets(nil, true).each {|rrset| 154: return false unless otherrrsets.include?rrset 155: } 156: return true 157: end
# File lib/Dnsruby/message.rb, line 159 159: def remove_rrset(name, type) 160: # Remove all RRs with the name and type from the section. 161: # Need to worry about header counts here - can we get Message to 162: # update the counts itself, rather than the section worrying about it? 163: rrs_to_delete = [] 164: each do |rr| 165: next if rr.rr_type == Types::OPT 166: if ((rr.name.to_s.downcase == name.to_s.downcase) && 167: ((rr.type == type) || 168: ((rr.type == Types::RRSIG) && (rr.type_covered == type)) )) 169: rrs_to_delete.push(rr) 170: end 171: end 172: rrs_to_delete.each {|rr| 173: delete(rr) 174: } 175: @msg.update_counts if @msg 176: end
Return the rrset of the specified type in this section
# File lib/Dnsruby/message.rb, line 96 96: def rrset(name, type=Types.A, klass=Classes::IN) 97: rrs = select{|rr| 98: type_ok = (rr.type==type) 99: if (rr.type == Types::RRSIG) 100: type_ok = (rr.type_covered == type) 101: end 102: type_ok && (rr.klass == klass) && (rr.name.to_s.downcase == name.to_s.downcase) 103: } 104: rrset = RRSet.new() 105: rrs.each do |rr| 106: rrset.add(rr) 107: end 108: return rrset 109: end
Return an array of all the rrsets in the section
# File lib/Dnsruby/message.rb, line 112 112: def rrsets(type = nil, include_opt = false) 113: if (type && !(Types === type)) 114: type = Types.new(type) 115: end 116: ret = [] 117: each do |rr| 118: next if (!include_opt && (rr.type == Types::OPT)) 119: # if (type) 120: # next if ((rr.type == Types.RRSIG) && (type != Types.RRSIG) && (rr.type_covered != type)) 121: # next if (rr.type != type) 122: # end 123: if (type) 124: # if this is an rrsig type, then : 125: # only include it if the type_covered is the type requested, 126: # OR if the type requested is an RRSIG 127: if (rr.type == Types::RRSIG) 128: if ((rr.type_covered == type) || (type == Types::RRSIG)) 129: else 130: next 131: end 132: # next if ((rr.type_covered != type) || (type != Types.RRSIG)) 133: elsif (rr.type != type) 134: next 135: end 136: end 137: 138: found_rrset = false 139: ret.each do |rrset| 140: found_rrset = rrset.add(rr) 141: break if found_rrset 142: end 143: if (!found_rrset) 144: ret.push(RRSet.new(rr)) 145: end 146: end 147: return ret 148: end