mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-29 09:16:20 -05:00
Add administrator option to disable proxying
This commit is contained in:
parent
5fd3ed782f
commit
2cc25b1e6e
@ -4667,6 +4667,12 @@ get "/videoplayback" do |env|
|
||||
end
|
||||
|
||||
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
|
||||
client = make_client(URI.parse(host), region)
|
||||
client.get(url, headers) do |response|
|
||||
@ -4694,6 +4700,13 @@ get "/videoplayback" do |env|
|
||||
rescue ex
|
||||
end
|
||||
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
|
||||
first_chunk = true
|
||||
range_start, range_end = parse_range(env.request.headers["Range"]?)
|
||||
|
@ -96,6 +96,19 @@ struct Config
|
||||
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({
|
||||
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
|
||||
@ -118,11 +131,12 @@ struct Config
|
||||
default: Preferences.new(*ConfigPreferences.from_yaml("").to_tuple),
|
||||
converter: ConfigPreferencesConverter,
|
||||
},
|
||||
dmca_content: {type: Array(String), default: [] of String}, # For compliance with DMCA, disables download widget using list of video IDs
|
||||
check_tables: {type: Bool, default: false}, # Check table integrity, automatically try to add any missing columns, create tables, etc.
|
||||
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.
|
||||
hsts: {type: Bool?, default: true}, # Enables 'Strict-Transport-Security'. Ensure that `domain` and all subdomains are served securely
|
||||
dmca_content: {type: Array(String), default: [] of String}, # For compliance with DMCA, disables download widget using list of video IDs
|
||||
check_tables: {type: Bool, default: false}, # Check table integrity, automatically try to add any missing columns, create tables, etc.
|
||||
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.
|
||||
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
|
||||
|
||||
|
@ -1292,6 +1292,14 @@ def process_video_params(query, preferences)
|
||||
related_videos = related_videos == 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"]?
|
||||
video_start = decode_time(query["t"])
|
||||
end
|
||||
|
@ -6,7 +6,7 @@
|
||||
<% if params.autoplay %>autoplay<% end %>
|
||||
<% if params.video_loop %>loop<% end %>
|
||||
<% if params.controls %>controls<% end %>>
|
||||
<% if hlsvp %>
|
||||
<% if hlsvp && !CONFIG.disabled?("livestreams") %>
|
||||
<source src="<%= hlsvp %>?local=true" type="application/x-mpegURL" label="livestream">
|
||||
<% else %>
|
||||
<% if params.listen %>
|
||||
|
@ -35,7 +35,7 @@ function update_value(element) {
|
||||
|
||||
<div class="pure-control-group">
|
||||
<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 class="pure-control-group">
|
||||
@ -56,7 +56,9 @@ function update_value(element) {
|
||||
<label for="quality"><%= translate(locale, "Preferred video quality: ") %></label>
|
||||
<select name="quality" id="quality">
|
||||
<% {"dash", "hd720", "medium", "small"}.each do |option| %>
|
||||
<option value="<%= option %>" <% if preferences.quality == option %> selected <% end %>><%= translate(locale, option) %></option>
|
||||
<% if !(option == "dash" && CONFIG.disabled?("dash")) %>
|
||||
<option value="<%= option %>" <% if preferences.quality == option %> selected <% end %>><%= translate(locale, option) %></option>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
|
@ -98,7 +98,7 @@ var video_data = {
|
||||
<% end %>
|
||||
</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>
|
||||
<% else %>
|
||||
<form class="pure-form pure-form-stacked" action="/latest_version" method="get" rel="noopener" target="_blank">
|
||||
|
Loading…
Reference in New Issue
Block a user