forked from premiere/premiere-libtorrent
make tracker back-off configurable
This commit is contained in:
parent
4ef441f9ca
commit
418c1e8190
|
@ -1,6 +1,7 @@
|
|||
|
||||
0.16 release
|
||||
|
||||
* make tracker back-off configurable
|
||||
* don't restart the swarm after downloading metadata from magnet links
|
||||
* lower the default tracker retry intervals
|
||||
* support banning web seeds sending corrupt data
|
||||
|
|
|
@ -170,6 +170,8 @@ void bind_session_settings()
|
|||
.def_readwrite("enable_incoming_tcp", &session_settings::enable_incoming_tcp)
|
||||
.def_readwrite("enable_outgoing_utp", &session_settings::enable_outgoing_utp)
|
||||
.def_readwrite("enable_incoming_utp", &session_settings::enable_incoming_utp)
|
||||
.def_readwrite("ssl_listen", &session_settings::ssl_listen)
|
||||
.def_readwrite("tracker_backoff", &session_settings::tracker_backoff)
|
||||
;
|
||||
|
||||
enum_<proxy_settings::proxy_type>("proxy_type")
|
||||
|
|
|
@ -4299,6 +4299,8 @@ struct session_settings
|
|||
bool lock_files;
|
||||
|
||||
int ssl_listen;
|
||||
|
||||
int tracker_backoff;
|
||||
};
|
||||
</pre>
|
||||
<p><tt class="docutils literal"><span class="pre">version</span></tt> is automatically set to the libtorrent version you're using
|
||||
|
@ -5037,6 +5039,14 @@ no SSL listen port is opened. Otherwise a socket is opened on this port. This
|
|||
setting is only taken into account when opening the regular listen port, and
|
||||
won't re-open the listen socket simply by changing this setting.</p>
|
||||
<p>It defaults to port 4433.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">tracker_backoff</span></tt> determines how aggressively to back off from retrying
|
||||
failing trackers. This value determines <em>x</em> in the following formula, determining
|
||||
the number of seconds to wait until the next retry:</p>
|
||||
<blockquote>
|
||||
delay = 5 + 5 * x / 100 * fails^2</blockquote>
|
||||
<p>It defaults to 250.</p>
|
||||
<p>This setting may be useful to make libtorrent more or less aggressive in hitting
|
||||
trackers.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="pe-settings">
|
||||
|
@ -6248,7 +6258,7 @@ struct peer_disconnected_alert: peer_alert
|
|||
<div class="section" id="invalid-request-alert">
|
||||
<h2>invalid_request_alert</h2>
|
||||
<p>This is a debug alert that is generated by an incoming invalid piece request.
|
||||
<tt class="docutils literal"><span class="pre">Ïp</span></tt> is the address of the peer and the <tt class="docutils literal"><span class="pre">request</span></tt> is the actual incoming
|
||||
<tt class="docutils literal"><span class="pre">ìp</span></tt> is the address of the peer and the <tt class="docutils literal"><span class="pre">request</span></tt> is the actual incoming
|
||||
request from the peer.</p>
|
||||
<pre class="literal-block">
|
||||
struct invalid_request_alert: peer_alert
|
||||
|
@ -7835,13 +7845,13 @@ std::string error_code_to_string(boost::system::error_code const& ec)
|
|||
static const char const* swedish[] =
|
||||
{
|
||||
"inget fel",
|
||||
"en fil i torrenten kolliderar med en fil frÂn en annan torrent",
|
||||
"en fil i torrenten kolliderar med en fil från en annan torrent",
|
||||
"hash check misslyckades",
|
||||
"torrent filen ‰r inte en dictionary",
|
||||
"'info'-nyckeln saknas eller ‰r korrupt i torrentfilen",
|
||||
"'info'-f‰ltet ‰r inte en dictionary",
|
||||
"'piece length' f‰ltet saknas eller ‰r korrupt i torrentfilen",
|
||||
"torrentfilen saknar namnf‰ltet",
|
||||
"torrent filen är inte en dictionary",
|
||||
"'info'-nyckeln saknas eller är korrupt i torrentfilen",
|
||||
"'info'-fältet är inte en dictionary",
|
||||
"'piece length' fältet saknas eller är korrupt i torrentfilen",
|
||||
"torrentfilen saknar namnfältet",
|
||||
"ogiltigt namn i torrentfilen (kan vara en attack)",
|
||||
// ... more strings here
|
||||
};
|
||||
|
|
|
@ -4556,6 +4556,8 @@ session_settings
|
|||
bool lock_files;
|
||||
|
||||
int ssl_listen;
|
||||
|
||||
int tracker_backoff;
|
||||
};
|
||||
|
||||
``version`` is automatically set to the libtorrent version you're using
|
||||
|
@ -5442,6 +5444,17 @@ won't re-open the listen socket simply by changing this setting.
|
|||
|
||||
It defaults to port 4433.
|
||||
|
||||
``tracker_backoff`` determines how aggressively to back off from retrying
|
||||
failing trackers. This value determines *x* in the following formula, determining
|
||||
the number of seconds to wait until the next retry:
|
||||
|
||||
delay = 5 + 5 * x / 100 * fails^2
|
||||
|
||||
It defaults to 250.
|
||||
|
||||
This setting may be useful to make libtorrent more or less aggressive in hitting
|
||||
trackers.
|
||||
|
||||
pe_settings
|
||||
===========
|
||||
|
||||
|
|
|
@ -919,6 +919,14 @@ namespace libtorrent
|
|||
|
||||
// open an ssl listen socket for ssl torrents on this port
|
||||
int ssl_listen;
|
||||
|
||||
// this is the factor X in the formula to calculate the
|
||||
// next tracker timeout:
|
||||
// delay = 5 + X/100 * fails^2
|
||||
// so, it's an exponential back-off, and this factor
|
||||
// determines how fast the back-off happens. Default
|
||||
// is 250
|
||||
int tracker_backoff;
|
||||
};
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
|
|
@ -63,6 +63,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
namespace libtorrent
|
||||
{
|
||||
class peer_connection;
|
||||
struct session_settings;
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -144,7 +145,7 @@ namespace libtorrent
|
|||
min_announce = min_time();
|
||||
}
|
||||
|
||||
void failed(int retry_interval = 0);
|
||||
void failed(session_settings const& sett, int retry_interval = 0);
|
||||
|
||||
bool will_announce(ptime now) const
|
||||
{
|
||||
|
|
|
@ -1276,6 +1276,7 @@ namespace libtorrent
|
|||
, use_disk_read_ahead(true)
|
||||
, lock_files(false)
|
||||
, ssl_listen(4433)
|
||||
, tracker_backoff(250)
|
||||
{}
|
||||
|
||||
session_settings::~session_settings() {}
|
||||
|
|
|
@ -441,6 +441,8 @@ namespace aux {
|
|||
TORRENT_SETTING(integer, read_job_every)
|
||||
TORRENT_SETTING(boolean, use_disk_read_ahead)
|
||||
TORRENT_SETTING(boolean, lock_files)
|
||||
TORRENT_SETTING(integer, ssl_listen)
|
||||
TORRENT_SETTING(integer, tracker_backoff)
|
||||
};
|
||||
|
||||
#undef TORRENT_SETTING
|
||||
|
|
|
@ -8454,7 +8454,7 @@ namespace libtorrent
|
|||
announce_entry* ae = find_tracker(r);
|
||||
if (ae)
|
||||
{
|
||||
ae->failed(retry_interval);
|
||||
ae->failed(settings(), retry_interval);
|
||||
ae->last_error = ec;
|
||||
ae->message = msg;
|
||||
int tracker_index = ae - &m_trackers[0];
|
||||
|
|
|
@ -64,6 +64,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/utf8.hpp"
|
||||
#include "libtorrent/time.hpp"
|
||||
#include "libtorrent/invariant_check.hpp"
|
||||
#include "libtorrent/session_settings.hpp"
|
||||
|
||||
#if TORRENT_USE_I2P
|
||||
#include "libtorrent/parse_url.hpp"
|
||||
|
@ -470,13 +471,15 @@ namespace libtorrent
|
|||
int announce_entry::min_announce_in() const
|
||||
{ return total_seconds(min_announce - time_now()); }
|
||||
|
||||
void announce_entry::failed(int retry_interval)
|
||||
void announce_entry::failed(session_settings const& sett, int retry_interval)
|
||||
{
|
||||
++fails;
|
||||
// the exponential back-off ends up being:
|
||||
// 7, 15, 27, 45, 95, 127, 165, ... seconds
|
||||
// with the default tracker_backoff of 250
|
||||
int delay = (std::min)(tracker_retry_delay_min + int(fails) * int(fails)
|
||||
* tracker_retry_delay_min / 2, int(tracker_retry_delay_max));
|
||||
* tracker_retry_delay_min * sett.tracker_backoff / 100
|
||||
, int(tracker_retry_delay_max));
|
||||
delay = (std::max)(delay, retry_interval);
|
||||
next_announce = time_now() + seconds(delay);
|
||||
updating = false;
|
||||
|
|
|
@ -400,9 +400,11 @@ int test_main()
|
|||
// on failing announces
|
||||
announce_entry ae("dummy");
|
||||
int last = 0;
|
||||
session_settings sett;
|
||||
sett.tracker_backoff = 250;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
ae.failed(5);
|
||||
ae.failed(sett, 5);
|
||||
int delay = ae.next_announce_in();
|
||||
TEST_CHECK(delay > last);
|
||||
last = delay;
|
||||
|
|
Loading…
Reference in New Issue