diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index a4ea45eb3..47e6941b5 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -321,9 +321,6 @@ namespace aux { // need the initial push to connect peers void prioritize_connections(std::weak_ptr t) override; - tcp::endpoint get_ipv6_interface() const override; - tcp::endpoint get_ipv4_interface() const override; - void async_accept(std::shared_ptr const& listener, transport ssl); void on_accept_connection(std::shared_ptr const& s , std::weak_ptr listener, error_code const& e, transport ssl); diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index 902f30a39..56c66ff46 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -222,9 +222,6 @@ namespace libtorrent { namespace aux { virtual void prioritize_connections(std::weak_ptr 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 pack) = 0; diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 9791da2c1..b382d9a21 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -149,7 +149,7 @@ namespace libtorrent { std::uint32_t key; int num_want; #if TORRENT_USE_IPV6 - address_v6 ipv6; + std::vector ipv6; #endif sha1_hash info_hash; peer_id pid; diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 7581cbbf1..a3e0a16b6 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -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); } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index b6f36b482..b3283ab4c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -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 session_impl::setup_listener(std::string const& device , tcp::endpoint bind_ep, transport const ssl, error_code& ec) { diff --git a/src/torrent.cpp b/src/torrent.cpp index b7ee5a04c..2022bc885 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -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