mirror of
https://git.nerdvpn.de/NerdVPN.de/invidious
synced 2026-02-14 22:51:42 +01:00
Fix companion error TLS is nil - patch by @Fijxu
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
From aecf481a4e569f20e08294734162412a3ad9c83a Mon Sep 17 00:00:00 2001
|
||||
From: Fijxu <fijxu@nadeko.net>
|
||||
Date: Fri, 6 Jun 2025 12:27:08 -0400
|
||||
Subject: [PATCH] feat: Support multiple companion backends
|
||||
From 5ca139720f75771beb7e4f5aabd38251880f0c0d Mon Sep 17 00:00:00 2001
|
||||
From: Sommerwiesel <mzurborg@all-it.org>
|
||||
Date: Sat, 21 Jun 2025 12:38:20 +0200
|
||||
Subject: [PATCH] 002
|
||||
|
||||
Stripped down version of what inv.nadeko.net Invidious instance does to
|
||||
balance and allow the user to choose a backend.
|
||||
---
|
||||
locales/en-US.json | 3 +-
|
||||
src/invidious.cr | 14 +++-
|
||||
@@ -15,13 +13,13 @@ balance and allow the user to choose a backend.
|
||||
src/invidious/routes/before_all.cr | 53 +++++++++++-
|
||||
src/invidious/routes/watch.cr | 2 +-
|
||||
src/invidious/routing.cr | 1 +
|
||||
src/invidious/user/cookies.cr | 26 ++++++
|
||||
src/invidious/user/cookies.cr | 21 +++++
|
||||
src/invidious/videos.cr | 10 +--
|
||||
src/invidious/videos/parser.cr | 8 +-
|
||||
src/invidious/views/template.ecr | 31 +++++++
|
||||
src/invidious/yt_backend/connection_pool.cr | 9 ++-
|
||||
src/invidious/yt_backend/connection_pool.cr | 13 +--
|
||||
src/invidious/yt_backend/youtube_api.cr | 12 ++-
|
||||
15 files changed, 274 insertions(+), 23 deletions(-)
|
||||
15 files changed, 271 insertions(+), 25 deletions(-)
|
||||
create mode 100644 src/invidious/helpers/backend_info.cr
|
||||
create mode 100644 src/invidious/jobs/backend_checker.cr
|
||||
create mode 100644 src/invidious/routes/backend_switcher.cr
|
||||
@@ -39,7 +37,7 @@ index 3f42a509..0b752d93 100644
|
||||
+ "backend_unavailable": "The backend you selected is unavailable. You have been redirected to another one"
|
||||
}
|
||||
diff --git a/src/invidious.cr b/src/invidious.cr
|
||||
index 69f8a26c..c3071be1 100644
|
||||
index 0a416b95..3c7de8f7 100644
|
||||
--- a/src/invidious.cr
|
||||
+++ b/src/invidious.cr
|
||||
@@ -96,9 +96,11 @@ YT_POOL = YoutubeConnectionPool.new(YT_URL, capacity: CONFIG.pool_size)
|
||||
@@ -340,7 +338,7 @@ index 46b71f1f..769a7f71 100644
|
||||
self.register_channel_routes
|
||||
self.register_watch_routes
|
||||
diff --git a/src/invidious/user/cookies.cr b/src/invidious/user/cookies.cr
|
||||
index 654efc15..affcfdca 100644
|
||||
index 654efc15..50caffef 100644
|
||||
--- a/src/invidious/user/cookies.cr
|
||||
+++ b/src/invidious/user/cookies.cr
|
||||
@@ -35,5 +35,26 @@ struct Invidious::User
|
||||
@@ -449,7 +447,7 @@ index feb58440..c4f946e8 100644
|
||||
playability_status = response["playabilityStatus"]["status"]
|
||||
LOGGER.debug("try_fetch_streaming_data: [#{id}] Got playabilityStatus == #{playability_status}.")
|
||||
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
|
||||
index 9904b4fc..ad6c1c0e 100644
|
||||
index 769ab1e2..4c648174 100644
|
||||
--- a/src/invidious/views/template.ecr
|
||||
+++ b/src/invidious/views/template.ecr
|
||||
@@ -104,6 +104,37 @@
|
||||
@@ -491,36 +489,43 @@ index 9904b4fc..ad6c1c0e 100644
|
||||
<div class="h-box">
|
||||
<h3><%= CONFIG.banner %></h3>
|
||||
diff --git a/src/invidious/yt_backend/connection_pool.cr b/src/invidious/yt_backend/connection_pool.cr
|
||||
index 0daed46c..4c7227c4 100644
|
||||
index 0daed46c..ab954edb 100644
|
||||
--- a/src/invidious/yt_backend/connection_pool.cr
|
||||
+++ b/src/invidious/yt_backend/connection_pool.cr
|
||||
@@ -49,7 +49,7 @@ end
|
||||
struct CompanionConnectionPool
|
||||
@@ -46,10 +46,11 @@ struct YoutubeConnectionPool
|
||||
end
|
||||
end
|
||||
|
||||
-struct CompanionConnectionPool
|
||||
+class CompanionConnectionPool
|
||||
property pool : DB::Pool(HTTP::Client)
|
||||
+ property companion : URI
|
||||
|
||||
- def initialize(capacity = 5, timeout = 5.0)
|
||||
+ def initialize(companion, capacity = 5, timeout = 10.0)
|
||||
options = DB::Pool::Options.new(
|
||||
initial_pool_size: 0,
|
||||
max_pool_size: capacity,
|
||||
@@ -58,7 +58,6 @@ struct CompanionConnectionPool
|
||||
@@ -57,9 +58,10 @@ struct CompanionConnectionPool
|
||||
checkout_timeout: timeout
|
||||
)
|
||||
|
||||
+ @companion = companion.private_url
|
||||
+
|
||||
@pool = DB::Pool(HTTP::Client).new(options) do
|
||||
- companion = CONFIG.invidious_companion.sample
|
||||
next make_client(companion.private_url, use_http_proxy: false)
|
||||
- next make_client(companion.private_url, use_http_proxy: false)
|
||||
+ next make_client(@companion, use_http_proxy: false)
|
||||
end
|
||||
end
|
||||
@@ -71,8 +70,10 @@ struct CompanionConnectionPool
|
||||
|
||||
@@ -71,8 +73,7 @@ struct CompanionConnectionPool
|
||||
rescue ex
|
||||
conn.close
|
||||
|
||||
- companion = CONFIG.invidious_companion.sample
|
||||
- conn = make_client(companion.private_url, use_http_proxy: false)
|
||||
+ scheme = "http"
|
||||
+ same_companion = "#{scheme}://#{conn.host}:#{conn.port}"
|
||||
+
|
||||
+ conn = make_client(URI.parse(same_companion), use_http_proxy: false)
|
||||
+ conn = make_client(@companion, use_http_proxy: false)
|
||||
|
||||
response = yield conn
|
||||
ensure
|
||||
@@ -569,4 +574,5 @@ index b40092a1..1b37c4c9 100644
|
||||
if (response.status_code != 200)
|
||||
raise Exception.new(
|
||||
--
|
||||
2.49.0
|
||||
2.39.5
|
||||
|
||||
|
||||
Reference in New Issue
Block a user