1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-12 23:23:54 +00:00

fix: not correctly sending UA to trackers related to curl gh6312 (#7447)

fallback to http1.1 when using flawed curl.
curl 7.71.0-7.74.0 are affected.
This commit is contained in:
pathC 2025-03-04 13:14:20 +08:00 committed by GitHub
parent 43e869b18e
commit 5163ac3e1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -409,6 +409,13 @@ public:
return version >= 0x075700 /* 7.87.0 */ && version <= 0x080500 /* 8.5.0 */;
}
// https://github.com/curl/curl/issues/6312
[[nodiscard]] static bool check_curl_gh6312() noexcept
{
auto const version = curl_version_info(CURLVERSION_NOW)->version_num;
return version >= 0x074700 /* 7.71.0 */ && version <= 0x074a00 /* 7.74.0 */;
}
static auto constexpr BandwidthPauseMsec = long{ 500 };
static auto constexpr DnsCacheTimeoutSecs = long{ 60 * 60 };
static auto constexpr MaxRedirects = long{ 10 };
@ -416,7 +423,7 @@ public:
bool const curl_verbose = tr_env_key_exists("TR_CURL_VERBOSE");
bool const curl_ssl_verify = !tr_env_key_exists("TR_CURL_SSL_NO_VERIFY");
bool const curl_proxy_ssl_verify = !tr_env_key_exists("TR_CURL_PROXY_SSL_NO_VERIFY");
bool const curl_gh10936 = check_curl_gh10936();
bool const curl_avoid_http2 = check_curl_gh10936() || check_curl_gh6312(); // both related to curl http2 bugs
Mediator& mediator;
@ -624,7 +631,7 @@ public:
(void)curl_easy_setopt(e, CURLOPT_RANGE, range->c_str());
}
if (curl_gh10936)
if (curl_avoid_http2)
{
(void)curl_easy_setopt(e, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
}