Class: Dnsruby::Question

### Home Classes Methods

### In Files

- lib/Dnsruby/message.rb

### Parent

Object

### Methods

- ::new
- #qclass=
- #qname=
- #qtype=
- #to_s

### Files

- DNSSEC
- EVENTMACHINE
- EXAMPLES
- README

### Class/Module Index

Quicksearch

- Dnsruby
- Dnsruby::Algorithms
- 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::Section
- 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::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::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::SelectThread
- Dnsruby::ServFail
- Dnsruby::SingleResolver
- 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

No matching classes.

# Dnsruby::Question

A Dnsruby::Question object represents a record in the question section of a DNS packet.

RFC 1035 Section 4.1.2

### Attributes

qclass[R]

The Question class

qname[R]

The Question name

qtype[R]

The Question type

type[R]

The Question type

zclass[R]

The Question class

zname[R]

The Question name

ztype[R]

The Question type

### Public Class Methods

new(*args) click to toggle source

Creates a question object from the domain, type, and class passed as arguments.

If a String is passed in, a Name, IPv4 or IPv6 object is created.

If an IPv4 or IPv6 object is used then the type is set to PTR.

    # File lib/Dnsruby/message.rb, line 1129
    def initialize(*args)
      @qtype = Types::A
      @qclass = Classes::IN
      type_given = false
      if (args.length > 0)
        if (args.length > 1)
          @qtype = Types.new(args[1])
          type_given = true
          if (args.length > 2)
            @qclass = Classes.new(args[2])
          end
        end
      else
        raise ArgumentError.new("Must pass at least a name!")
      end
      # If the name looks like an IP address then do an appropriate
      # PTR query, unless the user specified the qtype
      @qname=args[0]
      if (!type_given)
        case @qname.to_s
        when IPv4::Regex
          @qname = IPv4.create(@qname).to_name
          @qtype = Types.PTR
        when IPv6::Regex
          @qname = IPv6.create(@qname).to_name
          @qtype = Types.PTR
        when Name
        when IPv6
          @qtype = Types.PTR
        when IPv4
          @qtype = Types.PTR
        else
          @qname = Name.create(@qname)
        end
      else
        case @qtype
        when Types.PTR
          case @qname.to_s
          when IPv4::Regex
            @qname = IPv4.create(@qname).to_name
          when IPv6::Regex
            @qname = IPv6.create(@qname).to_name
          when IPv6
          when IPv4
          else
            @qname = Name.create(@qname)
          end
        else
          @qname = Name.create(@qname)
        end
      end
    end

### Public Instance Methods

qclass=(qclass) click to toggle source

    # File lib/Dnsruby/message.rb, line 1186
    def qclass=(qclass)
      @qclass = Classes.new(qclass)
    end

qname=(qname) click to toggle source

    # File lib/Dnsruby/message.rb, line 1190
    def qname=(qname)
      case qname
      when IPv4::Regex
        @qname = IPv4.create(qname).to_name
        @qtype = Types.PTR
      when IPv6::Regex
        @qname = IPv6.create(qname).to_name
        @qtype = Types.PTR
      when Name
      when IPv6
        @qtype = Types.PTR
      when IPv4
        @qtype = Types.PTR
      else
        @qname = Name.create(qname)
      end
    end

qtype=(qtype) click to toggle source

    # File lib/Dnsruby/message.rb, line 1182
    def qtype=(qtype)
      @qtype = Types.new(qtype)
    end

to_s() click to toggle source

Returns a string representation of the question record.

    # File lib/Dnsruby/message.rb, line 1209
    def to_s
      return "#{@qname}.\t#{@qclass.string}\t#{@qtype.string}";
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.