each_resource(name, typeclass, &proc)
public
Iterates over all typeclass DNS resources for name. See
#getresource for argument
details.
Show source
def each_resource(name, typeclass, &proc)
lazy_initialize
requester = make_udp_requester
senders = {}
begin
@config.resolv(name) {|candidate, tout, nameserver, port|
msg = Message.new
msg.rd = 1
msg.add_question(candidate, typeclass)
unless sender = senders[[candidate, nameserver, port]]
sender = senders[[candidate, nameserver, port]] =
requester.sender(msg, candidate, nameserver, port)
end
reply, reply_name = requester.request(sender, tout)
case reply.rcode
when RCode::NoError
if reply.tc == 1 and not Requester::TCP === requester
requester.close
requester = make_tcp_requester(nameserver, port)
senders = {}
redo
else
extract_resources(reply, reply_name, typeclass, &proc)
end
return
when RCode::NXDomain
raise Config::NXDomain.new(reply_name.to_s)
else
raise Config::OtherResolvError.new(reply_name.to_s)
end
}
ensure
requester.close
end
end