summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTheFrenchGhosty <47571719+TheFrenchGhosty@users.noreply.github.com>2021-06-11 14:04:05 +0000
committerGitHub <noreply@github.com>2021-06-11 14:04:05 +0000
commit4fd51ec880518439d43733f9d4d279189bcb6b3a (patch)
tree4d6b0577f73056aa5a6251924644dd74380c7f18 /src
parent9407b910606f7f37c2c9efe3609afbbb5620653b (diff)
parent0323c521be6cf6ba49735351bc0e7c669337ad26 (diff)
downloadinvidious-4fd51ec880518439d43733f9d4d279189bcb6b3a.tar.gz
invidious-4fd51ec880518439d43733f9d4d279189bcb6b3a.tar.bz2
invidious-4fd51ec880518439d43733f9d4d279189bcb6b3a.zip
Merge branch 'master' into patch-1
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr4
-rw-r--r--src/invidious/helpers/utils.cr8
-rw-r--r--src/invidious/jobs/bypass_captcha_job.cr2
-rw-r--r--src/invidious/routes/login.cr4
-rw-r--r--src/invidious/routes/preferences.cr8
-rw-r--r--src/invidious/users.cr2
6 files changed, 14 insertions, 14 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index ae20e13e..ebba52b1 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -166,7 +166,7 @@ end
before_all do |env|
preferences = begin
- Preferences.from_json(env.request.cookies["PREFS"]?.try &.value || "{}")
+ Preferences.from_json(URI.decode_www_form(env.request.cookies["PREFS"]?.try &.value || "{}"))
rescue
Preferences.from_json("{}")
end
@@ -421,7 +421,7 @@ get "/modify_notifications" do |env|
html = YT_POOL.client &.get("/subscription_manager?disable_polymer=1", headers)
- cookies = HTTP::Cookies.from_headers(headers)
+ cookies = HTTP::Cookies.from_client_headers(headers)
html.cookies.each do |cookie|
if {"VISITOR_INFO1_LIVE", "YSC", "SIDCC"}.includes? cookie.name
if cookies[cookie.name]?
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index 10d4e6b6..20107fad 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -1,5 +1,5 @@
require "lsquic"
-require "pool/connection"
+require "db"
def add_yt_headers(request)
request.headers["user-agent"] ||= "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36"
@@ -20,7 +20,7 @@ struct YoutubeConnectionPool
property! url : URI
property! capacity : Int32
property! timeout : Float64
- property pool : ConnectionPool(QUIC::Client | HTTP::Client)
+ property pool : DB::Pool(QUIC::Client | HTTP::Client)
def initialize(url : URI, @capacity = 5, @timeout = 5.0, use_quic = true)
@url = url
@@ -43,7 +43,7 @@ struct YoutubeConnectionPool
conn.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com"
response = yield conn
ensure
- pool.checkin(conn)
+ pool.release(conn)
end
end
@@ -51,7 +51,7 @@ struct YoutubeConnectionPool
end
private def build_pool(use_quic)
- ConnectionPool(QUIC::Client | HTTP::Client).new(capacity: capacity, timeout: timeout) do
+ DB::Pool(QUIC::Client | HTTP::Client).new(initial_pool_size: 0, max_pool_size: capacity, max_idle_pool_size: capacity, checkout_timeout: timeout) do
if use_quic
conn = QUIC::Client.new(url)
else
diff --git a/src/invidious/jobs/bypass_captcha_job.cr b/src/invidious/jobs/bypass_captcha_job.cr
index 4269e123..e68b81e6 100644
--- a/src/invidious/jobs/bypass_captcha_job.cr
+++ b/src/invidious/jobs/bypass_captcha_job.cr
@@ -112,7 +112,7 @@ class Invidious::Jobs::BypassCaptchaJob < Invidious::Jobs::BaseJob
headers = HTTP::Headers{
"Cookie" => URI.parse(response.headers["location"]).query_params["google_abuse"].split(";")[0],
}
- cookies = HTTP::Cookies.from_headers(headers)
+ cookies = HTTP::Cookies.from_client_headers(headers)
cookies.each { |cookie| CONFIG.cookies << cookie }
diff --git a/src/invidious/routes/login.cr b/src/invidious/routes/login.cr
index ffe5f568..f9e6ea6c 100644
--- a/src/invidious/routes/login.cr
+++ b/src/invidious/routes/login.cr
@@ -238,7 +238,7 @@ class Invidious::Routes::Login < Invidious::Routes::BaseRoute
traceback << "Logging in..."
location = URI.parse(challenge_results[0][-1][2].to_s)
- cookies = HTTP::Cookies.from_headers(headers)
+ cookies = HTTP::Cookies.from_client_headers(headers)
headers.delete("Content-Type")
headers.delete("Google-Accounts-XSRF")
@@ -261,7 +261,7 @@ class Invidious::Routes::Login < Invidious::Routes::BaseRoute
location = login.headers["Location"]?.try { |u| URI.parse(u) }
end
- cookies = HTTP::Cookies.from_headers(headers)
+ cookies = HTTP::Cookies.from_client_headers(headers)
sid = cookies["SID"]?.try &.value
if !sid
raise "Couldn't get SID."
diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr
index cfdad443..f98c7a5e 100644
--- a/src/invidious/routes/preferences.cr
+++ b/src/invidious/routes/preferences.cr
@@ -198,10 +198,10 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute
end
if CONFIG.domain
- env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{CONFIG.domain}", value: preferences, expires: Time.utc + 2.years,
+ env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{CONFIG.domain}", value: URI.encode_www_form(preferences), expires: Time.utc + 2.years,
secure: secure, http_only: true)
else
- env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: preferences, expires: Time.utc + 2.years,
+ env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: URI.encode_www_form(preferences), expires: Time.utc + 2.years,
secure: secure, http_only: true)
end
end
@@ -250,10 +250,10 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute
end
if CONFIG.domain
- env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{CONFIG.domain}", value: preferences, expires: Time.utc + 2.years,
+ env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{CONFIG.domain}", value: URI.encode_www_form(preferences), expires: Time.utc + 2.years,
secure: secure, http_only: true)
else
- env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: preferences, expires: Time.utc + 2.years,
+ env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: URI.encode_www_form(preferences), expires: Time.utc + 2.years,
secure: secure, http_only: true)
end
end
diff --git a/src/invidious/users.cr b/src/invidious/users.cr
index 5dfd80bb..d774ee12 100644
--- a/src/invidious/users.cr
+++ b/src/invidious/users.cr
@@ -462,7 +462,7 @@ def subscribe_ajax(channel_id, action, env_headers)
html = YT_POOL.client &.get("/subscription_manager?disable_polymer=1", headers)
- cookies = HTTP::Cookies.from_headers(headers)
+ cookies = HTTP::Cookies.from_client_headers(headers)
html.cookies.each do |cookie|
if {"VISITOR_INFO1_LIVE", "YSC", "SIDCC"}.includes? cookie.name
if cookies[cookie.name]?