bitcoin/src
MarcoFalke 22a9018649
Merge bitcoin/bitcoin#23306: Make AddrMan support multiple ports per IP
92617b7a75 Make AddrMan support multiple ports per IP (Pieter Wuille)

Pull request description:

  For a long part of Bitcoin's history, this codebase has aggressively avoided making automatic connections to anything but nodes running on port 8333. I'd like to propose changing that, and this is a first PR necessary for that.

  The folklore justification (eventually actually added as a comment to the codebase in #20668) is that this is to prevent the Bitcoin P2P network from being leveraged to perform a DoS attack on other services, if their IP/port would get rumoured. It appears, at least the current network scale - and probably significantly larger - that the impact is very low at best (see calculations by vasild in https://github.com/bitcoin/bitcoin/issues/5150#issuecomment-853888909 e.g.). Another possible justification would be a risk that treating different IP:port combinations separately would help perform Eclipse attacks (by an attacker rumouring their own IP with many ports). This concern is (a) no different than what is possible with IPv6 (where large ranges of IP addresses are very cheaply available), and (b) already hopefully sufficiently addressed by addrman's design (which limits access through based selected based on network groups).

  And this policy has downsides too; in particular, a fixed port is easy to detect, and a very obvious sign a Bitcoin node is running there.

  One obstacle in moving away from a default port that is the fact that addrman is currently restricted to a single entry per IP address. If ports are no longer expected to be generally always the default one, we need to deal with the case where conflicting information is relayed. It turns out there is a very natural solution to this: treat (IP,port) combination exactly as we're treating IPs now; this automatically means that the same IP may appear with multiple ports, simply because those would be distinct entries. Given that indexing into addrman's bucket _already_ uses the port number, the only change required is making all addrman lookup be (IP,port) (aka `CService`) based, rather than IP (aka `CNetAddr`) based.

  This PR doesn't include any change to the actual outbound connection preference logic, as perhaps that's something that we want to phase in more gradually.

ACKs for top commit:
  jnewbery:
    Code review ACK 92617b7a75
  naumenkogs:
    ACK 92617b7a75
  ajtowns:
    ACK 92617b7a75
  vasild:
    ACK 92617b7a75

Tree-SHA512: 9eef06ce97a8b54a3f05fb8acf6941f253a9a5e0be8ce383dd05c44bb567cea243b74ee5667178e7497f6df2db93adab97ac66edbc37c883fd8ec840ee69a33f
2021-10-25 16:44:17 +02:00
..
bench Merge bitcoin/bitcoin#23157: txmempool -/-> validation 1/2: improve performance of check() and remove dependency on validation 2021-10-25 15:21:27 +02:00
common
compat
config
consensus Add comment to COIN constant. 2021-10-16 13:35:57 -07:00
crc32c
crypto Fix K1/K2 use in the comments in ChaCha20-Poly1305 AEAD 2021-10-20 11:54:03 +05:30
index Fix outdated comments referring to ::ChainActive() 2021-10-12 14:36:51 +13:00
init
interfaces Merge bitcoin/bitcoin#23003: multiprocess: Make interfaces::Chain::isTaprootActive non-const 2021-10-13 07:19:13 +02:00
ipc
leveldb
logging
node [mempool] delete exists(uint256) function 2021-10-21 16:26:59 +01:00
policy [mempool] delete exists(uint256) function 2021-10-21 16:26:59 +01:00
primitives Make GenTxid boolean constructor private 2021-10-22 12:32:16 +02:00
qt Merge bitcoin-core/gui#454: Use only Qt translation primitives in GUI code 2021-10-22 23:50:20 +03:00
rpc [mempool] delete exists(uint256) function 2021-10-21 16:26:59 +01:00
script
secp256k1
support refactor: remove references to deprecated values under std::allocator 2021-10-20 18:36:40 -04:00
test Merge bitcoin/bitcoin#23306: Make AddrMan support multiple ports per IP 2021-10-25 16:44:17 +02:00
univalue
util Add missing gettimeofday to syscall sandbox 2021-10-19 12:28:13 +02:00
wallet Merge bitcoin/bitcoin#23311: wallet: Use PACKAGE_NAME to mention our software 2021-10-25 15:24:00 +02:00
zmq
.clang-format
.clang-tidy
Makefile.am Merge bitcoin/bitcoin#23137: Move-only: bloom to src/common 2021-10-21 10:30:04 +08:00
Makefile.bench.include
Makefile.crc32c.include
Makefile.leveldb.include build: remove build stubs for external leveldb 2021-10-15 01:02:45 +00:00
Makefile.qt.include scripted-diff: Prefix makefile variables with QT_ 2021-10-13 21:09:54 +01:00
Makefile.qt_locale.include
Makefile.qttest.include
Makefile.test.include Integrate univalue into our buildsystem 2021-10-11 20:46:25 +08:00
Makefile.test_fuzz.include
Makefile.test_util.include
Makefile.univalue.include Integrate univalue into our buildsystem 2021-10-11 20:46:25 +08:00
addrdb.cpp
addrdb.h
addrman.cpp Merge bitcoin/bitcoin#23306: Make AddrMan support multiple ports per IP 2021-10-25 16:44:17 +02:00
addrman.h
addrman_impl.h Make AddrMan support multiple ports per IP 2021-10-22 12:06:36 -04:00
arith_uint256.cpp
arith_uint256.h
attributes.h
banman.cpp
banman.h
base58.cpp
base58.h
bech32.cpp
bech32.h
bitcoin-cli-res.rc
bitcoin-cli.cpp netinfo: print peer counts for all reachable networks 2021-10-20 15:52:54 +02:00
bitcoin-tx-res.rc
bitcoin-tx.cpp bitcoin-tx: Reject non-integral and out of range multisig numbers 2021-10-12 12:45:55 +02:00
bitcoin-util-res.rc
bitcoin-util.cpp
bitcoin-wallet-res.rc
bitcoin-wallet.cpp
bitcoind-res.rc
bitcoind.cpp
blockencodings.cpp
blockencodings.h
blockfilter.cpp
blockfilter.h
chain.cpp
chain.h Merge bitcoin/bitcoin#13875: [doc] nChainTx needs to become a 64-bit earlier due to SegWit 2021-10-20 15:52:08 +02:00
chainparams.cpp Use absolute FQDN for DNS seed domains 2021-10-14 17:49:52 +05:30
chainparams.h
chainparamsbase.cpp
chainparamsbase.h
chainparamsseeds.h
checkqueue.h
clientversion.cpp
clientversion.h
coins.cpp
coins.h
compat.h
compressor.cpp
compressor.h
core_io.h
core_memusage.h
core_read.cpp
core_write.cpp
cuckoocache.h
dbwrapper.cpp Merge bitcoin/bitcoin#22937: refactor: Forbid calling unsafe fs::path(std::string) constructor and fs::path::string() method 2021-10-15 10:01:56 +02:00
dbwrapper.h
deploymentinfo.cpp
deploymentinfo.h
deploymentstatus.cpp
deploymentstatus.h
dummywallet.cpp
external_signer.cpp
external_signer.h
flatfile.cpp
flatfile.h
fs.cpp refactor: include a missing <limits> header in fs.cpp 2021-10-22 04:03:45 +03:00
fs.h
hash.cpp
hash.h
httprpc.cpp
httprpc.h
httpserver.cpp
httpserver.h
i2p.cpp
i2p.h
indirectmap.h
init.cpp
init.h
key.cpp
key.h
key_io.cpp
key_io.h
logging.cpp
logging.h
mapport.cpp
mapport.h
memusage.h
merkleblock.cpp
merkleblock.h
miner.cpp
miner.h
net.cpp
net.h Merge bitcoin/bitcoin#23218: p2p: Use mocktime for ping timeout 2021-10-21 19:44:38 +02:00
net_permissions.cpp
net_permissions.h
net_processing.cpp Merge bitcoin/bitcoin#23157: txmempool -/-> validation 1/2: improve performance of check() and remove dependency on validation 2021-10-25 15:21:27 +02:00
net_processing.h
net_types.cpp
net_types.h
netaddress.cpp
netaddress.h Make AddrMan support multiple ports per IP 2021-10-22 12:06:36 -04:00
netbase.cpp
netbase.h
netmessagemaker.h
noui.cpp
noui.h
outputtype.cpp
outputtype.h
pow.cpp
pow.h
prevector.h
protocol.cpp Make GenTxid boolean constructor private 2021-10-22 12:32:16 +02:00
protocol.h
psbt.cpp
psbt.h
pubkey.cpp
pubkey.h
random.cpp
random.h
randomenv.cpp
randomenv.h
rest.cpp Merge bitcoin/bitcoin#22918: rpc: Add level 3 verbosity to getblock RPC call (#21245 modified) 2021-10-19 15:47:53 +02:00
reverse_iterator.h
scheduler.cpp
scheduler.h
serialize.h
shutdown.cpp
shutdown.h
signet.cpp
signet.h
span.h
streams.h
sync.cpp
sync.h
threadinterrupt.cpp
threadinterrupt.h
threadsafety.h
timedata.cpp
timedata.h
tinyformat.h
torcontrol.cpp
torcontrol.h
txdb.cpp
txdb.h
txmempool.cpp Merge bitcoin/bitcoin#23157: txmempool -/-> validation 1/2: improve performance of check() and remove dependency on validation 2021-10-25 15:21:27 +02:00
txmempool.h Merge bitcoin/bitcoin#23157: txmempool -/-> validation 1/2: improve performance of check() and remove dependency on validation 2021-10-25 15:21:27 +02:00
txorphanage.cpp
txorphanage.h
txrequest.cpp Make GenTxid boolean constructor private 2021-10-22 12:32:16 +02:00
txrequest.h
uint256.cpp
uint256.h
undo.h
validation.cpp Merge bitcoin/bitcoin#23157: txmempool -/-> validation 1/2: improve performance of check() and remove dependency on validation 2021-10-25 15:21:27 +02:00
validation.h Merge bitcoin/bitcoin#23157: txmempool -/-> validation 1/2: improve performance of check() and remove dependency on validation 2021-10-25 15:21:27 +02:00
validationinterface.cpp
validationinterface.h
version.h
versionbits.cpp
versionbits.h
walletinitinterface.h
warnings.cpp
warnings.h