Compare commits
No commits in common. "0d1e55d566b4d3c8b5daad086ba760c5f88fea52" and "472eec8ae1a138504f250b8ef7d8a3dcaa4f9535" have entirely different histories.
0d1e55d566
...
472eec8ae1
1 changed files with 3 additions and 22 deletions
|
@ -261,30 +261,11 @@ class Request
|
|||
begin
|
||||
addresses = [IPAddr.new(host)]
|
||||
rescue IPAddr::InvalidAddressError
|
||||
begin
|
||||
Resolv::DNS.open do |dns|
|
||||
dns.timeouts = 5
|
||||
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
|
||||
end
|
||||
|
||||
if addresses.empty?
|
||||
# try /etc/hosts file
|
||||
# https://github.com/mastodon/mastodon/issues/9436
|
||||
Resolv::Hosts.new.each_address(host) do |address|
|
||||
case address
|
||||
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
|
||||
addresses = addresses.filter { |addr| addr.is_a?(Resolv::IPv6) }.take(2) + addresses.filter { |addr| !addr.is_a?(Resolv::IPv6) }.take(2)
|
||||
end
|
||||
end
|
||||
|
||||
socks = []
|
||||
|
|
Loading…
Reference in a new issue