Compare commits

...

2 Commits

Author SHA1 Message Date
syeopite
1c0b4205d4
Add parameter to disable force_resolve in make_client (#4335)
* Add option to disable force_resolve in make_client

Some websites such as archive.org and textcaptcha.com
does not support IPv6 and as such requests fail when Invidious requests
with IPv6 to those services.

* Reenable force_resolve on pubsub subcribe request

* Make force_resolve false by default in make_client

* Remove missed explicit force_resolve=false
2024-01-10 23:01:00 +00:00
syeopite
b16f66ef00
Exempt issues with "exempt-stale" from staling (#4385)
The exempt-stale label was not actually set to exempt issues from staling...
2024-01-10 20:40:19 +00:00
3 changed files with 15 additions and 10 deletions

View File

@ -16,7 +16,7 @@ jobs:
days-before-stale: 365 days-before-stale: 365
days-before-pr-stale: 90 days-before-pr-stale: 90
days-before-close: 30 days-before-close: 30
exempt-pr-labels: blocked exempt-pr-labels: blocked,exempt-stale
stale-issue-message: 'This issue has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely outdated. If you think this issue is still relevant and applicable, you just have to post a comment and it will be unmarked.' stale-issue-message: 'This issue has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely outdated. If you think this issue is still relevant and applicable, you just have to post a comment and it will be unmarked.'
stale-pr-message: 'This pull request has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely abandoned or outdated. If you think this pull request is still relevant and applicable, you just have to post a comment and it will be unmarked.' stale-pr-message: 'This pull request has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely abandoned or outdated. If you think this pull request is still relevant and applicable, you just have to post a comment and it will be unmarked.'
stale-issue-label: "stale" stale-issue-label: "stale"

View File

@ -42,7 +42,7 @@ module Invidious::Routes::VideoPlayback
headers["Range"] = "bytes=#{range_for_head}" headers["Range"] = "bytes=#{range_for_head}"
end end
client = make_client(URI.parse(host), region) client = make_client(URI.parse(host), region, force_resolve = true)
response = HTTP::Client::Response.new(500) response = HTTP::Client::Response.new(500)
error = "" error = ""
5.times do 5.times do
@ -57,7 +57,7 @@ module Invidious::Routes::VideoPlayback
if new_host != host if new_host != host
host = new_host host = new_host
client.close client.close
client = make_client(URI.parse(new_host), region) client = make_client(URI.parse(new_host), region, force_resolve = true)
end end
url = "#{location.request_target}&host=#{location.host}#{region ? "&region=#{region}" : ""}" url = "#{location.request_target}&host=#{location.host}#{region ? "&region=#{region}" : ""}"
@ -71,7 +71,7 @@ module Invidious::Routes::VideoPlayback
fvip = "3" fvip = "3"
host = "https://r#{fvip}---#{mn}.googlevideo.com" host = "https://r#{fvip}---#{mn}.googlevideo.com"
client = make_client(URI.parse(host), region) client = make_client(URI.parse(host), region, force_resolve = true)
rescue ex rescue ex
error = ex.message error = ex.message
end end
@ -196,7 +196,7 @@ module Invidious::Routes::VideoPlayback
break break
else else
client.close client.close
client = make_client(URI.parse(host), region) client = make_client(URI.parse(host), region, force_resolve = true)
end end
end end

View File

@ -26,7 +26,7 @@ struct YoutubeConnectionPool
def client(region = nil, &block) def client(region = nil, &block)
if region if region
conn = make_client(url, region) conn = make_client(url, region, force_resolve = true)
response = yield conn response = yield conn
else else
conn = pool.checkout conn = pool.checkout
@ -59,9 +59,14 @@ struct YoutubeConnectionPool
end end
end end
def make_client(url : URI, region = nil) def make_client(url : URI, region = nil, force_resolve : Bool = false)
client = HTTPClient.new(url, OpenSSL::SSL::Context::Client.insecure) client = HTTPClient.new(url, OpenSSL::SSL::Context::Client.insecure)
client.family = CONFIG.force_resolve
# Some services do not support IPv6.
if force_resolve
client.family = CONFIG.force_resolve
end
client.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com" client.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com"
client.read_timeout = 10.seconds client.read_timeout = 10.seconds
client.connect_timeout = 10.seconds client.connect_timeout = 10.seconds
@ -80,8 +85,8 @@ def make_client(url : URI, region = nil)
return client return client
end end
def make_client(url : URI, region = nil, &block) def make_client(url : URI, region = nil, force_resolve : Bool = false, &block)
client = make_client(url, region) client = make_client(url, region, force_resolve)
begin begin
yield client yield client
ensure ensure