forked from premiere/premiere-libtorrent
select which DHT port to report based on the connection's local endpoint (#2316)
This commit is contained in:
parent
55228756e5
commit
df8a57efb7
|
@ -600,14 +600,7 @@ namespace aux {
|
|||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
bool is_dht_running() const { return (m_dht.get() != nullptr); }
|
||||
int external_udp_port() const override
|
||||
{
|
||||
for (auto const& s : m_listen_sockets)
|
||||
{
|
||||
if (s->udp_sock) return s->udp_external_port;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
int external_udp_port(address const& local_address) const override;
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_I2P
|
||||
|
|
|
@ -300,7 +300,7 @@ namespace libtorrent { namespace aux {
|
|||
virtual bool announce_dht() const = 0;
|
||||
virtual void add_dht_node(udp::endpoint const& n) = 0;
|
||||
virtual bool has_dht() const = 0;
|
||||
virtual int external_udp_port() const = 0;
|
||||
virtual int external_udp_port(address const& local_address) const = 0;
|
||||
virtual dht::dht_tracker* dht() = 0;
|
||||
virtual void prioritize_dht(std::weak_ptr<torrent> t) = 0;
|
||||
#endif
|
||||
|
|
|
@ -333,7 +333,7 @@ namespace {
|
|||
#ifndef TORRENT_DISABLE_DHT
|
||||
if (m_supports_dht_port && m_ses.has_dht())
|
||||
{
|
||||
int const port = m_ses.external_udp_port();
|
||||
int const port = m_ses.external_udp_port(local_endpoint().address());
|
||||
if (port >= 0) write_dht_port(port);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2151,6 +2151,22 @@ namespace {
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
int session_impl::external_udp_port(address const& local_address) const
|
||||
{
|
||||
auto ls = std::find_if(m_listen_sockets.begin(), m_listen_sockets.end()
|
||||
, [&](std::shared_ptr<listen_socket_t> const& e)
|
||||
{
|
||||
return e->local_endpoint.address() == local_address;
|
||||
});
|
||||
|
||||
if (ls != m_listen_sockets.end())
|
||||
return (*ls)->udp_external_port;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_I2P
|
||||
|
||||
proxy_settings session_impl::i2p_proxy() const
|
||||
|
|
Loading…
Reference in New Issue