mirror of
https://github.com/transmission/transmission
synced 2025-01-30 10:52:00 +00:00
refactor: rename tr_tracker_view.host to .host_and_port for clarity (#5508)
This commit is contained in:
parent
ea500ecdcd
commit
c61d8b7cf7
11 changed files with 23 additions and 22 deletions
|
@ -1964,7 +1964,8 @@ void buildTrackerSummary(
|
|||
// hostname
|
||||
gstr << text_dir_mark.at(static_cast<int>(direction));
|
||||
gstr << (tracker.isBackup ? "<i>" : "<b>");
|
||||
gstr << Glib::Markup::escape_text(!key.empty() ? fmt::format(FMT_STRING("{:s} - {:s}"), tracker.host, key) : tracker.host);
|
||||
gstr << Glib::Markup::escape_text(
|
||||
!key.empty() ? fmt::format(FMT_STRING("{:s} - {:s}"), tracker.host_and_port, key) : tracker.host_and_port);
|
||||
gstr << (tracker.isBackup ? "</i>" : "</b>");
|
||||
|
||||
if (!tracker.isBackup)
|
||||
|
|
|
@ -218,7 +218,7 @@ bool FilterBar::Impl::tracker_filter_model_update()
|
|||
for (size_t j = 0, n = tr_torrentTrackerCount(&raw_torrent); j < n; ++j)
|
||||
{
|
||||
auto const view = tr_torrentTracker(&raw_torrent, j);
|
||||
site_to_host_and_announce.try_emplace(std::data(view.sitename), view.host, view.announce);
|
||||
site_to_host_and_announce.try_emplace(std::data(view.sitename), view.host_and_port, view.announce);
|
||||
}
|
||||
|
||||
for (auto const& [sitename, host_and_announce] : site_to_host_and_announce)
|
||||
|
|
|
@ -84,7 +84,7 @@ bool tr_announce_list::add(std::string_view announce_url_sv, tr_tracker_tier_t t
|
|||
tracker.announce = announce_url_sv;
|
||||
tracker.tier = get_tier(tier, *announce);
|
||||
tracker.id = next_unique_id();
|
||||
tracker.host = fmt::format(FMT_STRING("{:s}:{:d}"), announce->host, announce->port);
|
||||
tracker.host_and_port = fmt::format(FMT_STRING("{:s}:{:d}"), announce->host, announce->port);
|
||||
tracker.sitename = announce->sitename;
|
||||
|
||||
if (auto const scrape_str = announce_to_scrape(announce_url_sv); scrape_str)
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
{
|
||||
tr_interned_string announce;
|
||||
tr_interned_string scrape;
|
||||
tr_interned_string host; // 'example.org:80'
|
||||
tr_interned_string host_and_port; // 'example.org:80'
|
||||
tr_interned_string sitename; // 'example'
|
||||
tr_tracker_tier_t tier = 0;
|
||||
tr_tracker_id_t id = 0;
|
||||
|
|
|
@ -270,7 +270,7 @@ std::unique_ptr<tr_announcer> tr_announcer::create(
|
|||
struct tr_tracker
|
||||
{
|
||||
explicit tr_tracker(tr_announcer_impl* announcer, tr_announce_list::tracker_info const& info)
|
||||
: host{ info.host }
|
||||
: host_and_port{ info.host_and_port }
|
||||
, announce_url{ info.announce }
|
||||
, sitename{ info.sitename }
|
||||
, scrape_info{ std::empty(info.scrape) ? nullptr : announcer->scrape_info(info.scrape) }
|
||||
|
@ -305,7 +305,7 @@ struct tr_tracker
|
|||
}
|
||||
}
|
||||
|
||||
tr_interned_string const host;
|
||||
tr_interned_string const host_and_port;
|
||||
tr_interned_string const announce_url;
|
||||
std::string_view const sitename;
|
||||
tr_scrape_info* const scrape_info;
|
||||
|
@ -443,8 +443,8 @@ struct tr_tier
|
|||
{
|
||||
auto const* const torrent_name = tr_torrentName(tor);
|
||||
auto const* const current_tracker = currentTracker();
|
||||
auto const host_sv = current_tracker == nullptr ? "?"sv : current_tracker->host.sv();
|
||||
*fmt::format_to_n(buf, buflen - 1, FMT_STRING("{:s} at {:s}"), torrent_name, host_sv).out = '\0';
|
||||
auto const host_and_port_sv = current_tracker == nullptr ? "?"sv : current_tracker->host_and_port.sv();
|
||||
*fmt::format_to_n(buf, buflen - 1, FMT_STRING("{:s} at {:s}"), torrent_name, host_and_port_sv).out = '\0';
|
||||
}
|
||||
|
||||
[[nodiscard]] bool canManualAnnounce() const
|
||||
|
@ -1250,10 +1250,10 @@ void on_scrape_error(tr_session const* /*session*/, tr_tier* tier, char const* e
|
|||
|
||||
// schedule a rescrape
|
||||
auto const interval = current_tracker->getRetryInterval();
|
||||
auto const* const host_cstr = current_tracker->host.c_str();
|
||||
auto const* const host_and_port_cstr = current_tracker->host_and_port.c_str();
|
||||
tr_logAddDebugTier(
|
||||
tier,
|
||||
fmt::format("Tracker '{}' scrape error: {} (Retrying in {} seconds)", host_cstr, errmsg, interval));
|
||||
fmt::format("Tracker '{}' scrape error: {} (Retrying in {} seconds)", host_and_port_cstr, errmsg, interval));
|
||||
tier->lastScrapeSucceeded = false;
|
||||
tier->scheduleNextScrape(interval);
|
||||
}
|
||||
|
@ -1625,7 +1625,7 @@ namespace tracker_view_helpers
|
|||
auto const now = tr_time();
|
||||
auto view = tr_tracker_view{};
|
||||
|
||||
view.host = tracker.host.c_str();
|
||||
view.host_and_port = tracker.host_and_port.c_str();
|
||||
view.announce = tracker.announce_url.c_str();
|
||||
view.scrape = tracker.scrape_info == nullptr ? "" : tracker.scrape_info->scrape_url.c_str();
|
||||
*std::copy_n(
|
||||
|
|
|
@ -362,7 +362,7 @@ void addTrackerStats(tr_tracker_view const& tracker, tr_variant* list)
|
|||
tr_variantDictAddInt(d, TR_KEY_downloadCount, tracker.downloadCount);
|
||||
tr_variantDictAddBool(d, TR_KEY_hasAnnounced, tracker.hasAnnounced);
|
||||
tr_variantDictAddBool(d, TR_KEY_hasScraped, tracker.hasScraped);
|
||||
tr_variantDictAddStr(d, TR_KEY_host, tracker.host);
|
||||
tr_variantDictAddStr(d, TR_KEY_host, tracker.host_and_port);
|
||||
tr_variantDictAddStr(d, TR_KEY_sitename, tracker.sitename);
|
||||
tr_variantDictAddInt(d, TR_KEY_id, tracker.id);
|
||||
tr_variantDictAddBool(d, TR_KEY_isBackup, tracker.isBackup);
|
||||
|
|
|
@ -418,7 +418,7 @@ namespace script_helpers
|
|||
|
||||
for (size_t i = 0, n = tr_torrentTrackerCount(tor); i < n; ++i)
|
||||
{
|
||||
buf << tr_torrentTracker(tor, i).host;
|
||||
buf << tr_torrentTracker(tor, i).host_and_port;
|
||||
|
||||
if (++i < n)
|
||||
{
|
||||
|
|
|
@ -1274,7 +1274,7 @@ struct tr_tracker_view
|
|||
{
|
||||
char const* announce; // full announce URL
|
||||
char const* scrape; // full scrape URL
|
||||
char const* host; // uniquely-identifying tracker name (`${host}:${port}`)
|
||||
char const* host_and_port; // uniquely-identifying tracker name (`${host}:${port}`)
|
||||
|
||||
// The tracker site's name. Uses the first label before the public suffix
|
||||
// (https://publicsuffix.org/) in the announce URL's host.
|
||||
|
|
|
@ -1684,10 +1684,10 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error)
|
|||
{
|
||||
auto const tracker = tr_torrentTracker(self.fHandle, i);
|
||||
|
||||
NSString* host = @(tracker.host);
|
||||
if (!best || [host localizedCaseInsensitiveCompare:best] == NSOrderedAscending)
|
||||
NSString* host_and_port = @(tracker.host_and_port);
|
||||
if (!best || [host_and_port localizedCaseInsensitiveCompare:best] == NSOrderedAscending)
|
||||
{
|
||||
best = host;
|
||||
best = host_and_port;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
- (NSString*)host
|
||||
{
|
||||
return @(self.fStat.host);
|
||||
return @(self.fStat.host_and_port);
|
||||
}
|
||||
|
||||
- (NSString*)fullAnnounceAddress
|
||||
|
|
|
@ -35,7 +35,7 @@ TEST_F(AnnounceListTest, canAdd)
|
|||
EXPECT_EQ(Announce, tracker.announce.sv());
|
||||
EXPECT_EQ("https://example.org/scrape"sv, tracker.scrape.sv());
|
||||
EXPECT_EQ(Tier, tracker.tier);
|
||||
EXPECT_EQ("example.org:443"sv, tracker.host.sv());
|
||||
EXPECT_EQ("example.org:443"sv, tracker.host_and_port.sv());
|
||||
}
|
||||
|
||||
TEST_F(AnnounceListTest, groupsSiblingsIntoSameTier)
|
||||
|
@ -59,9 +59,9 @@ TEST_F(AnnounceListTest, groupsSiblingsIntoSameTier)
|
|||
EXPECT_EQ(Announce1, announce_list.at(0).announce.sv());
|
||||
EXPECT_EQ(Announce2, announce_list.at(1).announce.sv());
|
||||
EXPECT_EQ(Announce3, announce_list.at(2).announce.sv());
|
||||
EXPECT_EQ("example.org:443"sv, announce_list.at(0).host.sv());
|
||||
EXPECT_EQ("example.org:80"sv, announce_list.at(1).host.sv());
|
||||
EXPECT_EQ("example.org:999"sv, announce_list.at(2).host.sv());
|
||||
EXPECT_EQ("example.org:443"sv, announce_list.at(0).host_and_port.sv());
|
||||
EXPECT_EQ("example.org:80"sv, announce_list.at(1).host_and_port.sv());
|
||||
EXPECT_EQ("example.org:999"sv, announce_list.at(2).host_and_port.sv());
|
||||
}
|
||||
|
||||
TEST_F(AnnounceListTest, canAddWithoutScrape)
|
||||
|
|
Loading…
Reference in a new issue