This commit is contained in:
Arvid Norberg 2007-08-07 07:29:51 +00:00
parent 61f713d24a
commit 6b86e5faa3
2 changed files with 12 additions and 3 deletions

View File

@ -62,9 +62,10 @@ namespace libtorrent
{
if (a.is_v6()) return false;
address_v4 a4 = a.to_v4();
return ((a4.to_ulong() & 0xff000000) == 0x0a000000
|| (a4.to_ulong() & 0xfff00000) == 0xac100000
|| (a4.to_ulong() & 0xffff0000) == 0xc0a80000);
unsigned long ip = htonl(a4.to_ulong());
return ((ip & 0xff000000) == 0x0a000000
|| (ip & 0xfff00000) == 0xac100000
|| (ip & 0xffff0000) == 0xc0a80000);
}
address_v4 guess_local_address(asio::io_service& ios)

View File

@ -2,6 +2,7 @@
#include "libtorrent/http_tracker_connection.hpp"
#include "libtorrent/buffer.hpp"
#include "libtorrent/xml_parse.hpp"
#include "libtorrent/upnp.hpp"
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
#include <boost/bind.hpp>
@ -159,6 +160,13 @@ int test_main()
, boost::ref(out4), _1, _2, _3));
std::cerr << out4 << std::endl;
TEST_CHECK(out4 == "BaPgarbage inside element bracketsSfooFaPgarbage inside element brackets");
// test network functions
TEST_CHECK(is_local(address::from_string("192.168.0.1")));
TEST_CHECK(is_local(address::from_string("10.1.1.56")));
TEST_CHECK(!is_local(address::from_string("14.14.251.63")));
return 0;
}