windows fix for ip-voter test
This commit is contained in:
parent
d8c2228ff3
commit
5b638c3c9e
|
@ -41,7 +41,7 @@ namespace libtorrent
|
|||
{
|
||||
// this is an object that keeps the state for a single external IP
|
||||
// based on peoples votes
|
||||
struct ip_voter
|
||||
struct TORRENT_EXTRA_EXPORT ip_voter
|
||||
{
|
||||
// returns true if a different IP is the top vote now
|
||||
// i.e. we changed our idea of what our external IP is
|
||||
|
|
|
@ -832,7 +832,7 @@ namespace libtorrent
|
|||
(*m_torrent->session().m_logger) << time_now_string()
|
||||
<< " *** FOUND CONNECTION CANDIDATE ["
|
||||
" ip: " << m_peers[candidate]->ip() <<
|
||||
" d: " << cidr_distance(external.address(m_peers[candidate]->address()), m_peers[candidate]->address()) <<
|
||||
" d: " << cidr_distance(external.external_address(m_peers[candidate]->address()), m_peers[candidate]->address()) <<
|
||||
" rank: " << m_peers[candidate]->rank(external, external_port) <<
|
||||
" external: " << external.external_address(m_peers[candidate]->address()) <<
|
||||
" t: " << (session_time - m_peers[candidate]->last_connected) <<
|
||||
|
|
|
@ -550,8 +550,10 @@ int test_main()
|
|||
// test a single malicious node
|
||||
// adds 50 legitimate responses from different peers
|
||||
// and 50 malicious responses from the same peer
|
||||
address real_external = address_v4::from_string("5.5.5.5");
|
||||
address malicious = address_v4::from_string("4.4.4.4");
|
||||
address real_external = address_v4::from_string("5.5.5.5", ec);
|
||||
TEST_CHECK(!ec);
|
||||
address malicious = address_v4::from_string("4.4.4.4", ec);
|
||||
TEST_CHECK(!ec);
|
||||
for (int i = 0; i < 50; ++i)
|
||||
{
|
||||
ipv1.cast_vote(real_external, aux::session_impl::source_dht, rand_v4());
|
||||
|
@ -564,17 +566,27 @@ int test_main()
|
|||
// test a single malicious node
|
||||
// adds 50 legitimate responses from different peers
|
||||
// and 50 consistent malicious responses from the same peer
|
||||
address real_external1 = address_v4::from_string("5.5.5.5");
|
||||
address real_external2 = address_v6::from_string("2f80::1");
|
||||
malicious = address_v4::from_string("4.4.4.4");
|
||||
address malicious_external = address_v4::from_string("3.3.3.3");
|
||||
address real_external1 = address_v4::from_string("5.5.5.5", ec);
|
||||
TEST_CHECK(!ec);
|
||||
address real_external2;
|
||||
if (supports_ipv6())
|
||||
{
|
||||
real_external2 = address_v6::from_string("2f80::", ec);
|
||||
TEST_CHECK(!ec);
|
||||
}
|
||||
malicious = address_v4::from_string("4.4.4.4", ec);
|
||||
TEST_CHECK(!ec);
|
||||
address malicious_external = address_v4::from_string("3.3.3.3", ec);
|
||||
TEST_CHECK(!ec);
|
||||
for (int i = 0; i < 50; ++i)
|
||||
{
|
||||
ipv2.cast_vote(real_external1, aux::session_impl::source_dht, rand_v4());
|
||||
if (supports_ipv6())
|
||||
ipv2.cast_vote(real_external2, aux::session_impl::source_dht, rand_v6());
|
||||
ipv2.cast_vote(malicious_external, aux::session_impl::source_dht, malicious);
|
||||
}
|
||||
TEST_CHECK(ipv2.external_address(rand_v4()) == real_external1);
|
||||
if (supports_ipv6())
|
||||
TEST_CHECK(ipv2.external_address(rand_v6()) == real_external2);
|
||||
|
||||
// test bloom_filter
|
||||
|
|
Loading…
Reference in New Issue