limits: sync streams, listings per author, inbound connections per IP

A peer may hold 4 sync streams and open 1500 a minute; banned peers get none and cannot redial. A node keeps at most 100 unexpired listings per author (--max-per-author); updates, renewals and deletions of held ones still work. At most 16 inbound connections per public IP or IPv6 /64 (--max-conns-per-ip); local and private addresses are exempt.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-19 00:30:36 +01:00
co-authored by Claude Sonnet 5.5
parent 0b3ead4b23
commit 5ac02360c4
12 changed files with 527 additions and 23 deletions
+18 -3
View File
@@ -703,9 +703,24 @@ Findings (see "What is left" in SPECS.md for the open ones):
banned for an hour: closed connection, gossip blacklist; `internal/p2p/guard.go`).
In the sim the attacker was cut off from all 6 nodes it reached and honest
listings still arrived 50 of 50. What it does not stop: an attacker with many
peer IDs (a ban costs it nothing but a new key), a peer that sends only
valid but unwanted records, or one that stays under the limits. The ban is
per node, not shared, and covers gossip only, not the sync protocol.
peer IDs, a peer that sends only valid but unwanted records, or one that
stays under the limits. Three more limits close part of that:
- **Sync:** a peer may hold 4 sync streams at once and open 1500 a minute
(a full sync of 100,000 listings is about 1200); a banned peer gets none.
- **Per author:** a node keeps at most 100 unexpired listings per author
(`--max-per-author`, -1 for no limit); a 101st new one is neither stored
nor passed on, while updates, renewals and deletions of held ones still
work. Each node decides for itself, so nodes with different values hold
different sets and anti-entropy keeps offering the refused ones.
- **Per address:** at most 16 inbound connections from one public IP, or one
IPv6 /64 (`--max-conns-per-ip`, -1 for no limit); loopback, private and
link-local addresses are exempt, and a banned peer ID is refused when it
redials. A new peer ID from the same machine therefore does not help.
Behind a Kubernetes service the real source address is only visible with
`externalTrafficPolicy: Local` (the base manifest has it; the nodeport
overlay uses `Cluster`, which hides it, so the limit does nothing there).
Bans are per node and not shared (a shared ban would let one node get
honest ones banned); the HTTP API still has no limits.
3. **The DHT is only as good as its servers.** Only publicly reachable nodes
serve it. With every seed gone, a newcomer whose remembered peers are all in
another region found nobody (0 of 114 listings), and one that remembers no