mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-06-28 01:48:26 +00:00
generate CSP each time the backend checker runs instead of each request made to invidious
This commit is contained in:
parent
d47aa3dd6a
commit
895745934b
@ -2,12 +2,15 @@ module BackendInfo
|
|||||||
extend self
|
extend self
|
||||||
@@exvpp_url : Array(String) = Array.new(CONFIG.invidious_companion.size, "")
|
@@exvpp_url : Array(String) = Array.new(CONFIG.invidious_companion.size, "")
|
||||||
@@status : Array(Int32) = Array.new(CONFIG.invidious_companion.size, 0)
|
@@status : Array(Int32) = Array.new(CONFIG.invidious_companion.size, 0)
|
||||||
|
@@extra_media_csp : String = ""
|
||||||
|
@@extra_connect_csp : String = ""
|
||||||
|
|
||||||
def check_backends
|
def check_backends
|
||||||
check_companion()
|
check_companion()
|
||||||
|
generate_csp()
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_companion
|
private def check_companion
|
||||||
CONFIG.invidious_companion.each_with_index do |companion, index|
|
CONFIG.invidious_companion.each_with_index do |companion, index|
|
||||||
spawn do
|
spawn do
|
||||||
begin
|
begin
|
||||||
@ -50,6 +53,23 @@ module BackendInfo
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private def generate_csp
|
||||||
|
@@extra_media_csp = ""
|
||||||
|
@@extra_connect_csp = ""
|
||||||
|
|
||||||
|
CONFIG.invidious_companion.each do |companion|
|
||||||
|
@@extra_media_csp += " #{companion.public_url}"
|
||||||
|
@@extra_connect_csp += " #{companion.public_url}"
|
||||||
|
end
|
||||||
|
exvpp_urls = self.get_exvpp
|
||||||
|
exvpp_urls.each do |exvpp_url|
|
||||||
|
if !exvpp_url.empty?
|
||||||
|
@@extra_media_csp += " #{exvpp_url}"
|
||||||
|
@@extra_connect_csp += " #{exvpp_url}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def get_status
|
def get_status
|
||||||
return @@status
|
return @@status
|
||||||
end
|
end
|
||||||
@ -57,4 +77,8 @@ module BackendInfo
|
|||||||
def get_exvpp
|
def get_exvpp
|
||||||
return @@exvpp_url
|
return @@exvpp_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_csp
|
||||||
|
return @@extra_media_csp, @@extra_connect_csp
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -41,17 +41,7 @@ module Invidious::Routes::BeforeAll
|
|||||||
|
|
||||||
env.set "current_companion", current_companion
|
env.set "current_companion", current_companion
|
||||||
|
|
||||||
CONFIG.invidious_companion.each do |companion|
|
extra_media_csp, extra_connect_csp = BackendInfo.get_csp()
|
||||||
extra_media_csp += " #{companion.public_url}"
|
|
||||||
extra_connect_csp += " #{companion.public_url}"
|
|
||||||
end
|
|
||||||
exvpp_urls = BackendInfo.get_exvpp
|
|
||||||
exvpp_urls.each do |exvpp_url|
|
|
||||||
if !exvpp_url.empty?
|
|
||||||
extra_media_csp += " #{exvpp_url}"
|
|
||||||
extra_connect_csp += " #{exvpp_url}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if !CONFIG.external_videoplayback_proxy.empty?
|
if !CONFIG.external_videoplayback_proxy.empty?
|
||||||
|
Loading…
Reference in New Issue
Block a user