Class: Dnsruby::Section

### Home Classes Methods

### In Files

- lib/dnsruby/message/section.rb

### Parent

Array

### Methods

- ::new
- #==
- #remove_rrset
- #rrset
- #rrsets

### Files

- DNSSEC
- EVENTMACHINE
- EXAMPLES

### Class/Module Index

Quicksearch

- Dnsruby
- Dnsruby::Algorithms
- Dnsruby::BitMapping
- Dnsruby::Bitmap
- Dnsruby::Classes
- Dnsruby::CodeMapper
- Dnsruby::Config
- Dnsruby::DNS
- Dnsruby::DecodeError
- Dnsruby::Dnssec
- Dnsruby::Dnssec::ValidationPolicy
- Dnsruby::EncodeError
- Dnsruby::ExtendedRCode
- Dnsruby::FormErr
- Dnsruby::Header
- Dnsruby::Hosts
- Dnsruby::IPv4
- Dnsruby::IPv6
- Dnsruby::Message
- Dnsruby::Message::SecurityLevel
- Dnsruby::MetaTypes
- Dnsruby::Modes
- Dnsruby::NXDomain
- Dnsruby::NXRRSet
- Dnsruby::Name
- Dnsruby::Name::Label
- Dnsruby::NotAuth
- Dnsruby::NotImp
- Dnsruby::NotZone
- Dnsruby::Nsec3HashAlgorithms
- Dnsruby::OpCode
- Dnsruby::OtherResolvError
- Dnsruby::QTypes
- Dnsruby::Question
- Dnsruby::RCode
- Dnsruby::RR
- Dnsruby::RR::ANY
- Dnsruby::RR::CERT
- Dnsruby::RR::CERT::CertificateTypes
- Dnsruby::RR::CNAME
- Dnsruby::RR::DHCID
- Dnsruby::RR::DLV
- Dnsruby::RR::DNAME
- Dnsruby::RR::DNSKEY
- Dnsruby::RR::DS
- Dnsruby::RR::DS::DigestTypes
- Dnsruby::RR::DomainName
- Dnsruby::RR::GPOS
- Dnsruby::RR::Generic
- Dnsruby::RR::HINFO
- Dnsruby::RR::HIP
- Dnsruby::RR::IN
- Dnsruby::RR::IN::A
- Dnsruby::RR::IN::AAAA
- Dnsruby::RR::IN::AFSDB
- Dnsruby::RR::IN::PX
- Dnsruby::RR::IN::SRV
- Dnsruby::RR::IN::WKS
- Dnsruby::RR::IPSECKEY
- Dnsruby::RR::ISDN
- Dnsruby::RR::KX
- Dnsruby::RR::LOC
- Dnsruby::RR::MB
- Dnsruby::RR::MG
- Dnsruby::RR::MINFO
- Dnsruby::RR::MR
- Dnsruby::RR::MX
- Dnsruby::RR::NAPTR
- Dnsruby::RR::NS
- Dnsruby::RR::NSAP
- Dnsruby::RR::NSEC
- Dnsruby::RR::NSEC3
- Dnsruby::RR::NSEC3PARAM
- Dnsruby::RR::NXT
- Dnsruby::RR::NXT::NxtTypes
- Dnsruby::RR::NXT::TypeBitmap
- Dnsruby::RR::OPT
- Dnsruby::RR::PTR
- Dnsruby::RR::RP
- Dnsruby::RR::RRSIG
- Dnsruby::RR::RT
- Dnsruby::RR::SOA
- Dnsruby::RR::SPF
- Dnsruby::RR::SSHFP
- Dnsruby::RR::SSHFP::Algorithms
- Dnsruby::RR::SSHFP::FpTypes
- Dnsruby::RR::TKEY
- Dnsruby::RR::TSIG
- Dnsruby::RR::TXT
- Dnsruby::RR::X25
- Dnsruby::RRSet
- Dnsruby::Recursor
- Dnsruby::Refused
- Dnsruby::Resolv
- Dnsruby::ResolvError
- Dnsruby::ResolvTimeout
- Dnsruby::Resolver
- Dnsruby::Resolver::EventType
- Dnsruby::Section
- Dnsruby::SelectThread
- Dnsruby::ServFail
- Dnsruby::SingleResolver
- Dnsruby::SocketEofResolvError
- Dnsruby::TheLog
- Dnsruby::TsigError
- Dnsruby::TsigNotSignedResponseError
- Dnsruby::Types
- Dnsruby::Update
- Dnsruby::VerifyError
- Dnsruby::YXDomain
- Dnsruby::YXRRSet
- Dnsruby::ZoneReader
- Dnsruby::ZoneReader::ParseException
- Dnsruby::ZoneSerialError
- Dnsruby::ZoneTransfer
- Dnsruby::ZoneTransfer::Delta
- Base32
- Object

