diff options
| author | bitflash <admin@bitflash.network> | 2026-08-18 10:24:01 -0300 |
|---|---|---|
| committer | bitflash <admin@bitflash.network> | 2026-08-18 10:24:01 -0300 |
| commit | 33092ffe8ee5fb5f7c080a44831e5557b63deb63 (patch) | |
| tree | ded284f5c10d89cad8071bcaac2d33dfc2c1012d /src/net.h | |
| parent | db84acfc5f99ac1ddf4962879b4cbaf1af9952dd (diff) | |
net: exempt loopback from the per-IP connection cap
Review follow-up. A managed-Tor node receives every inbound onion peer
over its local hidden-service listener, so they all accept as 127.0.0.1.
Capping loopback would cap onion peers as one group and refuse the 33rd
legitimate onion peer -- the wrong limit for a network moving toward
onion-only. Exempt loopback (127.0.0.0/8): the global MAX_CONNECTIONS
still bounds the total, and the direct-IP flood this defends against
never arrives over loopback.
Bench: a 40-connection flood from 127.0.0.1 is now held in full (no
per-IP refusal), while a flood from the machine's LAN address still caps
at exactly 32.
Diffstat (limited to 'src/net.h')
| -rw-r--r-- | src/net.h | 8 |
1 files changed, 8 insertions, 0 deletions
| @@ -119,6 +119,14 @@ static const unsigned int MAX_CONNECTIONS = 125; | |||
| 119 | // needs only a handful; 32 leaves generous room while denying any one address | 119 | // needs only a handful; 32 leaves generous room while denying any one address |
| 120 | // more than a quarter of the table. The firewall connlimit on the relays does | 120 | // more than a quarter of the table. The firewall connlimit on the relays does |
| 121 | // the same thing a layer lower; this makes every build carry the defense. | 121 | // the same thing a layer lower; this makes every build carry the defense. |
| 122 | // | ||
| 123 | // Loopback (127.0.0.0/8) is exempt in the accept path. A managed-Tor node | ||
| 124 | // receives every inbound onion peer over its local hidden-service listener, so | ||
| 125 | // they all appear as 127.0.0.1 -- capping loopback would cap onion peers as a | ||
| 126 | // group, which is exactly wrong for a network moving toward onion-only. The | ||
| 127 | // global MAX_CONNECTIONS still bounds the total; a per-onion-identity limit, | ||
| 128 | // applied once identity is known after accept(), is the right future tool for | ||
| 129 | // onion floods. | ||
| 122 | static const unsigned int MAX_CONNECTIONS_PER_IP = 32; | 130 | static const unsigned int MAX_CONNECTIONS_PER_IP = 32; |
| 123 | 131 | ||
| 124 | // A node marked for disconnect is normally held until its buffers drain, so | 132 | // A node marked for disconnect is normally held until its buffers drain, so |