fixes from review

This commit is contained in:
Steven Siloti 2017-04-23 15:23:46 -07:00 committed by Arvid Norberg
parent cdd50be859
commit bcfaf9621a
3 changed files with 14 additions and 5 deletions

View File

@ -65,7 +65,14 @@ void bootstrap_session(std::vector<dht_network*> networks, lt::session& ses)
// bootstrap off of 8 of the nodes
auto router_nodes = dht->router_nodes();
lt::entry::list_type& nodes = state["dht state"]["nodes"].list();
char const* nodes_key;
if (router_nodes.front().address().is_v6())
nodes_key = "nodes6";
else
nodes_key = "nodes";
lt::entry::list_type& nodes = state["dht state"][nodes_key].list();
for (auto const& n : router_nodes)
{
std::string node;

View File

@ -156,6 +156,7 @@ namespace libtorrent { namespace dht {
void dht_tracker::delete_socket(aux::session_listen_socket* s)
{
TORRENT_ASSERT(m_nodes.count(s) == 1);
m_nodes.erase(s);
}

View File

@ -3515,10 +3515,11 @@ TORRENT_TEST(dht_state)
s.nids.emplace_back(address::from_string("1.1.1.1"), to_hash("0000000000000000000000000000000000000001"));
s.nodes.push_back(uep("1.1.1.1", 1));
s.nodes.push_back(uep("2.2.2.2", 2));
// not important that IPv6 is disabled here
s.nids.emplace_back(address::from_string("1::1"), to_hash("0000000000000000000000000000000000000002"));
s.nodes.push_back(uep("1::1", 3));
s.nodes.push_back(uep("2::2", 4));
// remove these for now because they will only get used if the host system has IPv6 support
// hopefully in the future we can rely on the test system supporting IPv6
//s.nids.emplace_back(address::from_string("1::1"), to_hash("0000000000000000000000000000000000000002"));
//s.nodes6.push_back(uep("1::1", 3));
//s.nodes6.push_back(uep("2::2", 4));
entry const e = save_dht_state(s);