forked from premiere/premiere-libtorrent
send implied_port in dht announce messages when uTP is enabled
This commit is contained in:
parent
4ac670de5c
commit
fec7407461
|
@ -89,7 +89,8 @@ namespace libtorrent { namespace dht
|
|||
|
||||
entry state() const;
|
||||
|
||||
void announce(sha1_hash const& ih, int listen_port, bool seed
|
||||
enum flags_t { flag_seed = 1, flag_implied_port = 2 };
|
||||
void announce(sha1_hash const& ih, int listen_port, int flags
|
||||
, boost::function<void(std::vector<tcp::endpoint> const&)> f);
|
||||
|
||||
void dht_status(session_status& s);
|
||||
|
|
|
@ -232,7 +232,8 @@ public:
|
|||
{ m_table.print_state(os); }
|
||||
#endif
|
||||
|
||||
void announce(sha1_hash const& info_hash, int listen_port, bool seed
|
||||
enum flags_t { flag_seed = 1, flag_implied_port = 2 };
|
||||
void announce(sha1_hash const& info_hash, int listen_port, int flags
|
||||
, boost::function<void(std::vector<tcp::endpoint> const&)> f);
|
||||
|
||||
void get_item(sha1_hash const& target, boost::function<bool(item&)> f);
|
||||
|
|
|
@ -416,10 +416,10 @@ namespace libtorrent { namespace dht
|
|||
#endif
|
||||
}
|
||||
|
||||
void dht_tracker::announce(sha1_hash const& ih, int listen_port, bool seed
|
||||
void dht_tracker::announce(sha1_hash const& ih, int listen_port, int flags
|
||||
, boost::function<void(std::vector<tcp::endpoint> const&)> f)
|
||||
{
|
||||
m_dht.announce(ih, listen_port, seed, f);
|
||||
m_dht.announce(ih, listen_port, flags, f);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -294,7 +294,7 @@ void node_impl::incoming(msg const& m)
|
|||
namespace
|
||||
{
|
||||
void announce_fun(std::vector<std::pair<node_entry, std::string> > const& v
|
||||
, node_impl& node, int listen_port, sha1_hash const& ih, bool seed)
|
||||
, node_impl& node, int listen_port, sha1_hash const& ih, int flags)
|
||||
{
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(node) << "sending announce_peer [ ih: " << ih
|
||||
|
@ -327,8 +327,8 @@ namespace
|
|||
a["info_hash"] = ih.to_string();
|
||||
a["port"] = listen_port;
|
||||
a["token"] = i->second;
|
||||
a["seed"] = int(seed);
|
||||
// TODO: 3 if uTP is enabled, we should say "implied_port": 1
|
||||
a["seed"] = (flags & node_impl::flag_seed) ? 1 : 0;
|
||||
if (flags & node_impl::flag_implied_port) a["implied_port"] = 1;
|
||||
node.m_rpc.invoke(e, i->first.ep(), o);
|
||||
}
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ void node_impl::add_node(udp::endpoint node)
|
|||
m_rpc.invoke(e, node, o);
|
||||
}
|
||||
|
||||
void node_impl::announce(sha1_hash const& info_hash, int listen_port, bool seed
|
||||
void node_impl::announce(sha1_hash const& info_hash, int listen_port, int flags
|
||||
, boost::function<void(std::vector<tcp::endpoint> const&)> f)
|
||||
{
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
|
@ -378,13 +378,13 @@ void node_impl::announce(sha1_hash const& info_hash, int listen_port, bool seed
|
|||
{
|
||||
ta.reset(new obfuscated_get_peers(*this, info_hash, f
|
||||
, boost::bind(&announce_fun, _1, boost::ref(*this)
|
||||
, listen_port, info_hash, seed), seed));
|
||||
, listen_port, info_hash, flags), flags & node_impl::flag_seed));
|
||||
}
|
||||
else
|
||||
{
|
||||
ta.reset(new get_peers(*this, info_hash, f
|
||||
, boost::bind(&announce_fun, _1, boost::ref(*this)
|
||||
, listen_port, info_hash, seed), seed));
|
||||
, listen_port, info_hash, flags), flags & node_impl::flag_seed));
|
||||
}
|
||||
|
||||
ta->start();
|
||||
|
|
|
@ -2139,8 +2139,17 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
boost::weak_ptr<torrent> self(shared_from_this());
|
||||
|
||||
// if we're a seed, we tell the DHT for better scrape stats
|
||||
int flags = is_seed() ? dht::dht_tracker::flag_seed : 0;
|
||||
// if we allow incoming uTP connections, set the implied_port
|
||||
// argument in the announce, this will make the DHT node use
|
||||
// our source port in the packet as our listen port, which is
|
||||
// likely more accurate when behind a NAT
|
||||
if (settings().enable_incoming_utp) flags |= dht::dht_tracker::flag_implied_port;
|
||||
|
||||
m_ses.m_dht->announce(m_torrent_file->info_hash()
|
||||
, port, is_seed()
|
||||
, port, flags
|
||||
, boost::bind(&torrent::on_dht_announce_response_disp, self, _1));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue