support for ip address in announce

This commit is contained in:
Arvid Norberg 2007-06-13 00:20:06 +00:00
parent b75a69cd47
commit 5b5f3b3ca2
3 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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&";

View File

@ -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