remove pointless DHT extension (for IPv6)

This commit is contained in:
Arvid Norberg 2014-10-01 16:21:29 +00:00
parent ba3ffe52f8
commit 0ed0bdc50c
1 changed files with 2 additions and 24 deletions

View File

@ -561,40 +561,18 @@ namespace detail
{ {
void TORRENT_EXTRA_EXPORT write_nodes_entry(entry& r, nodes_t const& nodes) void TORRENT_EXTRA_EXPORT write_nodes_entry(entry& r, nodes_t const& nodes)
{ {
bool ipv6_nodes = false;
entry& n = r["nodes"]; entry& n = r["nodes"];
std::back_insert_iterator<std::string> out(n.string()); std::back_insert_iterator<std::string> out(n.string());
for (nodes_t::const_iterator i = nodes.begin() for (nodes_t::const_iterator i = nodes.begin()
, end(nodes.end()); i != end; ++i) , end(nodes.end()); i != end; ++i)
{ {
if (!i->addr().is_v4()) if (!i->addr().is_v4()) continue;
{
ipv6_nodes = true;
continue;
}
std::copy(i->id.begin(), i->id.end(), out); std::copy(i->id.begin(), i->id.end(), out);
write_endpoint(udp::endpoint(i->addr(), i->port()), out); write_endpoint(udp::endpoint(i->addr(), i->port()), out);
} }
if (ipv6_nodes)
{
entry& p = r["nodes2"];
std::string endpoint;
for (nodes_t::const_iterator i = nodes.begin()
, end(nodes.end()); i != end; ++i)
{
if (!i->addr().is_v6()) continue;
endpoint.resize(18 + 20);
std::string::iterator out = endpoint.begin();
std::copy(i->id.begin(), i->id.end(), out);
out += 20;
write_endpoint(udp::endpoint(i->addr(), i->port()), out);
endpoint.resize(out - endpoint.begin());
p.list().push_back(entry(endpoint));
}
}
} }
} }
using detail::write_nodes_entry; using detail::write_nodes_entry;
// verifies that a message has all the required // verifies that a message has all the required