mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 09:43:55 +02:00
Merge #10446: net: avoid extra dns query per seed
c1be285chainparams: make supported service bits option explicit (Cory Fields)d5c7c1cnet: use an internal address for fixed seeds (Cory Fields)6cdc488net: switch to dummy internal ip for dns seed source (Cory Fields)6d0bd5bnet: do not allow resolving to an internal address (Cory Fields)7f31762net: add an internal subnet for representing unresolved hostnames (Cory Fields) Tree-SHA512: 9bf1042bef546ac3ef0e0d3a9a5555eb21628ff2674a0cf8c6367194b22bfdab477adf452c0e7c56f44e0fb37debc5e14bdb623452e076fb9c492c7702601d7a
This commit is contained in:
@@ -25,6 +25,13 @@ static CSubNet ResolveSubNet(const char* subnet)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static CNetAddr CreateInternal(const char* host)
|
||||
{
|
||||
CNetAddr addr;
|
||||
addr.SetInternal(host);
|
||||
return addr;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(netbase_networks)
|
||||
{
|
||||
BOOST_CHECK(ResolveIP("127.0.0.1").GetNetwork() == NET_UNROUTABLE);
|
||||
@@ -32,6 +39,7 @@ BOOST_AUTO_TEST_CASE(netbase_networks)
|
||||
BOOST_CHECK(ResolveIP("8.8.8.8").GetNetwork() == NET_IPV4);
|
||||
BOOST_CHECK(ResolveIP("2001::8888").GetNetwork() == NET_IPV6);
|
||||
BOOST_CHECK(ResolveIP("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetNetwork() == NET_TOR);
|
||||
BOOST_CHECK(CreateInternal("foo.com").GetNetwork() == NET_INTERNAL);
|
||||
|
||||
}
|
||||
|
||||
@@ -58,6 +66,8 @@ BOOST_AUTO_TEST_CASE(netbase_properties)
|
||||
BOOST_CHECK(ResolveIP("8.8.8.8").IsRoutable());
|
||||
BOOST_CHECK(ResolveIP("2001::1").IsRoutable());
|
||||
BOOST_CHECK(ResolveIP("127.0.0.1").IsValid());
|
||||
BOOST_CHECK(CreateInternal("FD6B:88C0:8724:edb1:8e4:3588:e546:35ca").IsInternal());
|
||||
BOOST_CHECK(CreateInternal("bar.com").IsInternal());
|
||||
|
||||
}
|
||||
|
||||
@@ -103,6 +113,11 @@ BOOST_AUTO_TEST_CASE(netbase_lookupnumeric)
|
||||
BOOST_CHECK(TestParse("[::]:8333", "[::]:8333"));
|
||||
BOOST_CHECK(TestParse("[127.0.0.1]", "127.0.0.1:65535"));
|
||||
BOOST_CHECK(TestParse(":::", "[::]:0"));
|
||||
|
||||
// verify that an internal address fails to resolve
|
||||
BOOST_CHECK(TestParse("[fd6b:88c0:8724:1:2:3:4:5]", "[::]:0"));
|
||||
// and that a one-off resolves correctly
|
||||
BOOST_CHECK(TestParse("[fd6c:88c0:8724:1:2:3:4:5]", "[fd6c:88c0:8724:1:2:3:4:5]:65535"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(onioncat_test)
|
||||
@@ -281,6 +296,9 @@ BOOST_AUTO_TEST_CASE(netbase_getgroup)
|
||||
BOOST_CHECK(ResolveIP("2001:470:abcd:9999:9999:9999:9999:9999").GetGroup() == std::vector<unsigned char>({(unsigned char)NET_IPV6, 32, 1, 4, 112, 175})); //he.net
|
||||
BOOST_CHECK(ResolveIP("2001:2001:9999:9999:9999:9999:9999:9999").GetGroup() == std::vector<unsigned char>({(unsigned char)NET_IPV6, 32, 1, 32, 1})); //IPv6
|
||||
|
||||
// baz.net sha256 hash: 12929400eb4607c4ac075f087167e75286b179c693eb059a01774b864e8fe505
|
||||
std::vector<unsigned char> internal_group = {NET_INTERNAL, 0x12, 0x92, 0x94, 0x00, 0xeb, 0x46, 0x07, 0xc4, 0xac, 0x07};
|
||||
BOOST_CHECK(CreateInternal("baz.net").GetGroup() == internal_group);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user