From c989faaa6201f19e99dc7088a496e603153f0f90 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 8 Nov 2022 16:36:26 +0100 Subject: [PATCH] Change Request connection logic to try both IPv6 and IPv4 when available (#20108) Fixes #19751 --- app/lib/request.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/lib/request.rb b/app/lib/request.rb index 1ea86862db..dd198f3991 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -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