diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index 47cfdd651..a8b2091f6 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -238,6 +238,10 @@ namespace libtorrent // the number of seconds between chokes/unchokes int unchoke_interval; + // if this is set, this IP will be reported do the + // tracker in the ip= parameter. + address announce_ip; + #ifndef TORRENT_DISABLE_DHT // while this is true, the dht will note be used unless the // tracker is online diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index cc039f198..936f8292a 100755 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -411,6 +411,12 @@ namespace libtorrent std::min(req.num_want, 999)); m_send_buffer += '&'; } + if (m_settings.announce_ip != address() && !url_has_argument(request, "ip")) + { + m_send_buffer += "ip="; + m_send_buffer += m_settings.announce_ip.to_string(); + m_send_buffer += '&'; + } #ifndef TORRENT_DISABLE_ENCRYPTION m_send_buffer += "supportcrypto=1&"; diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index d992ca050..d08abd359 100755 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -307,7 +307,10 @@ namespace libtorrent // event detail::write_int32(req.event, out); // ip address - detail::write_int32(0, out); + if (m_settings.announce_ip != address() && m_settings.announce_ip.is_v4()) + detail::write_uint32(m_settings.announce_ip.to_v4().to_ulong(), out); + else + detail::write_int32(0, out); // key detail::write_int32(req.key, out); // num_want