diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 25d80effb..b54d4d0bf 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -161,6 +161,8 @@ namespace libtorrent boost::uint32_t key; int num_want; + + address_v4 ipv4; #if TORRENT_USE_IPV6 address_v6 ipv6; #endif diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index e13d6b40f..21700a9fa 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -183,6 +183,17 @@ namespace libtorrent } } + if (tracker_req().ipv4 != address_v4() && !i2p) + { + error_code err; + std::string const ip = tracker_req().ipv4.to_string(err); + if (!err) + { + url += "&ipv4="; + url += escape_string(ip.c_str(), ip.size()); + } + } + #if TORRENT_USE_IPV6 if (tracker_req().ipv6 != address_v6() && !i2p) { diff --git a/src/torrent.cpp b/src/torrent.cpp index fc6f18aef..3f343ec5e 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3246,17 +3246,19 @@ namespace { req.event = e; -#if TORRENT_USE_IPV6 - // since sending our IPv6 address to the tracker may be sensitive. Only + // since sending our IPv4/v6 address to the tracker may be sensitive. Only // do that if we're not in anonymous mode and if it's a private torrent if (!settings().get_bool(settings_pack::anonymous_mode) && m_torrent_file && m_torrent_file->priv()) { - boost::optional ep = m_ses.get_ipv6_interface(); - if (ep) req.ipv6 = ep->address().to_v6(); - } + boost::optional ep4 = m_ses.get_ipv4_interface(); + if (ep4) req.ipv4 = ep4->address().to_v4(); +#if TORRENT_USE_IPV6 + boost::optional ep6 = m_ses.get_ipv6_interface(); + if (ep6) req.ipv6 = ep6->address().to_v6(); #endif + } // if we are aborting. we don't want any new peers req.num_want = (req.event == tracker_request::stopped)