diff --git a/bindings/python/src/session_settings.cpp b/bindings/python/src/session_settings.cpp index bb6ece9ed..e53c155b8 100644 --- a/bindings/python/src/session_settings.cpp +++ b/bindings/python/src/session_settings.cpp @@ -133,6 +133,11 @@ void bind_session_settings() .def_readwrite("tick_interval", &session_settings::tick_interval) .def_readwrite("report_web_seed_downloads", &session_settings::report_web_seed_downloads) .def_readwrite("share_mode_target", &session_settings::share_mode_target) + .def_readwrite("rate_limit_utp", &session_settings::rate_limit_utp) + .def_readwrite("listen_queue_size", &session_settings::listen_queue_size) + .def_readwrite("announce_double_nat", &session_settings::announce_double_nat) + .def_readwrite("torrent_connect_boost", &session_settings::torrent_connect_boost) + .def_readwrite("seeding_outgoing_connections", &session_settings::seeding_outgoing_connections) ; enum_("proxy_type") diff --git a/docs/manual.rst b/docs/manual.rst index 4b7536b1f..cdb276e2b 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -4010,6 +4010,7 @@ session_settings bool announce_double_nat; int torrent_connect_boost; + bool seeding_outgoing_connections; }; ``version`` is automatically set to the libtorrent version you're using @@ -4818,6 +4819,13 @@ given to new torrents to accelerate them starting up. The normal connect schedul is run once every second, this allows peers to be connected immediately instead of waiting for the session tick to trigger connections. +``seeding_outgoing_connections`` determines if seeding (and finished) torrents +should attempt to make outgoing connections or not. By default this is true. It +may be set to false in very specific applications where the cost of making +outgoing connections is high, and there are no or small benefits of doing so. +For instance, if no nodes are behind a firewall or a NAT, seeds don't need to +make outgoing connections. + pe_settings =========== diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index 3c6a62266..f073cd772 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -253,6 +253,7 @@ namespace libtorrent , listen_queue_size(5) , announce_double_nat(false) , torrent_connect_boost(10) + , seeding_outgoing_connections(true) {} // libtorrent version. Used for forward binary compatibility @@ -1006,6 +1007,13 @@ namespace libtorrent // instead of waiting for the connection scheduler which // triggeres every second int torrent_connect_boost; + + // this controls whether or not seeding (and complete) torrents + // attempt to make outgoing connections or not. It defaults to + // true, but can be set to zero for specific applications where + // making outgoing connections is costly and known to not + // add any benefits + bool seeding_outgoing_connections; }; #ifndef TORRENT_DISABLE_DHT diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 0845f9f26..81db5ce32 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -347,6 +347,7 @@ namespace aux { TORRENT_SETTING(integer, listen_queue_size) TORRENT_SETTING(boolean, announce_double_nat) TORRENT_SETTING(integer, torrent_connect_boost) + TORRENT_SETTING(boolean, seeding_outgoing_connections) }; #undef TORRENT_SETTING diff --git a/src/torrent.cpp b/src/torrent.cpp index 3d8f77a37..776bbfe88 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -4752,7 +4752,10 @@ namespace libtorrent && m_state != torrent_status::queued_for_checking) || !valid_metadata()) && m_policy.num_connect_candidates() > 0 - && !m_abort; + && !m_abort + && (m_ses.settings().seeding_outgoing_connections + || m_state != torrent_status::seeding + || m_state != torrent_status::finished); } void torrent::disconnect_all(error_code const& ec)