lib/httpx/resolver.rb in httpx-1.1.0 vs lib/httpx/resolver.rb in httpx-1.1.1
- old
+ new
@@ -3,11 +3,11 @@
require "resolv"
require "ipaddr"
module HTTPX
module Resolver
- RESOLVE_TIMEOUT = 5
+ RESOLVE_TIMEOUT = [2, 3].freeze
require "httpx/resolver/resolver"
require "httpx/resolver/system"
require "httpx/resolver/native"
require "httpx/resolver/https"
@@ -85,19 +85,21 @@
# do not use directly!
def lookup(hostname, ttl)
return unless @lookups.key?(hostname)
- @lookups[hostname] = @lookups[hostname].select do |address|
+ entries = @lookups[hostname] = @lookups[hostname].select do |address|
address["TTL"] > ttl
end
- ips = @lookups[hostname].flat_map do |address|
+
+ ips = entries.flat_map do |address|
if address.key?("alias")
lookup(address["alias"], ttl)
else
IPAddr.new(address["data"])
end
- end
+ end.compact
+
ips unless ips.empty?
end
def generate_id
@identifier_mutex.synchronize { @identifier = (@identifier + 1) & 0xFFFF }