No matching classes.

# Dnsruby::Section

### Public Class Methods

new(msg = nil) click to toggle source

    # File lib/dnsruby/message/section.rb, line 4
    def initialize(msg = nil)
      @msg = msg
      super(0)
    end

### Public Instance Methods

==(other) click to toggle source

    # File lib/dnsruby/message/section.rb, line 67
    def ==(other)
      return false unless self.class == other.class
      return false if other.rrsets(nil, true).length != self.rrsets(nil, true).length

      otherrrsets = other.rrsets(nil)
      self.rrsets(nil).each {|rrset|
        return false unless otherrrsets.include?(rrset)
      }

      true
    end

remove_rrset(name, type) click to toggle source

    # File lib/dnsruby/message/section.rb, line 79
    def remove_rrset(name, type)
      #  Remove all RRs with the name and type from the section.
      #  Need to worry about header counts here - can we get Message to
      #  update the counts itself, rather than the section worrying about it?
      rrs_to_delete = []
      each do |rr|
        next if rr.rr_type == Types::OPT
        if (rr.name.to_s.downcase == name.to_s.downcase) &&
            ((rr.type == type) ||
                ((rr.type == Types::RRSIG) && (rr.type_covered == type)))
          rrs_to_delete.push(rr)
        end
      end
      rrs_to_delete.each { |rr| delete(rr) }
      @msg.update_counts if @msg
    end

rrset(name, type=Types.A, klass=Classes::IN) click to toggle source

Return the rrset of the specified type in this section

    # File lib/dnsruby/message/section.rb, line 10
    def rrset(name, type=Types.A, klass=Classes::IN)
      rrs = select{|rr|
        type_ok = (rr.type==type)
        if rr.type == Types::RRSIG
          type_ok = (rr.type_covered == type)
        end
        unless /\.\z/ =~ name.to_s
          name = name.to_s + '.'
        end
        type_ok && (rr.klass == klass) && (rr.name.to_s(true).downcase == name.to_s().downcase)
      }
      rrset = RRSet.new()
      rrs.each do |rr|
        rrset.add(rr)
      end
      rrset
    end

rrsets(type = nil, include_opt = false) click to toggle source

Return an array of all the rrsets in the section

    # File lib/dnsruby/message/section.rb, line 29
    def rrsets(type = nil, include_opt = false)
      if type && !(Types === type)
        type = Types.new(type)
      end
      ret = []
      each do |rr|
        next if (!include_opt && (rr.type == Types::OPT))
        #           if (type)
        #             next if ((rr.type == Types.RRSIG) && (type != Types.RRSIG) && (rr.type_covered != type))
        #             next if (rr.type != type)
        #           end
        if (type)
          #  if this is an rrsig type, then :
          #     only include it if the type_covered is the type requested,
          #     OR if the type requested is an RRSIG
          if rr.type == Types::RRSIG
            if (rr.type_covered == type) || (type == Types::RRSIG)
            else
              next
            end
            #               next if ((rr.type_covered != type) || (type != Types.RRSIG))
          elsif rr.type != type
            next
          end
        end

        found_rrset = false
        ret.each do |rrset|
          found_rrset = rrset.add(rr)
          break if found_rrset
        end
        unless found_rrset
          ret.push(RRSet.new(rr))
        end
      end
      ret
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.