diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-03 22:33:20 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-03 22:33:20 +0000 |
| commit | b810d86752ddb2674118f737582c924bb9eb74c1 (patch) | |
| tree | 1ceadf421609a2e58da81103165a2fb7085387de /src/net.h | |
| parent | db44eac5d347c229539946e8d61f1ff0d1f68001 (diff) | |
| parent | 5ef59833756da6f47274cb990eb874fb0ed99019 (diff) | |
merge: upstream 1.2.20 into deploy/all-2026-08-24
# Conflicts:
# Makefile
Diffstat (limited to 'src/net.h')
| -rw-r--r-- | src/net.h | 17 |
1 files changed, 17 insertions, 0 deletions
| @@ -124,6 +124,23 @@ static const unsigned int MAX_PROTOCOL_MESSAGE_SIZE = MAX_SIZE; | |||
| 124 | // 125 is Bitcoin's number and remains a conservative public-node default. | 124 | // 125 is Bitcoin's number and remains a conservative public-node default. |
| 125 | static const unsigned int MAX_CONNECTIONS = 125; | 125 | static const unsigned int MAX_CONNECTIONS = 125; |
| 126 | 126 | ||
| 127 | // Cap inbound connections from any single address. Without it one source can | ||
| 128 | // hold every slot up to MAX_CONNECTIONS -- exactly what happened to the | ||
| 129 | // rendezvous relays, where a single IP parked hundreds of connections and | ||
| 130 | // starved real peers. A legitimate peer, even a relay talking to a relay, | ||
| 131 | // needs only a handful; 32 leaves generous room while denying any one address | ||
| 132 | // more than a quarter of the table. The firewall connlimit on the relays does | ||
| 133 | // the same thing a layer lower; this makes every build carry the defense. | ||
| 134 | // | ||
| 135 | // Loopback (127.0.0.0/8) is exempt in the accept path. A managed-Tor node | ||
| 136 | // receives every inbound onion peer over its local hidden-service listener, so | ||
| 137 | // they all appear as 127.0.0.1 -- capping loopback would cap onion peers as a | ||
| 138 | // group, which is exactly wrong for a network moving toward onion-only. The | ||
| 139 | // global MAX_CONNECTIONS still bounds the total; a per-onion-identity limit, | ||
| 140 | // applied once identity is known after accept(), is the right future tool for | ||
| 141 | // onion floods. | ||
| 142 | static const unsigned int MAX_CONNECTIONS_PER_IP = 32; | ||
| 143 | |||
| 127 | // A node marked for disconnect is normally held until its buffers drain, so | 144 | // A node marked for disconnect is normally held until its buffers drain, so |
| 128 | // a last message still goes out. But vSend cannot drain through a socket | 145 | // a last message still goes out. But vSend cannot drain through a socket |
| 129 | // whose far end is gone, and that made such a node immortal: it stayed in | 146 | // whose far end is gone, and that made such a node immortal: it stayed in |