diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2021-11-18 09:19:09 +0100 |
---|---|---|
committer | Vasil Dimov <vd@FreeBSD.org> | 2022-02-11 15:21:49 +0100 |
commit | 97208634b96f2d9a55f2ead7b0ef407da729d7bd (patch) | |
tree | dcfd5e6b2bc512668d5f0337cb28aed21629cb5a /src/test/netbase_tests.cpp | |
parent | bcecde64b4ad7bb8e717d5709af8fd17532755ab (diff) |
net: open p2p connections to nodes that listen on non-default ports
By default, for mainnet, the p2p listening port is 8333. Bitcoin Core
has a strong preference for only connecting to nodes that listen on that
port.
Remove that preference because connections over clearnet that involve
port 8333 make it easy to detect, analyze, block or divert Bitcoin p2p
traffic before the connection is even established (at TCP SYN time).
For further justification see the OP of:
https://github.com/bitcoin/bitcoin/pull/23306
Diffstat (limited to 'src/test/netbase_tests.cpp')
-rw-r--r-- | src/test/netbase_tests.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp index 6410ac565a..8e6e911ec2 100644 --- a/src/test/netbase_tests.cpp +++ b/src/test/netbase_tests.cpp @@ -576,4 +576,24 @@ BOOST_AUTO_TEST_CASE(caddress_unserialize_v2) BOOST_CHECK(fixture_addresses == addresses_unserialized); } +BOOST_AUTO_TEST_CASE(isbadport) +{ + BOOST_CHECK(IsBadPort(1)); + BOOST_CHECK(IsBadPort(22)); + BOOST_CHECK(IsBadPort(6000)); + + BOOST_CHECK(!IsBadPort(80)); + BOOST_CHECK(!IsBadPort(443)); + BOOST_CHECK(!IsBadPort(8333)); + + // Check all ports, there must be 80 bad ports in total. + size_t total_bad_ports{0}; + for (uint16_t port = std::numeric_limits<uint16_t>::max(); port > 0; --port) { + if (IsBadPort(port)) { + ++total_bad_ports; + } + } + BOOST_CHECK_EQUAL(total_bad_ports, 80); +} + BOOST_AUTO_TEST_SUITE_END() |