add trackers from add_torrent_params/magnet links to separate tiers

This commit is contained in:
arvidn 2016-11-08 23:00:36 -05:00 committed by Arvid Norberg
parent 200b3c4965
commit f33d1b32e3
3 changed files with 8 additions and 0 deletions

View File

@ -1,3 +1,4 @@
* add trackers from add_torrent_params/magnet links to separate tiers
* fix resumedata check issue with files with priority 0
* deprecated mmap_cache feature
* add utility function for generating peer ID fingerprint

View File

@ -786,12 +786,14 @@ namespace libtorrent
}
#endif
int tier = 0;
for (std::vector<std::string>::const_iterator i = p.trackers.begin()
, end(p.trackers.end()); i != end; ++i)
{
m_trackers.push_back(announce_entry(*i));
m_trackers.back().fail_limit = 0;
m_trackers.back().source = announce_entry::source_magnet_link;
m_trackers.back().tier = tier++;
m_torrent_file->add_tracker(*i);
}

View File

@ -146,6 +146,8 @@ TORRENT_TEST(magnet)
trackers = t2.trackers();
TEST_EQUAL(trackers.size(), 2);
TEST_EQUAL(trackers[0].tier, 0);
TEST_EQUAL(trackers[1].tier, 1);
p.url = "magnet:"
"?tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80"
@ -162,16 +164,19 @@ TORRENT_TEST(magnet)
if (trackers.size() > 0)
{
TEST_EQUAL(trackers[0].url, "udp://tracker.openbittorrent.com:80");
TEST_EQUAL(trackers[0].tier, 0);
fprintf(stderr, "1: %s\n", trackers[0].url.c_str());
}
if (trackers.size() > 1)
{
TEST_EQUAL(trackers[1].url, "udp://tracker.publicbt.com:80");
TEST_EQUAL(trackers[1].tier, 1);
fprintf(stderr, "2: %s\n", trackers[1].url.c_str());
}
if (trackers.size() > 2)
{
TEST_EQUAL(trackers[2].url, "udp://tracker.ccc.de:80");
TEST_EQUAL(trackers[2].tier, 2);
fprintf(stderr, "3: %s\n", trackers[2].url.c_str());
}