mirror of
https://github.com/transmission/transmission
synced 2025-03-12 23:23:54 +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:
parent
40814a3195
commit
04769d9986
1 changed files with 23 additions and 2 deletions
|
@ -122,6 +122,11 @@ bool handleAnnounceResponse(tr_web::FetchResponse const& web_response, tr_announ
|
|||
|
||||
tr_announcerParseHttpAnnounceResponse(response, body, log_name);
|
||||
|
||||
if (!std::empty(response.errmsg))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!std::empty(response.pex6))
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -255,8 +276,8 @@ void tr_tracker_http_announce(
|
|||
public address they want to use.
|
||||
|
||||
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
|
||||
longer need to compute the global IPv4 and IPv6 addresses.
|
||||
and to be safe we also add the "ipv4=" and "ipv6=" parameters, if
|
||||
we already have them.
|
||||
*/
|
||||
auto url = tr_urlbuf{};
|
||||
announce_url_new(url, session, request);
|
||||
|
|
Loading…
Add table
Reference in a new issue