Change Request connection logic to try both IPv6 and IPv4 when available (#20108)

Fixes #19751
lolsob-rspec
Claire 2022-11-08 16:36:26 +01:00 committed by GitHub
parent 01e5aedf4b
commit 18a11da3b5
1 changed files with 2 additions and 1 deletions

View File

@ -199,7 +199,8 @@ class Request
rescue IPAddr::InvalidAddressError
Resolv::DNS.open do |dns|
dns.timeouts = 5
addresses = dns.getaddresses(host).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
end