th: etc etc host host s s
This commit is contained in:
parent
c379487041
commit
7719de5665
1 changed files with 13 additions and 4 deletions
|
@ -261,10 +261,19 @@ class Request
|
||||||
begin
|
begin
|
||||||
addresses = [IPAddr.new(host)]
|
addresses = [IPAddr.new(host)]
|
||||||
rescue IPAddr::InvalidAddressError
|
rescue IPAddr::InvalidAddressError
|
||||||
Resolv::DNS.open do |dns|
|
begin
|
||||||
dns.timeouts = 5
|
Resolv::DNS.open do |dns|
|
||||||
addresses = dns.getaddresses(host)
|
dns.timeouts = 5
|
||||||
addresses = addresses.filter { |addr| addr.is_a?(Resolv::IPv6) }.take(2) + addresses.filter { |addr| !addr.is_a?(Resolv::IPv6) }.take(2)
|
addresses = dns.getaddresses(host)
|
||||||
|
addresses = addresses.filter { |addr| addr.is_a?(Resolv::IPv6) }.take(2) + addresses.filter { |addr| !addr.is_a?(Resolv::IPv6) }.take(2)
|
||||||
|
end
|
||||||
|
rescue ResolvError
|
||||||
|
# try /etc/hosts file
|
||||||
|
# https://github.com/mastodon/mastodon/issues/9436
|
||||||
|
Resolv::Hosts.open do |dns|
|
||||||
|
addresses = dns.getaddresses(host)
|
||||||
|
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
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue