Project

General

Profile

Feature #3835 » resolv-1.8.7-tcp-fallback.diff

TCP fallback for Ruby 1.8.7's Resolv::DNS - julian.mehnle (Julian Mehnle), 09/16/2010 05:48 AM

View differences:

resolv-1.8.7.rb 2010-09-15 20:39:41.555445345 +0000
def each_resource(name, typeclass, &proc)
lazy_initialize
requester = make_requester
requester = make_udp_requester
senders = {}
begin
@config.resolv(name) {|candidate, tout, nameserver|
......
reply, reply_name = requester.request(sender, tout)
case reply.rcode
when RCode::NoError
extract_resources(reply, reply_name, typeclass, &proc)
if reply.tc and not Requester::TCP === requester
# Retry via TCP:
requester = make_tcp_requester
senders = {}
# This will use TCP for all remaining candidates (assuming the
# current candidate does not already respond successfully via
# TCP). This makes sense because we already know the full
# response will not fit in an untruncated UDP packet.
redo
else
extract_resources(reply, reply_name, typeclass, &proc)
end
return
when RCode::NXDomain
raise Config::NXDomain.new(reply_name.to_s)
......
end
end
def make_requester # :nodoc:
def make_udp_requester # :nodoc:
nameserver_port = @config.nameserver_port
if nameserver_port.length == 1
Requester::ConnectedUDP.new(*nameserver_port[0])
......
end
end
def make_tcp_requester # :nodoc:
nameserver_port = @config.nameserver_port
return Requester::TCP.new(*nameserver_port[0])
end
def extract_resources(msg, name, typeclass) # :nodoc:
if typeclass < Resource::ANY
n0 = Name.create(name)
(2-2/4)