print announce status for each endpoint

This commit is contained in:
Arvid Norberg 2020-03-26 23:52:58 +01:00 committed by Arvid Norberg
parent 56ec116f63
commit e9cff1db0b
1 changed files with 24 additions and 11 deletions

View File

@ -1785,19 +1785,32 @@ COLUMN OPTIONS
std::vector<lt::announce_entry> tr = h.trackers();
for (lt::announce_entry const& ae : h.trackers())
{
auto best_ae = std::min_element(ae.endpoints.begin(), ae.endpoints.end()
, [](lt::announce_endpoint const& l, lt::announce_endpoint const& r) { return l.fails < r.fails; } );
if (pos + 1 >= terminal_height) break;
std::snprintf(str, sizeof(str), "%2d %-55s fails: %-3d (%-3d) %s %s %5d \"%s\" %s\x1b[K\n"
, ae.tier, ae.url.c_str()
, best_ae != ae.endpoints.end() ? best_ae->fails : 0, ae.fail_limit, ae.verified?"OK ":"- "
, to_string(best_ae != ae.endpoints.end() ? int(total_seconds(best_ae->next_announce - now)) : 0, 8).c_str()
, best_ae != ae.endpoints.end() && best_ae->min_announce > now ? int(total_seconds(best_ae->min_announce - now)) : 0
, best_ae != ae.endpoints.end() && best_ae->last_error ? best_ae->last_error.message().c_str() : ""
, best_ae != ae.endpoints.end() ? best_ae->message.c_str() : "");
std::snprintf(str, sizeof(str), "%2d %-55s %s\x1b[K\n"
, ae.tier, ae.url.c_str(), ae.verified?"OK ":"- ");
out += str;
pos += 1;
int idx = 0;
for (auto const& ep : ae.endpoints)
{
++idx;
if (!ep.enabled) continue;
if (pos + 1 >= terminal_height) break;
std::snprintf(str, sizeof(str), " [%2d] fails: %-3d (%-3d) %s %5d \"%s\" %s\x1b[K\n"
, idx
, ep.fails, ae.fail_limit
, to_string(int(total_seconds(ep.next_announce - now)), 8).c_str()
, ep.min_announce > now ? int(total_seconds(ep.min_announce - now)) : 0
, ep.last_error ? ep.last_error.message().c_str() : ""
, ep.message.c_str());
out += str;
pos += 1;
// we only need to show this error once, not for every
// endpoint
if (ep.last_error == boost::asio::error::host_not_found) break;
}
if (pos + 1 >= terminal_height) break;
}
}