forked from Fijxu/invidious
External Proxies: Adapt it to use a NamedTuple
This commit is contained in:
parent
67998d1f36
commit
fc910b43ba
3 changed files with 10 additions and 7 deletions
|
@ -390,7 +390,7 @@ def gen_videoplayback_proxy_list
|
||||||
if !CONFIG.external_videoplayback_proxy.empty?
|
if !CONFIG.external_videoplayback_proxy.empty?
|
||||||
external_videoplayback_proxy = ""
|
external_videoplayback_proxy = ""
|
||||||
CONFIG.external_videoplayback_proxy.each do |proxy|
|
CONFIG.external_videoplayback_proxy.each do |proxy|
|
||||||
external_videoplayback_proxy += " #{proxy}"
|
external_videoplayback_proxy += " #{proxy[:url]}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
external_videoplayback_proxy = ""
|
external_videoplayback_proxy = ""
|
||||||
|
|
|
@ -9,16 +9,19 @@ module Invidious::HttpServer
|
||||||
def check_external_proxy
|
def check_external_proxy
|
||||||
CONFIG.external_videoplayback_proxy.each do |proxy|
|
CONFIG.external_videoplayback_proxy.each do |proxy|
|
||||||
begin
|
begin
|
||||||
response = HTTP::Client.get(proxy)
|
response = HTTP::Client.get("#{proxy[:url]}/health")
|
||||||
if response.status_code == 200
|
if response.status_code == 200
|
||||||
@@proxy_alive = proxy
|
@@proxy_alive = proxy[:url]
|
||||||
LOGGER.debug("CheckExternalProxy: Proxy set to: '#{proxy}'")
|
LOGGER.debug("CheckExternalProxy: Proxy set to: '#{proxy[:url]}'")
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
LOGGER.debug("CheckExternalProxy: Proxy '#{proxy}' is not available")
|
LOGGER.debug("CheckExternalProxy: Proxy '#{proxy[:url]}' is not available")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if @@proxy_alive.empty?
|
||||||
|
LOGGER.warn("CheckExternalProxy: No proxies alive! Using own server proxy")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_external_proxy
|
def get_external_proxy
|
||||||
|
|
|
@ -5,8 +5,8 @@ class Invidious::Jobs::CheckExternalProxy < Invidious::Jobs::BaseJob
|
||||||
def begin
|
def begin
|
||||||
loop do
|
loop do
|
||||||
HttpServer::Utils.check_external_proxy
|
HttpServer::Utils.check_external_proxy
|
||||||
LOGGER.info("CheckExternalProxy: Done, sleeping for 1 minute")
|
LOGGER.info("CheckExternalProxy: Done, sleeping for 10 seconds")
|
||||||
sleep 1.minutes
|
sleep 10.seconds
|
||||||
Fiber.yield
|
Fiber.yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue