mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-13 22:00:33 +05:30
Add support for force_resolve to QUIC client
This commit is contained in:
parent
3fea1976c8
commit
a017574f74
@ -26,7 +26,7 @@ dependencies:
|
|||||||
version: ~> 0.1.2
|
version: ~> 0.1.2
|
||||||
lsquic:
|
lsquic:
|
||||||
github: omarroth/lsquic.cr
|
github: omarroth/lsquic.cr
|
||||||
version: ~> 0.1.5
|
version: ~> 0.1.7
|
||||||
|
|
||||||
crystal: 0.31.1
|
crystal: 0.31.1
|
||||||
|
|
||||||
|
@ -4523,9 +4523,10 @@ get "/api/v1/search/suggestions" do |env|
|
|||||||
query ||= ""
|
query ||= ""
|
||||||
|
|
||||||
begin
|
begin
|
||||||
response = QUIC::Client.get(
|
client = QUIC::Client.new("suggestqueries.google.com")
|
||||||
"https://suggestqueries.google.com/complete/search?hl=en&gl=#{region}&client=youtube&ds=yt&q=#{URI.encode_www_form(query)}&callback=suggestCallback"
|
client.family = CONFIG.force_resolve || Socket::Family::INET
|
||||||
).body
|
client.family = Socket::Family::INET if client.family == Socket::Family::UNSPEC
|
||||||
|
response = client.get("/complete/search?hl=en&gl=#{region}&client=youtube&ds=yt&q=#{URI.encode_www_form(query)}&callback=suggestCallback").body
|
||||||
|
|
||||||
body = response[35..-2]
|
body = response[35..-2]
|
||||||
body = JSON.parse(body).as_a
|
body = JSON.parse(body).as_a
|
||||||
|
@ -31,8 +31,10 @@ struct QUICPool
|
|||||||
begin
|
begin
|
||||||
response = yield conn
|
response = yield conn
|
||||||
rescue ex
|
rescue ex
|
||||||
conn.destroy_engine
|
conn.close
|
||||||
conn = QUIC::Client.new(url)
|
conn = QUIC::Client.new(url)
|
||||||
|
conn.family = (url.host == "www.youtube.com") ? CONFIG.force_resolve : Socket::Family::INET
|
||||||
|
conn.family = Socket::Family::INET if conn.family == Socket::Family::UNSPEC
|
||||||
conn.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com"
|
conn.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com"
|
||||||
response = yield conn
|
response = yield conn
|
||||||
ensure
|
ensure
|
||||||
@ -45,9 +47,11 @@ struct QUICPool
|
|||||||
|
|
||||||
private def build_pool
|
private def build_pool
|
||||||
ConnectionPool(QUIC::Client).new(capacity: capacity, timeout: timeout) do
|
ConnectionPool(QUIC::Client).new(capacity: capacity, timeout: timeout) do
|
||||||
client = QUIC::Client.new(url)
|
conn = QUIC::Client.new(url)
|
||||||
client.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com"
|
conn.family = (url.host == "www.youtube.com") ? CONFIG.force_resolve : Socket::Family::INET
|
||||||
client
|
conn.family = Socket::Family::INET if conn.family == Socket::Family::UNSPEC
|
||||||
|
conn.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com"
|
||||||
|
conn
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user