api: a per-client rate limit on the HTTP API, with trusted proxies for X-Forwarded-For

600 /api/ requests a minute per client address (--requests-per-minute), 429 with Retry-After; static UI files and the node's own machine are exempt. The real client behind a reverse proxy is read from X-Forwarded-For only when the connection comes from a --trusted-proxy, taking the last entry that is not itself a trusted proxy. k8s: TRUSTED_PROXY in config.env (the private ranges) is passed as --trusted-proxy.

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:35:21 +01:00
co-authored by Claude Sonnet 5.5
parent 5ac02360c4
commit 3799faddcf
10 changed files with 296 additions and 17 deletions
+3 -2
View File
@@ -151,8 +151,9 @@ starting a design-heavy item; see "Working with the owner".
relaying over 1200 messages a minute and bans one that sends 20 invalid ones
for an hour, limits sync streams (4 at once, 1500 a minute), keeps at most
100 listings per author (`--max-per-author`) and 16 inbound connections per
public IP (`--max-conns-per-ip`). Not covered: a rate limit on the HTTP API,
attackers with many addresses, sharing bans between nodes (deliberately).
public IP (`--max-conns-per-ip`), and 600 API requests a minute per client
address (`--requests-per-minute`, `--trusted-proxy`). Not covered: attackers
with many addresses, sharing bans between nodes (deliberately).
- **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.