External Proxies: Adapt it to use a NamedTuple

This commit is contained in:
Fijxu 2024-10-31 21:38:40 -03:00
parent 67998d1f36
commit fc910b43ba
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
3 changed files with 10 additions and 7 deletions

View file

@ -390,7 +390,7 @@ def gen_videoplayback_proxy_list
if !CONFIG.external_videoplayback_proxy.empty?
external_videoplayback_proxy = ""
CONFIG.external_videoplayback_proxy.each do |proxy|
external_videoplayback_proxy += " #{proxy}"
external_videoplayback_proxy += " #{proxy[:url]}"
end
else
external_videoplayback_proxy = ""

View file

@ -9,16 +9,19 @@ module Invidious::HttpServer
def check_external_proxy
CONFIG.external_videoplayback_proxy.each do |proxy|
begin
response = HTTP::Client.get(proxy)
response = HTTP::Client.get("#{proxy[:url]}/health")
if response.status_code == 200
@@proxy_alive = proxy
LOGGER.debug("CheckExternalProxy: Proxy set to: '#{proxy}'")
@@proxy_alive = proxy[:url]
LOGGER.debug("CheckExternalProxy: Proxy set to: '#{proxy[:url]}'")
break
end
rescue
LOGGER.debug("CheckExternalProxy: Proxy '#{proxy}' is not available")
LOGGER.debug("CheckExternalProxy: Proxy '#{proxy[:url]}' is not available")
end
end
if @@proxy_alive.empty?
LOGGER.warn("CheckExternalProxy: No proxies alive! Using own server proxy")
end
end
def get_external_proxy

View file

@ -5,8 +5,8 @@ class Invidious::Jobs::CheckExternalProxy < Invidious::Jobs::BaseJob
def begin
loop do
HttpServer::Utils.check_external_proxy
LOGGER.info("CheckExternalProxy: Done, sleeping for 1 minute")
sleep 1.minutes
LOGGER.info("CheckExternalProxy: Done, sleeping for 10 seconds")
sleep 10.seconds
Fiber.yield
end
end