| 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 1124
1124: def initialize(*args)
1125: @qtype = Types::A
1126: @qclass = Classes::IN
1127: if (args.length > 0)
1128: if (args.length > 1)
1129: @qtype = Types.new(args[1])
1130: if (args.length > 2)
1131: @qclass = Classes.new(args[2])
1132: end
1133: end
1134: else
1135: raise ArgumentError.new("Must pass at least a name!")
1136: end
1137: # If the name looks like an IP address then do an appropriate
1138: # PTR query.
1139: @qname=args[0]
1140: case @qname.to_s
1141: when IPv4::Regex
1142: @qname = IPv4.create(@qname).to_name
1143: @qtype = Types.PTR
1144: when IPv6::Regex
1145: @qname = IPv6.create(@qname).to_name
1146: @qtype = Types.PTR
1147: when Name
1148: when IPv6
1149: @qtype = Types.PTR
1150: when IPv4
1151: @qtype = Types.PTR
1152: else
1153: @qname = Name.create(@qname)
1154: end
1155: end
# File lib/Dnsruby/message.rb, line 1161
1161: def qclass=(qclass)
1162: @qclass = Classes.new(qclass)
1163: end
# File lib/Dnsruby/message.rb, line 1165
1165: def qname=(qname)
1166: case qname
1167: when IPv4::Regex
1168: @qname = IPv4.create(qname).to_name
1169: @qtype = Types.PTR
1170: when IPv6::Regex
1171: @qname = IPv6.create(qname).to_name
1172: @qtype = Types.PTR
1173: when Name
1174: when IPv6
1175: @qtype = Types.PTR
1176: when IPv4
1177: @qtype = Types.PTR
1178: else
1179: @qname = Name.create(qname)
1180: end
1181: end