From 2cbf245aae7a304ca3498c21561ab0be5f2278b4 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 24 Aug 2024 19:37:04 -0700 Subject: [PATCH] Ensure IP family is always used when force_resolve --- src/invidious/yt_backend/connection_pool.cr | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/invidious/yt_backend/connection_pool.cr b/src/invidious/yt_backend/connection_pool.cr index 7b29c7d8..4dc029d7 100644 --- a/src/invidious/yt_backend/connection_pool.cr +++ b/src/invidious/yt_backend/connection_pool.cr @@ -23,7 +23,6 @@ struct YoutubeConnectionPool rescue ex conn.close conn = make_client(url) - conn.family = Socket::Family::INET if conn.family == Socket::Family::UNSPEC response = yield conn ensure pool.release(conn) @@ -34,9 +33,7 @@ struct YoutubeConnectionPool private def build_pool DB::Pool(HTTP::Client).new(initial_pool_size: 0, max_pool_size: capacity, max_idle_pool_size: capacity, checkout_timeout: timeout) do - conn = make_client(url, force_resolve: true) - conn.family = Socket::Family::INET if conn.family == Socket::Family::UNSPEC - conn + next make_client(url, force_resolve: true) end end end @@ -47,6 +44,7 @@ def make_client(url : URI, region = nil, force_resolve : Bool = false, force_you # Force the usage of a specific configured IP Family if force_resolve client.family = CONFIG.force_resolve + client.family = Socket::Family::INET if client.family == Socket::Family::UNSPEC end client.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com" || force_youtube_headers