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