Class | Dnsruby::Question |
In: |
lib/Dnsruby/message.rb
|
Parent: | Object |
A Dnsruby::Question object represents a record in the question section of a DNS packet.
RFC 1035 Section 4.1.2
qname | -> | zname |
For Updates, the qname field is redefined to zname (RFC2136, section 2.3) | ||
qtype | -> | ztype |
For Updates, the qtype field is redefined to ztype (RFC2136, section 2.3) | ||
qclass | -> | zclass |
For Updates, the qclass field is redefined to zclass (RFC2136, section 2.3) | ||
qtype | -> | type |
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 1112 1112: def initialize(*args) 1113: @qtype = Types::A 1114: @qclass = Classes::IN 1115: if (args.length > 0) 1116: if (args.length > 1) 1117: @qtype = Types.new(args[1]) 1118: if (args.length > 2) 1119: @qclass = Classes.new(args[2]) 1120: end 1121: end 1122: else 1123: raise ArgumentError.new("Must pass at least a name!") 1124: end 1125: # If the name looks like an IP address then do an appropriate 1126: # PTR query. 1127: @qname=args[0] 1128: case @qname.to_s 1129: when IPv4::Regex 1130: @qname = IPv4.create(@qname).to_name 1131: @qtype = Types.PTR 1132: when IPv6::Regex 1133: @qname = IPv6.create(@qname).to_name 1134: @qtype = Types.PTR 1135: when Name 1136: when IPv6 1137: @qtype = Types.PTR 1138: when IPv4 1139: @qtype = Types.PTR 1140: else 1141: @qname = Name.create(@qname) 1142: end 1143: end
# File lib/Dnsruby/message.rb, line 1149 1149: def qclass=(qclass) 1150: @qclass = Classes.new(qclass) 1151: end
# File lib/Dnsruby/message.rb, line 1153 1153: def qname=(qname) 1154: case qname 1155: when IPv4::Regex 1156: @qname = IPv4.create(qname).to_name 1157: @qtype = Types.PTR 1158: when IPv6::Regex 1159: @qname = IPv6.create(qname).to_name 1160: @qtype = Types.PTR 1161: when Name 1162: when IPv6 1163: @qtype = Types.PTR 1164: when IPv4 1165: @qtype = Types.PTR 1166: else 1167: @qname = Name.create(qname) 1168: end 1169: end