mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 12:28:52 +00:00
feat: log which tracker is giving a warning (#4544)
This commit is contained in:
@@ -118,7 +118,7 @@ bool handleAnnounceResponse(tr_web::FetchResponse const& web_response, tr_announ
|
|||||||
if (status != HTTP_OK)
|
if (status != HTTP_OK)
|
||||||
{
|
{
|
||||||
auto const* const response_str = tr_webGetResponseStr(status);
|
auto const* const response_str = tr_webGetResponseStr(status);
|
||||||
response->errmsg = fmt::format(FMT_STRING("Tracker HTTP response {:d} ({:s}"), status, response_str);
|
response->errmsg = fmt::format(FMT_STRING("Tracker HTTP response {:d} ({:s})"), status, response_str);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -856,8 +856,10 @@ void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e)
|
|||||||
{
|
{
|
||||||
using namespace announce_helpers;
|
using namespace announce_helpers;
|
||||||
|
|
||||||
/* increment the error count */
|
|
||||||
auto* current_tracker = tier->currentTracker();
|
auto* current_tracker = tier->currentTracker();
|
||||||
|
std::string announce_url = current_tracker != nullptr ? tr_urlTrackerLogName(current_tracker->announce_url) : "nullptr";
|
||||||
|
|
||||||
|
/* increment the error count */
|
||||||
if (current_tracker != nullptr)
|
if (current_tracker != nullptr)
|
||||||
{
|
{
|
||||||
++current_tracker->consecutive_failures;
|
++current_tracker->consecutive_failures;
|
||||||
@@ -871,12 +873,14 @@ void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e)
|
|||||||
|
|
||||||
if (isUnregistered(err))
|
if (isUnregistered(err))
|
||||||
{
|
{
|
||||||
tr_logAddErrorTier(tier, fmt::format(_("Announce error: {error}"), fmt::arg("error", err)));
|
tr_logAddErrorTier(
|
||||||
|
tier,
|
||||||
|
fmt::format(_("Announce error: {error}"), fmt::arg("error", err)).append(fmt::format(" ({})", announce_url)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* schedule a reannounce */
|
/* schedule a reannounce */
|
||||||
int const interval = current_tracker->getRetryInterval();
|
auto const interval = current_tracker->getRetryInterval();
|
||||||
tr_logAddWarnTier(
|
tr_logAddWarnTier(
|
||||||
tier,
|
tier,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@@ -885,7 +889,8 @@ void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e)
|
|||||||
"Announce error: {error} (Retrying in {count} seconds)",
|
"Announce error: {error} (Retrying in {count} seconds)",
|
||||||
interval),
|
interval),
|
||||||
fmt::arg("error", err),
|
fmt::arg("error", err),
|
||||||
fmt::arg("count", interval)));
|
fmt::arg("count", interval))
|
||||||
|
.append(fmt::format(" ({})", announce_url)));
|
||||||
tier_announce_event_push(tier, e, tr_time() + interval);
|
tier_announce_event_push(tier, e, tr_time() + interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1275,13 +1280,7 @@ void checkMultiscrapeMax(tr_announcer_impl* announcer, tr_scrape_response const&
|
|||||||
if (multiscrape_max != n)
|
if (multiscrape_max != n)
|
||||||
{
|
{
|
||||||
// don't log the full URL, since that might have a personal announce id
|
// don't log the full URL, since that might have a personal announce id
|
||||||
// (note: we know 'parsed' will be successful since this url has a scrape_info)
|
tr_logAddDebug(fmt::format(FMT_STRING("Reducing multiscrape max to {:d}"), n), tr_urlTrackerLogName(url));
|
||||||
if (auto const parsed = tr_urlParse(url); parsed)
|
|
||||||
{
|
|
||||||
tr_logAddDebug(
|
|
||||||
fmt::format(FMT_STRING("Reducing multiscrape max to {:d}"), n),
|
|
||||||
fmt::format(FMT_STRING("{:s}://{:s}:{:d}"), parsed->scheme, parsed->host, parsed->port));
|
|
||||||
}
|
|
||||||
|
|
||||||
multiscrape_max = n;
|
multiscrape_max = n;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2213,7 +2213,10 @@ void tr_torrent::onTrackerResponse(tr_tracker_event const* event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case tr_tracker_event::Type::Warning:
|
case tr_tracker_event::Type::Warning:
|
||||||
tr_logAddWarnTor(this, fmt::format(_("Tracker warning: '{warning}'"), fmt::arg("warning", event->text)));
|
tr_logAddWarnTor(
|
||||||
|
this,
|
||||||
|
fmt::format(_("Tracker warning: '{warning}'"), fmt::arg("warning", event->text))
|
||||||
|
.append(fmt::format(" ({})", tr_urlTrackerLogName(event->announce_url))));
|
||||||
error = TR_STAT_TRACKER_WARNING;
|
error = TR_STAT_TRACKER_WARNING;
|
||||||
error_announce_url = event->announce_url;
|
error_announce_url = event->announce_url;
|
||||||
error_string = event->text;
|
error_string = event->text;
|
||||||
|
|||||||
@@ -373,6 +373,17 @@ bool tr_urlIsValid(std::string_view url)
|
|||||||
return parsed && std::find(std::begin(Schemes), std::end(Schemes), parsed->scheme) != std::end(Schemes);
|
return parsed && std::find(std::begin(Schemes), std::end(Schemes), parsed->scheme) != std::end(Schemes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string tr_urlTrackerLogName(std::string_view url)
|
||||||
|
{
|
||||||
|
if (auto const parsed = tr_urlParse(url); parsed)
|
||||||
|
{
|
||||||
|
return fmt::format(FMT_STRING("{:s}://{:s}:{:d}"), parsed->scheme, parsed->host, parsed->port);
|
||||||
|
}
|
||||||
|
|
||||||
|
// we have an invalid URL, we log the full string
|
||||||
|
return std::string{ url };
|
||||||
|
}
|
||||||
|
|
||||||
tr_url_query_view::iterator& tr_url_query_view::iterator::operator++()
|
tr_url_query_view::iterator& tr_url_query_view::iterator::operator++()
|
||||||
{
|
{
|
||||||
auto pair = tr_strvSep(&remain, '&');
|
auto pair = tr_strvSep(&remain, '&');
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ struct tr_url_parsed_t
|
|||||||
// must be one we that Transmission supports for announce and scrape
|
// must be one we that Transmission supports for announce and scrape
|
||||||
[[nodiscard]] std::optional<tr_url_parsed_t> tr_urlParseTracker(std::string_view url);
|
[[nodiscard]] std::optional<tr_url_parsed_t> tr_urlParseTracker(std::string_view url);
|
||||||
|
|
||||||
|
// Convenience function to get a log-safe version of a tracker URL.
|
||||||
|
// This is to avoid logging sensitive info, e.g. a personal announcer id in the URL.
|
||||||
|
[[nodiscard]] std::string tr_urlTrackerLogName(std::string_view url);
|
||||||
|
|
||||||
// example use: `for (auto const [key, val] : tr_url_query_view{ querystr })`
|
// example use: `for (auto const [key, val] : tr_url_query_view{ querystr })`
|
||||||
struct tr_url_query_view
|
struct tr_url_query_view
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user