Skip to content

Commit

Permalink
Change Request connection logic to try both IPv6 and IPv4 when availa…
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored Nov 8, 2022
1 parent 36b0ff5 commit c989faa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/lib/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def open(host, *args)
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

Expand Down

0 comments on commit c989faa

Please sign in to comment.