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?
|
||||
external_videoplayback_proxy = ""
|
||||
CONFIG.external_videoplayback_proxy.each do |proxy|
|
||||
external_videoplayback_proxy += " #{proxy}"
|
||||
external_videoplayback_proxy += " #{proxy[:url]}"
|
||||
end
|
||||
else
|
||||
external_videoplayback_proxy = ""
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue