|
|
@ -268,12 +268,22 @@ class Request
|
|
|
|
addresses = addresses.filter { |addr| addr.is_a?(Resolv::IPv6) }.take(2) + addresses.filter { |addr| !addr.is_a?(Resolv::IPv6) }.take(2)
|
|
|
|
addresses = addresses.filter { |addr| addr.is_a?(Resolv::IPv6) }.take(2) + addresses.filter { |addr| !addr.is_a?(Resolv::IPv6) }.take(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue ResolvError
|
|
|
|
rescue ResolvError
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if addresses.empty?
|
|
|
|
# try /etc/hosts file
|
|
|
|
# try /etc/hosts file
|
|
|
|
# https://github.com/mastodon/mastodon/issues/9436
|
|
|
|
# https://github.com/mastodon/mastodon/issues/9436
|
|
|
|
Resolv::Hosts.open do |dns|
|
|
|
|
Resolv::Hosts.new.each_address(host) do |address|
|
|
|
|
addresses = dns.getaddresses(host)
|
|
|
|
case address
|
|
|
|
addresses = addresses.filter { |addr| addr.is_a?(Resolv::IPv6) }.take(2) + addresses.filter { |addr| !addr.is_a?(Resolv::IPv6) }.take(2)
|
|
|
|
when Resolv::IPv4::Regex
|
|
|
|
|
|
|
|
addresses << Resolv::IPv4.create(address)
|
|
|
|
|
|
|
|
when Resolv::IPv6::Regex
|
|
|
|
|
|
|
|
addresses << Resolv::IPv6.create(address)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
raise ResolvError.new("cannot interpret as address: #{address}")
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
addresses = addresses.filter { |addr| addr.is_a?(Resolv::IPv6) }.take(2) + addresses.filter { |addr| !addr.is_a?(Resolv::IPv6) }.take(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|