mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Add administrator option to disable proxying
This commit is contained in:
parent
5fd3ed782f
commit
2cc25b1e6e
6 changed files with 46 additions and 9 deletions
|
@ -4667,6 +4667,12 @@ get "/videoplayback" do |env|
|
||||||
end
|
end
|
||||||
|
|
||||||
if url.includes? "&file=seg.ts"
|
if url.includes? "&file=seg.ts"
|
||||||
|
if CONFIG.disabled?("livestreams")
|
||||||
|
env.response.status_code = 403
|
||||||
|
error_message = "Administrator has disabled this endpoint."
|
||||||
|
next templated "error"
|
||||||
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
client = make_client(URI.parse(host), region)
|
client = make_client(URI.parse(host), region)
|
||||||
client.get(url, headers) do |response|
|
client.get(url, headers) do |response|
|
||||||
|
@ -4694,6 +4700,13 @@ get "/videoplayback" do |env|
|
||||||
rescue ex
|
rescue ex
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
if query_params["title"]? && CONFIG.disabled?("downloads") ||
|
||||||
|
CONFIG.disabled?("dash")
|
||||||
|
env.response.status_code = 403
|
||||||
|
error_message = "Administrator has disabled this endpoint."
|
||||||
|
next templated "error"
|
||||||
|
end
|
||||||
|
|
||||||
content_length = nil
|
content_length = nil
|
||||||
first_chunk = true
|
first_chunk = true
|
||||||
range_start, range_end = parse_range(env.request.headers["Range"]?)
|
range_start, range_end = parse_range(env.request.headers["Range"]?)
|
||||||
|
|
|
@ -96,6 +96,19 @@ struct Config
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def disabled?(option)
|
||||||
|
case disabled = CONFIG.disable_proxy
|
||||||
|
when Bool
|
||||||
|
return disabled
|
||||||
|
when Array
|
||||||
|
if disabled.includes? option
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
YAML.mapping({
|
YAML.mapping({
|
||||||
channel_threads: Int32, # Number of threads to use for crawling videos from channels (for updating subscriptions)
|
channel_threads: Int32, # Number of threads to use for crawling videos from channels (for updating subscriptions)
|
||||||
feed_threads: Int32, # Number of threads to use for updating feeds
|
feed_threads: Int32, # Number of threads to use for updating feeds
|
||||||
|
@ -123,6 +136,7 @@ struct Config
|
||||||
cache_annotations: {type: Bool, default: false}, # Cache annotations requested from IA, will not cache empty annotations or annotations that only contain cards
|
cache_annotations: {type: Bool, default: false}, # Cache annotations requested from IA, will not cache empty annotations or annotations that only contain cards
|
||||||
banner: {type: String?, default: nil}, # Optional banner to be displayed along top of page for announcements, etc.
|
banner: {type: String?, default: nil}, # Optional banner to be displayed along top of page for announcements, etc.
|
||||||
hsts: {type: Bool?, default: true}, # Enables 'Strict-Transport-Security'. Ensure that `domain` and all subdomains are served securely
|
hsts: {type: Bool?, default: true}, # Enables 'Strict-Transport-Security'. Ensure that `domain` and all subdomains are served securely
|
||||||
|
disable_proxy: {type: Bool? | Array(String)?, default: false}, # Disable proxying server-wide: options: 'dash', 'livestreams', 'downloads', 'local'
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1292,6 +1292,14 @@ def process_video_params(query, preferences)
|
||||||
related_videos = related_videos == 1
|
related_videos = related_videos == 1
|
||||||
video_loop = video_loop == 1
|
video_loop = video_loop == 1
|
||||||
|
|
||||||
|
if CONFIG.disabled?("dash") && quality == "dash"
|
||||||
|
quality = "high"
|
||||||
|
end
|
||||||
|
|
||||||
|
if CONFIG.disabled?("local") && local
|
||||||
|
local = false
|
||||||
|
end
|
||||||
|
|
||||||
if query["t"]?
|
if query["t"]?
|
||||||
video_start = decode_time(query["t"])
|
video_start = decode_time(query["t"])
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<% if params.autoplay %>autoplay<% end %>
|
<% if params.autoplay %>autoplay<% end %>
|
||||||
<% if params.video_loop %>loop<% end %>
|
<% if params.video_loop %>loop<% end %>
|
||||||
<% if params.controls %>controls<% end %>>
|
<% if params.controls %>controls<% end %>>
|
||||||
<% if hlsvp %>
|
<% if hlsvp && !CONFIG.disabled?("livestreams") %>
|
||||||
<source src="<%= hlsvp %>?local=true" type="application/x-mpegURL" label="livestream">
|
<source src="<%= hlsvp %>?local=true" type="application/x-mpegURL" label="livestream">
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if params.listen %>
|
<% if params.listen %>
|
||||||
|
|
|
@ -35,7 +35,7 @@ function update_value(element) {
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="local"><%= translate(locale, "Proxy videos? ") %></label>
|
<label for="local"><%= translate(locale, "Proxy videos? ") %></label>
|
||||||
<input name="local" id="local" type="checkbox" <% if preferences.local %>checked<% end %>>
|
<input name="local" id="local" type="checkbox" <% if preferences.local && !CONFIG.disabled?("local") %>checked<% end %> <% if CONFIG.disabled?("local") %>disabled<% end %>>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
|
@ -56,8 +56,10 @@ function update_value(element) {
|
||||||
<label for="quality"><%= translate(locale, "Preferred video quality: ") %></label>
|
<label for="quality"><%= translate(locale, "Preferred video quality: ") %></label>
|
||||||
<select name="quality" id="quality">
|
<select name="quality" id="quality">
|
||||||
<% {"dash", "hd720", "medium", "small"}.each do |option| %>
|
<% {"dash", "hd720", "medium", "small"}.each do |option| %>
|
||||||
|
<% if !(option == "dash" && CONFIG.disabled?("dash")) %>
|
||||||
<option value="<%= option %>" <% if preferences.quality == option %> selected <% end %>><%= translate(locale, option) %></option>
|
<option value="<%= option %>" <% if preferences.quality == option %> selected <% end %>><%= translate(locale, option) %></option>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ var video_data = {
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<% if CONFIG.dmca_content.includes? video.id %>
|
<% if CONFIG.dmca_content.includes?(video.id) || CONFIG.disabled?("downloads") %>
|
||||||
<p><%= translate(locale, "Download is disabled.") %></p>
|
<p><%= translate(locale, "Download is disabled.") %></p>
|
||||||
<% else %>
|
<% else %>
|
||||||
<form class="pure-form pure-form-stacked" action="/latest_version" method="get" rel="noopener" target="_blank">
|
<form class="pure-form pure-form-stacked" action="/latest_version" method="get" rel="noopener" target="_blank">
|
||||||
|
|
Loading…
Reference in a new issue