Class: Net::DNS::Question
Overview
NAME
Net::DNS::Question - DNS question class
SYNOPSIS
use Net::DNS::Question
DESCRIPTION
A Net::DNS::Question object represents a record in the question section of a DNS packet.
COPYRIGHT
Copyright © 1997-2002 Michael Fuhr.
Portions Copyright © 2002-2004 Chris Reinhardt.
All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Net::DNS, Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Update, Net::DNS::Header, Net::DNS::RR, RFC 1035 Section 4.1.2
Constant Summary
Constants inherited from RR
Instance Attribute Summary collapse
-
#qclass ⇒ Object
Returns the value of attribute qclass.
-
#qname ⇒ Object
Returns the value of attribute qname.
-
#qtype ⇒ Object
Returns the value of attribute qtype.
Attributes inherited from RR
#name, #rdata, #rdlength, #rrclass, #ttl, #type
Instance Method Summary collapse
-
#data(packet, offset) ⇒ Object
Returns the question record in binary format suitable for inclusion in a DNS packet.
-
#initialize(qname, qtypein = "ANY", qclassin = "ANY") ⇒ Question
constructor
Creates a question object from the domain, type, and class passed as arguments.
-
#inspect ⇒ Object
Returns a string representation of the question record.
- #zclass ⇒ Object
- #zname ⇒ Object
- #ztype ⇒ Object
Methods inherited from RR
#_canonicalRdata, #_canonicaldata, _get_subclass, _name2wire, #_name2wire, build_regex, create, #create_rrsort_func, #get_rrsort_func, #init, #init_rrsort_func, new_from_data, new_from_hash, new_from_string, #rdatastr, #rr_rdata, #set_rrsort_func
Constructor Details
#initialize(qname, qtypein = "ANY", qclassin = "ANY") ⇒ Question
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/Net/DNS/Question.rb', line 53 def initialize(qname, qtypein="ANY", qclassin="ANY") qname = "" if (qname==nil); qtype = qtypein.upcase qclass = qclassin.upcase # Check if the caller has the type and class reversed. # We are not that kind for unknown types.... :-) if ((Net::DNS::typesbyname(qtype)==nil || \ Net::DNS::classesbyname(qclass)==nil) \ && Net::DNS::classesbyname(qtype)!=nil \ && Net::DNS::typesbyname(qclass)!=nil) temp = qtype qtype = qclass qclass = temp end # $qname =~ s/^\.+//o; # $qname =~ s/\.+$//o; qname.gsub!("^\.+", ""); qname.gsub!("\.+$", ""); @qname = qname; @qtype = qtype; @qclass = qclass; end |
Instance Attribute Details
#qclass ⇒ Object
Returns the value of attribute qclass.
47 48 49 |
# File 'lib/Net/DNS/Question.rb', line 47 def qclass @qclass end |
#qname ⇒ Object
Returns the value of attribute qname.
47 48 49 |
# File 'lib/Net/DNS/Question.rb', line 47 def qname @qname end |
#qtype ⇒ Object
Returns the value of attribute qtype.
47 48 49 |
# File 'lib/Net/DNS/Question.rb', line 47 def qtype @qtype end |
Instance Method Details
#data(packet, offset) ⇒ Object
Returns the question record in binary format suitable for inclusion in a DNS packet.
Arguments are a Net::DNS::Packet object and the offset within that packet’s data where the Net::DNS::Question record is to be stored. This information is necessary for using compressed domain names.
qdata = question.data(packet, offset)
97 98 99 100 101 102 103 104 |
# File 'lib/Net/DNS/Question.rb', line 97 def data(packet, offset) data, offset = packet.dn_comp(@qname, offset); data+=[Net::DNS::typesbyname(@qtype.upcase)].pack("n") data+=[Net::DNS::classesbyname(@qclass.upcase)].pack("n") return data; end |
#inspect ⇒ Object
Returns a string representation of the question record.
print qr.inspect, "\n"
84 85 86 |
# File 'lib/Net/DNS/Question.rb', line 84 def inspect return "#{@qname}.\t#{@qclass}\t#{@qtype}"; end |
#zclass ⇒ Object
112 113 114 |
# File 'lib/Net/DNS/Question.rb', line 112 def zclass return qclass end |
#zname ⇒ Object
106 107 108 |
# File 'lib/Net/DNS/Question.rb', line 106 def zname return qname end |
#ztype ⇒ Object
109 110 111 |
# File 'lib/Net/DNS/Question.rb', line 109 def ztype return qtype end |