1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-13 07:33:02 +00:00

feat: support trackers with only old BEP-7 support (#7481)

* feat: restore old BEP-7 query parameters

* fix: treat failed tracker response as failure
This commit is contained in:
Yat Ho 2025-03-11 00:07:15 +08:00 committed by GitHub
parent 40814a3195
commit 04769d9986
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -122,6 +122,11 @@ bool handleAnnounceResponse(tr_web::FetchResponse const& web_response, tr_announ
tr_announcerParseHttpAnnounceResponse(response, body, log_name); tr_announcerParseHttpAnnounceResponse(response, body, log_name);
if (!std::empty(response.errmsg))
{
return false;
}
if (!std::empty(response.pex6)) if (!std::empty(response.pex6))
{ {
tr_logAddTrace(fmt::format("got a peers6 length of {}", std::size(response.pex6)), log_name); tr_logAddTrace(fmt::format("got a peers6 length of {}", std::size(response.pex6)), log_name);
@ -229,6 +234,22 @@ void announce_url_new(tr_urlbuf& url, tr_session const* session, tr_announce_req
{ {
fmt::format_to(out, "&trackerid={}", req.tracker_id); fmt::format_to(out, "&trackerid={}", req.tracker_id);
} }
if (auto ipv4_addr = session->global_address(TR_AF_INET); ipv4_addr)
{
auto buf = std::array<char, INET_ADDRSTRLEN>{};
auto const display_name = ipv4_addr->display_name(std::data(buf), std::size(buf));
fmt::format_to(out, "&ipv4=");
tr_urlPercentEncode(out, display_name);
}
if (auto ipv6_addr = session->global_address(TR_AF_INET6); ipv6_addr)
{
auto buf = std::array<char, INET6_ADDRSTRLEN>{};
auto const display_name = ipv6_addr->display_name(std::data(buf), std::size(buf));
fmt::format_to(out, "&ipv6=");
tr_urlPercentEncode(out, display_name);
}
} }
[[nodiscard]] std::string format_ip_arg(std::string_view ip) [[nodiscard]] std::string format_ip_arg(std::string_view ip)
@ -255,8 +276,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,
but no longer use the "ipv4=" and "ipv6=" parameters. So, we no and to be safe we also add the "ipv4=" and "ipv6=" parameters, if
longer need to compute the global IPv4 and IPv6 addresses. we already have them.
*/ */
auto url = tr_urlbuf{}; auto url = tr_urlbuf{};
announce_url_new(url, session, request); announce_url_new(url, session, request);