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/net.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/net.cpp')
-rw-r--r-- | src/net.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/net.cpp b/src/net.cpp index bee8710062..cb9ef4d0cd 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2120,12 +2120,8 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect) continue; } - // Do not allow non-default ports, unless after 50 invalid - // addresses selected already. This is to prevent malicious peers - // from advertising themselves as a service on another host and - // port, causing a DoS attack as nodes around the network attempt - // to connect to it fruitlessly. - if (addr.GetPort() != Params().GetDefaultPort(addr.GetNetwork()) && nTries < 50) { + // Do not connect to bad ports, unless 50 invalid addresses have been selected already. + if (nTries < 50 && (addr.IsIPv4() || addr.IsIPv6()) && IsBadPort(addr.GetPort())) { continue; } |