p2p: a per-peer guard drops floods and bans peers that send invalid gossip

Per relaying peer and minute: over 1200 messages are dropped unread (no penalty); 20 invalid ones (bad signature, too little work, garbage) ban the peer for an hour, closing the connection and blacklisting it in gossip. Ignored messages (clock trouble, unknown listing) never count. In the simulator the attacker is cut off from every node it reached and honest listings still arrive 50 of 50; the message-flood scenario now uses a second attacker.

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:21:59 +01:00
co-authored by Claude Sonnet 5.5
parent bcae85b06f
commit daa80a6d56
6 changed files with 305 additions and 12 deletions
+4 -2
View File
@@ -147,8 +147,10 @@ starting a design-heavy item; see "Working with the owner".
- **Check a public node's memory under load.** `--public` nodes now accept
1000 inbound connections (`--max-conns`); nobody has measured a node holding
that many against the 512 MiB pod limit.
- **Peer scoring and rate limits** beyond what the validators do now. The
simulator's attacker stays connected after 500 bad messages.
- **Peer scoring beyond the guard.** `internal/p2p/guard.go` drops a peer
relaying over 1200 messages a minute and bans one that sends 20 invalid ones
for an hour (gossip only). Not covered: throwaway peer IDs, rate limits on
the sync protocol and the HTTP API, sharing bans between nodes.
- **Joining without the seeds.** A newcomer whose remembered peers are all in
another region cannot find its region when no DHT server is up (sim: 0 of
114 listings). Remember region peers separately, or ask connected peers.