summaryrefslogtreecommitdiff
path: root/lib/resolv.rb
diff options
context:
space:
mode:
authorJeremy Evans <[email protected]>2021-09-17 17:17:20 -0700
committergit <[email protected]>2023-11-25 02:24:43 +0000
commit7276d4b4e87bfdc9b609f481a734e39c499de253 ()
tree1669a12e27d1af77f3318d8a3c4987c8efa160fb /lib/resolv.rb
parentfb7add495454322ea00efa7549feb957cb1ca538 (diff)
[ruby/resolv] Support a :raise_timeout_errors option to raise timeouts as Resolv::ResolvError
This allows to differentiate a timeout from an NXDOMAIN response. Fixes [Bug #18151] https://.com/ruby/resolv/commit/c0e5abab76
-rw-r--r--lib/resolv.rb6
1 files changed, 6 insertions, 0 deletions
@@ -312,6 +312,8 @@ class Resolv
# String:: Path to a file using /etc/resolv.conf's format.
# Hash:: Must contain :nameserver, :search and :ndots keys.
# :nameserver_port can be used to specify port number of nameserver address.
#
# The value of :nameserver should be an address string or
# an array of address strings.
@@ -1032,6 +1034,7 @@ class Resolv
end
@search = config_hash[:search] if config_hash.include? :search
@ndots = config_hash[:ndots] if config_hash.include? :ndots
if @nameserver_port.empty?
@nameserver_port << ['0.0.0.0', Port]
@@ -1118,6 +1121,7 @@ class Resolv
def resolv(name)
candidates = generate_candidates(name)
timeouts = @timeouts || generate_timeouts
begin
candidates.each {|candidate|
begin
@@ -1129,11 +1133,13 @@ class Resolv
end
}
}
raise ResolvError.new("DNS resolv timeout: #{name}")
rescue NXDomain
end
}
rescue ResolvError
end
end