1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-30 10:52:00 +00:00

fix: intermediate fix for HTTP announce behaviour affected by bind-address-ipv* (#5296)

This commit is contained in:
tearfur 2023-03-29 01:59:42 +08:00 committed by GitHub
parent 47e141563a
commit 85a00625dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 32 deletions

View file

@ -92,8 +92,8 @@ Here is a sample of the three basic types: respectively Boolean, Number and Stri
* **utp-enabled:** Boolean (default = true) Enable [Micro Transport Protocol (µTP)](https://en.wikipedia.org/wiki/Micro_Transport_Protocol) * **utp-enabled:** Boolean (default = true) Enable [Micro Transport Protocol (µTP)](https://en.wikipedia.org/wiki/Micro_Transport_Protocol)
#### Peers #### Peers
* **bind-address-ipv4:** String (default = "0.0.0.0") Where to listen for peer connections. * **bind-address-ipv4:** String (default = "0.0.0.0") Where to listen for peer connections. When no valid IPv4 address is provided, Transmission will default to "0.0.0.0".
* **bind-address-ipv6:** String (default = "::") Where to listen for peer connections. * **bind-address-ipv6:** String (default = "::") Where to listen for peer connections. When no valid IPv6 address is provided, Transmission will determine your default public IPv6 address and use it.
* **peer-congestion-algorithm:** String. This is documented on https://www.pps.jussieu.fr/~jch/software/bittorrent/tcp-congestion-control.html. * **peer-congestion-algorithm:** String. This is documented on https://www.pps.jussieu.fr/~jch/software/bittorrent/tcp-congestion-control.html.
* **peer-limit-global:** Number (default = 240) * **peer-limit-global:** Number (default = 240)
* **peer-limit-per-torrent:** Number (default = 60) * **peer-limit-per-torrent:** Number (default = 60)

View file

@ -267,11 +267,8 @@ void tr_tracker_http_announce(
public address they want to use. public address they want to use.
We should ensure that we send the announce both via IPv6 and IPv4, We should ensure that we send the announce both via IPv6 and IPv4,
and to be safe we also add the "ipv6=" and "ipv4=" parameters, if but no longer use the "ipv4=" and "ipv6=" parameters. So, we no
we already have them. Our global IPv6 address is computed for the longer need to compute the global IPv4 and IPv6 addresses.
LTEP handshake, so this comes for free. Our public IPv4 address
may have been returned from a previous announce and stored in the
session.
*/ */
auto url = tr_urlbuf{}; auto url = tr_urlbuf{};
announce_url_new(url, session, request); announce_url_new(url, session, request);
@ -286,8 +283,6 @@ void tr_tracker_http_announce(
session->fetch(std::move(opt)); session->fetch(std::move(opt));
}; };
auto const [ipv6, ipv6_is_any] = session->publicAddress(TR_AF_INET6);
/* /*
* Before Curl 7.77.0, if we explicitly choose the IP version we want * Before Curl 7.77.0, if we explicitly choose the IP version we want
* to use, it is still possible that the wrong one is used. The workaround * to use, it is still possible that the wrong one is used. The workaround
@ -295,7 +290,7 @@ void tr_tracker_http_announce(
* a request that we don't know if will go through IPv6 or IPv4. * a request that we don't know if will go through IPv6 or IPv4.
*/ */
static auto const use_curl_workaround = curl_version_info(CURLVERSION_NOW)->version_num < 0x074D00 /* 7.77.0 */; static auto const use_curl_workaround = curl_version_info(CURLVERSION_NOW)->version_num < 0x074D00 /* 7.77.0 */;
if (use_curl_workaround) if (use_curl_workaround || session->useAnnounceIP())
{ {
if (session->useAnnounceIP()) if (session->useAnnounceIP())
{ {
@ -307,28 +302,16 @@ void tr_tracker_http_announce(
} }
else else
{ {
if (session->useAnnounceIP() || ipv6_is_any) d->requests_sent_count = 2;
{
if (session->useAnnounceIP())
{
options.url += format_ip_arg(session->announceIP());
}
d->requests_sent_count = 1;
do_make_request(""sv, std::move(options));
}
else
{
d->requests_sent_count = 2;
// First try to send the announce via IPv4: // First try to send the announce via IPv4:
auto ipv4_options = options; auto ipv4_options = options;
ipv4_options.ip_proto = tr_web::FetchOptions::IPProtocol::V4; ipv4_options.ip_proto = tr_web::FetchOptions::IPProtocol::V4;
do_make_request("IPv4"sv, std::move(ipv4_options)); do_make_request("IPv4"sv, std::move(ipv4_options));
// Then try to send via IPv6: // Then try to send via IPv6:
options.ip_proto = tr_web::FetchOptions::IPProtocol::V6; options.ip_proto = tr_web::FetchOptions::IPProtocol::V6;
do_make_request("IPv6"sv, std::move(options)); do_make_request("IPv6"sv, std::move(options));
}
} }
} }

View file

@ -581,13 +581,15 @@ std::optional<tr_address> tr_address::from_string(std::string_view address_sv)
auto addr = tr_address{}; auto addr = tr_address{};
if (evutil_inet_pton(AF_INET, address_sz, &addr.addr) == 1) addr.addr.addr4 = {};
if (evutil_inet_pton(AF_INET, address_sz, &addr.addr.addr4) == 1)
{ {
addr.type = TR_AF_INET; addr.type = TR_AF_INET;
return addr; return addr;
} }
if (evutil_inet_pton(AF_INET6, address_sz, &addr.addr) == 1) addr.addr.addr6 = {};
if (evutil_inet_pton(AF_INET6, address_sz, &addr.addr.addr6) == 1)
{ {
addr.type = TR_AF_INET6; addr.type = TR_AF_INET6;
return addr; return addr;