support option to report redundant bytes or not to tracker as well as 'corrupt' argument

This commit is contained in:
Arvid Norberg 2010-02-18 06:45:07 +00:00
parent e71f70a98d
commit 04d31cea6e
7 changed files with 33 additions and 4 deletions

View File

@ -118,6 +118,7 @@ release 0.14.9
* fixed MinGW support * fixed MinGW support
* fixed DHT bootstrapping issue * fixed DHT bootstrapping issue
* fixed UDP over SOCKS5 issue * fixed UDP over SOCKS5 issue
* added support for "corrupt" tracker announce
release 0.14.8 release 0.14.8

View File

@ -121,6 +121,7 @@ void bind_session_settings()
.def_readwrite("increase_est_reciprocation_rate", &session_settings::increase_est_reciprocation_rate) .def_readwrite("increase_est_reciprocation_rate", &session_settings::increase_est_reciprocation_rate)
.def_readwrite("decrease_est_reciprocation_rate", &session_settings::decrease_est_reciprocation_rate) .def_readwrite("decrease_est_reciprocation_rate", &session_settings::decrease_est_reciprocation_rate)
.def_readwrite("incoming_starts_queued_torrents", &session_settings::incoming_starts_queued_torrents) .def_readwrite("incoming_starts_queued_torrents", &session_settings::incoming_starts_queued_torrents)
.def_readwrite("report_true_downoaded", &session_settings::report_true_downloaded)
; ;
enum_<proxy_settings::proxy_type>("proxy_type") enum_<proxy_settings::proxy_type>("proxy_type")

View File

@ -3772,6 +3772,7 @@ session_settings
int increase_est_reciprocation_rate; int increase_est_reciprocation_rate;
int decrease_est_reciprocation_rate; int decrease_est_reciprocation_rate;
bool incoming_starts_queued_torrents; bool incoming_starts_queued_torrents;
bool report_true_downloaded;
}; };
``user_agent`` this is the client identification to the tracker. ``user_agent`` this is the client identification to the tracker.
@ -4343,6 +4344,10 @@ avoid spreading one's unchoke slots too thin. If a peer managed to
find us, even though we're no in the torrent anymore, this setting find us, even though we're no in the torrent anymore, this setting
can make us start the torrent and serve it. can make us start the torrent and serve it.
When ``report_true_downloaded`` is true, the ``&downloaded=`` argument
sent to trackers will include redundant downloaded bytes. It defaults
to ``false``, which means redundant bytes are not reported to the tracker.
pe_settings pe_settings
=========== ===========

View File

@ -202,6 +202,7 @@ namespace libtorrent
, increase_est_reciprocation_rate(20) , increase_est_reciprocation_rate(20)
, decrease_est_reciprocation_rate(3) , decrease_est_reciprocation_rate(3)
, incoming_starts_queued_torrents(false) , incoming_starts_queued_torrents(false)
, report_true_downloaded(false)
{} {}
// this is the user agent that will be sent to the tracker // this is the user agent that will be sent to the tracker
@ -762,6 +763,12 @@ namespace libtorrent
// if set to true, an incoming connection to a torrent that's // if set to true, an incoming connection to a torrent that's
// paused and auto-managed will make the torrent start. // paused and auto-managed will make the torrent start.
bool incoming_starts_queued_torrents; bool incoming_starts_queued_torrents;
// when set to true, the downloaded counter sent to trackers
// will include the actual number of payload bytes donwnloaded
// including redundant bytes. If set to false, it will not include
// any redundany bytes
bool report_true_downloaded;
}; };
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT

View File

@ -104,6 +104,7 @@ namespace libtorrent
size_type downloaded; size_type downloaded;
size_type uploaded; size_type uploaded;
size_type left; size_type left;
size_type corrupt;
unsigned short listen_port; unsigned short listen_port;
event_t event; event_t event;
std::string url; std::string url;

View File

@ -139,7 +139,8 @@ namespace libtorrent
char str[1024]; char str[1024];
const bool stats = tracker_req().send_stats; const bool stats = tracker_req().send_stats;
snprintf(str, sizeof(str), "&peer_id=%s&port=%d&uploaded=%"PRId64 snprintf(str, sizeof(str), "&peer_id=%s&port=%d&uploaded=%"PRId64
"&downloaded=%"PRId64"&left=%"PRId64"&compact=1&numwant=%d&key=%x&no_peer_id=1" "&downloaded=%"PRId64"&left=%"PRId64"&corrupt="PRId64"&compact=1"
"&numwant=%d&key=%x&no_peer_id=1"
, escape_string((const char*)&tracker_req().pid[0], 20).c_str() , escape_string((const char*)&tracker_req().pid[0], 20).c_str()
// the i2p tracker seems to verify that the port is not 0, // the i2p tracker seems to verify that the port is not 0,
// even though it ignores it otherwise // even though it ignores it otherwise
@ -147,6 +148,7 @@ namespace libtorrent
, stats ? tracker_req().uploaded : 0 , stats ? tracker_req().uploaded : 0
, stats ? tracker_req().downloaded : 0 , stats ? tracker_req().downloaded : 0
, stats ? tracker_req().left : 0 , stats ? tracker_req().left : 0
, stats ? tracker_req().corrupt : 0
, tracker_req().num_want , tracker_req().num_want
, tracker_req().key); , tracker_req().key);
url += str; url += str;

View File

@ -1345,10 +1345,16 @@ namespace libtorrent
tracker_request req; tracker_request req;
req.info_hash = m_torrent_file->info_hash(); req.info_hash = m_torrent_file->info_hash();
req.pid = m_ses.get_peer_id(); req.pid = m_ses.get_peer_id();
req.downloaded = m_stat.total_payload_download(); req.downloaded = m_stat.total_payload_download() - m_total_failed_bytes;
req.uploaded = m_stat.total_payload_upload(); req.uploaded = m_stat.total_payload_upload();
req.corrupt = m_total_failed_bytes;
req.left = bytes_left(); req.left = bytes_left();
if (req.left == -1) req.left = 16*1024; if (req.left == -1) req.left = 16*1024;
// exclude redundant bytes if we should
if (!settings().report_true_downloaded)
req.downloaded -= m_total_redundant_bytes;
req.event = e; req.event = e;
error_code ec; error_code ec;
tcp::endpoint ep; tcp::endpoint ep;
@ -5327,10 +5333,16 @@ namespace libtorrent
// tell the tracker that we're back // tell the tracker that we're back
std::for_each(m_trackers.begin(), m_trackers.end() std::for_each(m_trackers.begin(), m_trackers.end()
, bind(&announce_entry::reset, _1)); , bind(&announce_entry::reset, _1));
m_stat.clear();
announce_with_tracker();
} }
// reset the stats, since from the tracker's
// point of view, this is a new session
m_total_failed_bytes = 0;
m_total_redundant_bytes = 0;
m_stat.clear();
announce_with_tracker();
// private torrents are never announced on LSD // private torrents are never announced on LSD
// or on DHT, we don't need this timer. // or on DHT, we don't need this timer.
if (!m_torrent_file->is_valid() if (!m_torrent_file->is_valid()