don't try to connect to a global address with a local source address

This commit is contained in:
Steven Siloti 2017-10-07 18:23:48 -07:00 committed by Arvid Norberg
parent aec9a4940c
commit 0c6b17ed82
1 changed files with 5 additions and 0 deletions

View File

@ -538,6 +538,11 @@ void http_connection::on_resolve(error_code const& e
if (ep.address().is_v4() && m_bind_addr->is_v4())
return true;
TORRENT_ASSERT(ep.address().is_v6() && m_bind_addr->is_v6());
// don't try to connect to a global address with a local source address
// this is mainly needed to prevent attempting to connect to a global
// address using a ULA as the source
if (!is_local(ep.address()) && is_local(*m_bind_addr))
return false;
return ep.address().to_v6().scope_id() == m_bind_addr->to_v6().scope_id();
});
m_endpoints.erase(new_end, m_endpoints.end());