0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/lib/freedom_patches
David Taylor 6dfcbb6282
FEATURE: Support 'Happy Eyeballs' in FinalDestination::HTTP (#41680)
Ruby 3.4 shipped support for happy eyeballs in `Socket.tcp` and
`TCPSocket`. However, our `FinalDestination::HTTP` wrapper was
performing a DNS lookup and passing IP addresses one at a time when
opening the socket. That meant that we didn't benefit from the new Ruby
feature in most Discourse features.

This commit factors the strategy. Now, `FinalDestination::HTTP` encodes
the DNS result and passes it to the underlying implementation as a fake
hostname string. A patch to `Addrinfo` detects this fake hostname and
returns the given IPs instead of performing its own lookup.

For this Addrinfo patch to work, we also had to patch `TCPSocket` so
that it uses the ruby-based `Socket.tcp` rather than its native C
socket-opening code.

The result is that we now get the benefit of the native Ruby 'Happy
Eyeballs' support for concurrent ipv4 and ipv6 connections.

All this patching of low-level ruby classes is not ideal, but there is
no native way to control name resolution in `Net::HTTP` or its
dependencies.
2026-07-15 11:31:23 +01:00
..
active_record_attribute_methods.rb
active_record_disable_serialization.rb
ams_include_without_root.rb
copy_file.rb
cose_rsapkcs1.rb
fast_image.rb
final_destination_connect.rb FEATURE: Support 'Happy Eyeballs' in FinalDestination::HTTP (#41680) 2026-07-15 11:31:23 +01:00
inflector_backport.rb
ip_addr.rb
message_pack_extensions.rb DEV: Serialize cookies using MessagePack (#35082) 2025-10-03 11:40:49 +02:00
net_http.rb
net_http_header.rb DEV: Enable some minor rubocop rules (#40094) 2026-05-19 15:29:38 +02:00
pitchfork_sock_stream.rb DEV: Suppress Pitchfork's "Unexpected message in sig_queue" (#39985) 2026-05-13 18:37:09 +02:00
propshaft_patches.rb DEV: Replace JS build system with Rolldown (#35963) 2026-05-29 11:11:55 +01:00
rails_multisite.rb DEV: Enable Style/RedundantBegin rubocop rule (#40096) 2026-05-19 18:44:54 +02:00
request_server_session.rb DEV: Enable Style/RedundantParentheses rubocop rule (#40095) 2026-05-19 15:48:09 +02:00
rspec_mocks_from_described_class.rb DEV: Monkey patch a from_described_class helper in RSpec::Mocks (#34021) 2025-08-05 12:03:42 +10:00
safe_buffer.rb
safe_migrations.rb
schema_migration_details.rb
translate_accelerator.rb DEV: Enable Style/RedundantBegin rubocop rule (#40096) 2026-05-19 18:44:54 +02:00
web_push_request.rb