add some asserts and checks preventing IPv6 addresses to make it into libtorrent when IPv6 support is disabled

This commit is contained in:
arvidn 2018-03-30 01:04:21 +03:00 committed by Arvid Norberg
parent e7e5805c56
commit 6a2df1034a
3 changed files with 15 additions and 0 deletions

View File

@ -386,11 +386,17 @@ namespace libtorrent { namespace dht
void dht_tracker::add_node(udp::endpoint node)
{
#if !TORRENT_USE_IPV6
TORRENT_ASSERT(node.address().is_v4());
#endif
m_dht.add_node(node);
}
void dht_tracker::add_router_node(udp::endpoint const& node)
{
#if !TORRENT_USE_IPV6
TORRENT_ASSERT(node.address().is_v4());
#endif
m_dht.add_router_node(node);
}

View File

@ -1153,6 +1153,9 @@ void routing_table::node_failed(node_id const& nid, udp::endpoint const& ep)
void routing_table::add_router_node(udp::endpoint router)
{
#if !TORRENT_USE_IPV6
TORRENT_ASSERT(router.address().is_v4());
#endif
m_router_nodes.insert(router);
}

View File

@ -3551,6 +3551,9 @@ retry:
void session_impl::add_dht_node(udp::endpoint n)
{
TORRENT_ASSERT(is_single_thread());
#if !TORRENT_USE_IPV6
if (!n.address().is_v4()) return;
#endif
if (m_dht) m_dht->add_node(n);
else m_dht_nodes.push_back(n);
@ -5887,6 +5890,9 @@ retry:
for (std::vector<address>::const_iterator i = addresses.begin()
, end(addresses.end()); i != end; ++i)
{
#if !TORRENT_USE_IPV6
if (!i->is_v4()) continue;
#endif
// router nodes should be added before the DHT is started (and bootstrapped)
udp::endpoint ep(*i, port);
if (m_dht) m_dht->add_router_node(ep);