lib/httpx/resolver/native.rb in httpx-0.24.1 vs lib/httpx/resolver/native.rb in httpx-0.24.2

- old
+ new

@@ -27,16 +27,19 @@ def_delegator :@connections, :empty? attr_reader :state - def initialize(_, options) + def initialize(family, options) super @ns_index = 0 @resolver_options = DEFAULTS.merge(@options.resolver_options) @socket_type = @resolver_options.fetch(:socket_type, :udp) - @nameserver = Array(@resolver_options[:nameserver]) if @resolver_options[:nameserver] + @nameserver = if (nameserver = @resolver_options[:nameserver]) + nameserver = nameserver[family] if nameserver.is_a?(Hash) + Array(nameserver) + end @ndots = @resolver_options[:ndots] @search = Array(@resolver_options[:search]).map { |srch| srch.scan(/[^.]+/) } @_timeouts = Array(@resolver_options[:timeouts]) @timeouts = Hash.new { |timeouts, host| timeouts[host] = @_timeouts.dup } @connections = [] @@ -316,11 +319,11 @@ else resolve(connection, address["alias"]) return end else - @timeouts.delete(name) + reset_hostname(name, connection: connection) @timeouts.delete(connection.origin.host) @connections.delete(connection) Resolver.cached_lookup_set(connection.origin.host, @family, addresses) if @resolver_options[:cache] emit_addresses(connection, @family, addresses.map { |addr| addr["data"] }) end @@ -427,12 +430,11 @@ emit_resolve_error(connection, host, error) end end end - def reset_hostname(hostname, reset_candidates: true) + def reset_hostname(hostname, connection: @queries.delete(hostname), reset_candidates: true) @timeouts.delete(hostname) - connection = @queries.delete(hostname) @timeouts.delete(hostname) return unless connection && reset_candidates # eliminate other candidates