deprecate and remvoe broadcast_lsd setting
This commit is contained in:
parent
fa79697f45
commit
df85b31490
|
@ -1,3 +1,4 @@
|
||||||
|
* deprecate broadcast_lsd setting. Just use multicast
|
||||||
* deprecate upnp_ignore_nonrouters setting
|
* deprecate upnp_ignore_nonrouters setting
|
||||||
* don't attempt sending event=stopped if event=start never succeeded
|
* don't attempt sending event=stopped if event=start never succeeded
|
||||||
* make sure &key= stays consistent between different source IPs (as mandated by BEP7)
|
* make sure &key= stays consistent between different source IPs (as mandated by BEP7)
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace libtorrent {
|
||||||
struct plugin;
|
struct plugin;
|
||||||
struct upnp;
|
struct upnp;
|
||||||
struct natpmp;
|
struct natpmp;
|
||||||
class lsd;
|
struct lsd;
|
||||||
class torrent;
|
class torrent;
|
||||||
class alert;
|
class alert;
|
||||||
struct torrent_handle;
|
struct torrent_handle;
|
||||||
|
@ -642,7 +642,7 @@ namespace aux {
|
||||||
|
|
||||||
torrent_handle find_torrent_handle(sha1_hash const& info_hash);
|
torrent_handle find_torrent_handle(sha1_hash const& info_hash);
|
||||||
|
|
||||||
void announce_lsd(sha1_hash const& ih, int port, bool broadcast = false) override;
|
void announce_lsd(sha1_hash const& ih, int port) override;
|
||||||
|
|
||||||
void save_state(entry* e, save_state_flags_t flags) const;
|
void save_state(entry* e, save_state_flags_t flags) const;
|
||||||
void load_state(bdecode_node const* e, save_state_flags_t flags);
|
void load_state(bdecode_node const* e, save_state_flags_t flags);
|
||||||
|
|
|
@ -288,7 +288,7 @@ namespace aux {
|
||||||
virtual aux::vector<torrent*>& torrent_list(torrent_list_index_t i) = 0;
|
virtual aux::vector<torrent*>& torrent_list(torrent_list_index_t i) = 0;
|
||||||
|
|
||||||
virtual bool has_lsd() const = 0;
|
virtual bool has_lsd() const = 0;
|
||||||
virtual void announce_lsd(sha1_hash const& ih, int port, bool broadcast = false) = 0;
|
virtual void announce_lsd(sha1_hash const& ih, int port) = 0;
|
||||||
virtual libtorrent::utp_socket_manager* utp_socket_manager() = 0;
|
virtual libtorrent::utp_socket_manager* utp_socket_manager() = 0;
|
||||||
virtual void inc_boost_connections() = 0;
|
virtual void inc_boost_connections() = 0;
|
||||||
virtual std::vector<block_info>& block_info_storage() = 0;
|
virtual std::vector<block_info>& block_info_storage() = 0;
|
||||||
|
|
|
@ -41,15 +41,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
class lsd : public std::enable_shared_from_this<lsd>
|
struct lsd : std::enable_shared_from_this<lsd>
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
lsd(io_service& ios, aux::lsd_callback& cb);
|
lsd(io_service& ios, aux::lsd_callback& cb);
|
||||||
~lsd();
|
~lsd();
|
||||||
|
|
||||||
void start(error_code& ec);
|
void start(error_code& ec);
|
||||||
|
|
||||||
void announce(sha1_hash const& ih, int listen_port, bool broadcast = false);
|
void announce(sha1_hash const& ih, int listen_port);
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -57,7 +56,7 @@ private:
|
||||||
std::shared_ptr<lsd> self() { return shared_from_this(); }
|
std::shared_ptr<lsd> self() { return shared_from_this(); }
|
||||||
|
|
||||||
void announce_impl(sha1_hash const& ih, int listen_port
|
void announce_impl(sha1_hash const& ih, int listen_port
|
||||||
, bool broadcast, int retry_count);
|
, int retry_count);
|
||||||
void resend_announce(error_code const& e, sha1_hash const& ih
|
void resend_announce(error_code const& e, sha1_hash const& ih
|
||||||
, int listen_port, int retry_count);
|
, int listen_port, int retry_count);
|
||||||
void on_announce(udp::endpoint const& from, span<char const> buffer);
|
void on_announce(udp::endpoint const& from, span<char const> buffer);
|
||||||
|
@ -84,8 +83,8 @@ private:
|
||||||
// as a peer
|
// as a peer
|
||||||
int m_cookie;
|
int m_cookie;
|
||||||
|
|
||||||
bool m_disabled;
|
bool m_disabled = false;
|
||||||
bool m_disabled6;
|
bool m_disabled6 = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,13 +490,17 @@ namespace aux {
|
||||||
// requested from another peer already.
|
// requested from another peer already.
|
||||||
strict_end_game_mode,
|
strict_end_game_mode,
|
||||||
|
|
||||||
|
#if TORRENT_ABI_VERSION == 1
|
||||||
// if ``broadcast_lsd`` is set to true, the local peer discovery (or
|
// if ``broadcast_lsd`` is set to true, the local peer discovery (or
|
||||||
// Local Service Discovery) will not only use IP multicast, but also
|
// Local Service Discovery) will not only use IP multicast, but also
|
||||||
// broadcast its messages. This can be useful when running on networks
|
// broadcast its messages. This can be useful when running on networks
|
||||||
// that don't support multicast. Since broadcast messages might be
|
// that don't support multicast. Since broadcast messages might be
|
||||||
// expensive and disruptive on networks, only every 8th announce uses
|
// expensive and disruptive on networks, only every 8th announce uses
|
||||||
// broadcast.
|
// broadcast.
|
||||||
broadcast_lsd,
|
broadcast_lsd TORRENT_DEPRECATED_ENUM,
|
||||||
|
#else
|
||||||
|
deprecated_broadcast_lsd,
|
||||||
|
#endif
|
||||||
|
|
||||||
// when set to true, libtorrent will try to make outgoing utp
|
// when set to true, libtorrent will try to make outgoing utp
|
||||||
// connections controls whether libtorrent will accept incoming
|
// connections controls whether libtorrent will accept incoming
|
||||||
|
|
|
@ -1590,9 +1590,7 @@ namespace libtorrent {
|
||||||
// the number of unchoked peers in this torrent
|
// the number of unchoked peers in this torrent
|
||||||
unsigned int m_num_uploads:24;
|
unsigned int m_num_uploads:24;
|
||||||
|
|
||||||
// rotating sequence number for LSD announces sent out.
|
// 3 unused bits
|
||||||
// used to only use IP broadcast for every 8th lsd announce
|
|
||||||
std::uint8_t m_lsd_seq:3;
|
|
||||||
|
|
||||||
// when this is true, this torrent supports peer exchange
|
// when this is true, this torrent supports peer exchange
|
||||||
bool m_enable_pex:1;
|
bool m_enable_pex:1;
|
||||||
|
|
|
@ -210,8 +210,6 @@ namespace libtorrent {
|
||||||
std::shared_ptr<udp::socket> s = std::make_shared<udp::socket>(ios);
|
std::shared_ptr<udp::socket> s = std::make_shared<udp::socket>(ios);
|
||||||
s->open(addr.is_v4() ? udp::v4() : udp::v6(), ec);
|
s->open(addr.is_v4() ? udp::v4() : udp::v6(), ec);
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
s->bind(udp::endpoint(addr, 0), ec);
|
|
||||||
if (ec) return;
|
|
||||||
|
|
||||||
m_unicast_sockets.emplace_back(s, mask);
|
m_unicast_sockets.emplace_back(s, mask);
|
||||||
socket_entry& se = m_unicast_sockets.back();
|
socket_entry& se = m_unicast_sockets.back();
|
||||||
|
|
14
src/lsd.cpp
14
src/lsd.cpp
|
@ -72,8 +72,6 @@ lsd::lsd(io_service& ios, aux::lsd_callback& cb)
|
||||||
, m_socket6(udp::endpoint(make_address_v6("ff15::efc0:988f", dummy), 6771))
|
, m_socket6(udp::endpoint(make_address_v6("ff15::efc0:988f", dummy), 6771))
|
||||||
, m_broadcast_timer(ios)
|
, m_broadcast_timer(ios)
|
||||||
, m_cookie((random(0x7fffffff) ^ std::uintptr_t(this)) & 0x7fffffff)
|
, m_cookie((random(0x7fffffff) ^ std::uintptr_t(this)) & 0x7fffffff)
|
||||||
, m_disabled(false)
|
|
||||||
, m_disabled6(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,13 +107,13 @@ void lsd::start(error_code& ec)
|
||||||
|
|
||||||
lsd::~lsd() = default;
|
lsd::~lsd() = default;
|
||||||
|
|
||||||
void lsd::announce(sha1_hash const& ih, int listen_port, bool broadcast)
|
void lsd::announce(sha1_hash const& ih, int listen_port)
|
||||||
{
|
{
|
||||||
announce_impl(ih, listen_port, broadcast, 0);
|
announce_impl(ih, listen_port, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lsd::announce_impl(sha1_hash const& ih, int const listen_port
|
void lsd::announce_impl(sha1_hash const& ih, int const listen_port
|
||||||
, bool const broadcast, int retry_count)
|
, int retry_count)
|
||||||
{
|
{
|
||||||
if (m_disabled && m_disabled6) return;
|
if (m_disabled && m_disabled6) return;
|
||||||
|
|
||||||
|
@ -130,7 +128,7 @@ void lsd::announce_impl(sha1_hash const& ih, int const listen_port
|
||||||
{
|
{
|
||||||
int const msg_len = render_lsd_packet(msg, sizeof(msg), listen_port, aux::to_hex(ih).c_str()
|
int const msg_len = render_lsd_packet(msg, sizeof(msg), listen_port, aux::to_hex(ih).c_str()
|
||||||
, m_cookie, "239.192.152.143");
|
, m_cookie, "239.192.152.143");
|
||||||
m_socket.send(msg, msg_len, ec, broadcast ? broadcast_socket::flag_broadcast : 0);
|
m_socket.send(msg, msg_len, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
m_disabled = true;
|
m_disabled = true;
|
||||||
|
@ -148,7 +146,7 @@ void lsd::announce_impl(sha1_hash const& ih, int const listen_port
|
||||||
{
|
{
|
||||||
int const msg_len = render_lsd_packet(msg, sizeof(msg), listen_port, aux::to_hex(ih).c_str()
|
int const msg_len = render_lsd_packet(msg, sizeof(msg), listen_port, aux::to_hex(ih).c_str()
|
||||||
, m_cookie, "[ff15::efc0:988f]");
|
, m_cookie, "[ff15::efc0:988f]");
|
||||||
m_socket6.send(msg, msg_len, ec, broadcast ? broadcast_socket::flag_broadcast : 0);
|
m_socket6.send(msg, msg_len, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
m_disabled6 = true;
|
m_disabled6 = true;
|
||||||
|
@ -179,7 +177,7 @@ void lsd::resend_announce(error_code const& e, sha1_hash const& info_hash
|
||||||
COMPLETE_ASYNC("lsd::resend_announce");
|
COMPLETE_ASYNC("lsd::resend_announce");
|
||||||
if (e) return;
|
if (e) return;
|
||||||
|
|
||||||
announce_impl(info_hash, listen_port, false, retry_count);
|
announce_impl(info_hash, listen_port, retry_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lsd::on_announce(udp::endpoint const& from, span<char const> buf)
|
void lsd::on_announce(udp::endpoint const& from, span<char const> buf)
|
||||||
|
|
|
@ -5475,11 +5475,11 @@ namespace aux {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_impl::announce_lsd(sha1_hash const& ih, int port, bool broadcast)
|
void session_impl::announce_lsd(sha1_hash const& ih, int port)
|
||||||
{
|
{
|
||||||
// use internal listen port for local peers
|
// use internal listen port for local peers
|
||||||
if (m_lsd)
|
if (m_lsd)
|
||||||
m_lsd->announce(ih, port, broadcast);
|
m_lsd->announce(ih, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_impl::on_lsd_peer(tcp::endpoint const& peer, sha1_hash const& ih)
|
void session_impl::on_lsd_peer(tcp::endpoint const& peer, sha1_hash const& ih)
|
||||||
|
|
|
@ -170,7 +170,7 @@ constexpr int CLOSE_FILE_INTERVAL = 0;
|
||||||
SET(incoming_starts_queued_torrents, false, nullptr),
|
SET(incoming_starts_queued_torrents, false, nullptr),
|
||||||
SET(report_true_downloaded, false, nullptr),
|
SET(report_true_downloaded, false, nullptr),
|
||||||
SET(strict_end_game_mode, true, nullptr),
|
SET(strict_end_game_mode, true, nullptr),
|
||||||
SET(broadcast_lsd, true, nullptr),
|
DEPRECATED_SET(broadcast_lsd, true, nullptr),
|
||||||
SET(enable_outgoing_utp, true, nullptr),
|
SET(enable_outgoing_utp, true, nullptr),
|
||||||
SET(enable_incoming_utp, true, nullptr),
|
SET(enable_incoming_utp, true, nullptr),
|
||||||
SET(enable_outgoing_tcp, true, nullptr),
|
SET(enable_outgoing_tcp, true, nullptr),
|
||||||
|
|
|
@ -208,7 +208,6 @@ bool is_downloading_state(int const st)
|
||||||
, m_max_uploads((1 << 24) - 1)
|
, m_max_uploads((1 << 24) - 1)
|
||||||
, m_save_resume_flags()
|
, m_save_resume_flags()
|
||||||
, m_num_uploads(0)
|
, m_num_uploads(0)
|
||||||
, m_lsd_seq(0)
|
|
||||||
, m_enable_pex(!bool(p.flags & torrent_flags::disable_pex))
|
, m_enable_pex(!bool(p.flags & torrent_flags::disable_pex))
|
||||||
, m_magnet_link(false)
|
, m_magnet_link(false)
|
||||||
, m_apply_ip_filter(p.flags & torrent_flags::apply_ip_filter)
|
, m_apply_ip_filter(p.flags & torrent_flags::apply_ip_filter)
|
||||||
|
@ -2603,9 +2602,7 @@ bool is_downloading_state(int const st)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// announce with the local discovery service
|
// announce with the local discovery service
|
||||||
m_ses.announce_lsd(m_torrent_file->info_hash(), port
|
m_ses.announce_lsd(m_torrent_file->info_hash(), port);
|
||||||
, settings().get_bool(settings_pack::broadcast_lsd) && m_lsd_seq == 0);
|
|
||||||
++m_lsd_seq;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
|
|
@ -54,6 +54,7 @@ void test_lsd()
|
||||||
|
|
||||||
settings_pack pack;
|
settings_pack pack;
|
||||||
pack.set_bool(settings_pack::allow_multiple_connections_per_ip, true);
|
pack.set_bool(settings_pack::allow_multiple_connections_per_ip, true);
|
||||||
|
pack.set_int(settings_pack::alert_mask, alert::error_notification | alert::session_log_notification | alert::status_notification);
|
||||||
pack.set_bool(settings_pack::enable_dht, false);
|
pack.set_bool(settings_pack::enable_dht, false);
|
||||||
pack.set_bool(settings_pack::enable_lsd, true);
|
pack.set_bool(settings_pack::enable_lsd, true);
|
||||||
pack.set_bool(settings_pack::enable_upnp, false);
|
pack.set_bool(settings_pack::enable_upnp, false);
|
||||||
|
|
Loading…
Reference in New Issue