remove the last use of session_impl get_ipv6_interface and get_ipv4_interface

This commit is contained in:
arvidn 2017-08-23 08:45:48 +02:00 committed by Arvid Norberg
parent 1290e6f5af
commit e92cbf502c
6 changed files with 15 additions and 39 deletions

View File

@ -321,9 +321,6 @@ namespace aux {
// need the initial push to connect peers
void prioritize_connections(std::weak_ptr<torrent> t) override;
tcp::endpoint get_ipv6_interface() const override;
tcp::endpoint get_ipv4_interface() const override;
void async_accept(std::shared_ptr<tcp::acceptor> const& listener, transport ssl);
void on_accept_connection(std::shared_ptr<socket_type> const& s
, std::weak_ptr<tcp::acceptor> listener, error_code const& e, transport ssl);

View File

@ -222,9 +222,6 @@ namespace libtorrent { namespace aux {
virtual void prioritize_connections(std::weak_ptr<torrent> t) = 0;
virtual tcp::endpoint get_ipv4_interface() const = 0;
virtual tcp::endpoint get_ipv6_interface() const = 0;
virtual void trigger_auto_manage() = 0;
virtual void apply_settings_pack(std::shared_ptr<settings_pack> pack) = 0;

View File

@ -149,7 +149,7 @@ namespace libtorrent {
std::uint32_t key;
int num_want;
#if TORRENT_USE_IPV6
address_v6 ipv6;
std::vector<address_v6> ipv6;
#endif
sha1_hash info_hash;
peer_id pid;

View File

@ -181,12 +181,13 @@ namespace libtorrent {
}
#if TORRENT_USE_IPV6
if (tracker_req().ipv6 != address_v6() && !i2p)
if (!tracker_req().ipv6.empty() && !i2p)
{
error_code err;
std::string const ip = tracker_req().ipv6.to_string(err);
if (!err)
for (auto const& v6 : tracker_req().ipv6)
{
error_code err;
std::string const ip = v6.to_string(err);
if (err) continue;
url += "&ipv6=";
url += escape_string(ip);
}

View File

@ -1444,31 +1444,6 @@ namespace {
reopen_outgoing_sockets();
}
// TODO: 3 try to remove these functions. They are misleading and not very
// useful. Anything using these should probably be fixed to do something more
// multi-homed friendly
tcp::endpoint session_impl::get_ipv6_interface() const
{
#if TORRENT_USE_IPV6
for (auto const& i : m_listen_sockets)
{
if (!i->local_endpoint.address().is_v6()) continue;
return tcp::endpoint(i->local_endpoint.address(), std::uint16_t(i->tcp_external_port));
}
#endif
return tcp::endpoint();
}
tcp::endpoint session_impl::get_ipv4_interface() const
{
for (auto const& i : m_listen_sockets)
{
if (!i->local_endpoint.address().is_v4()) continue;
return tcp::endpoint(i->local_endpoint.address(), std::uint16_t(i->tcp_external_port));
}
return tcp::endpoint();
}
std::shared_ptr<listen_socket_t> session_impl::setup_listener(std::string const& device
, tcp::endpoint bind_ep, transport const ssl, error_code& ec)
{

View File

@ -2744,9 +2744,15 @@ namespace libtorrent {
&& m_torrent_file
&& m_torrent_file->priv())
{
tcp::endpoint ep;
ep = m_ses.get_ipv6_interface();
if (ep != tcp::endpoint()) req.ipv6 = ep.address().to_v6();
m_ses.for_each_listen_socket([&](aux::listen_socket_handle const& s)
{
if (s.is_ssl() != is_ssl_torrent())
return;
if (!s.get_local_endpoint().address().is_v6())
return;
req.ipv6.push_back(s.get_local_endpoint().address().to_v6());
});
}
#endif