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:
@@ -58,7 +58,7 @@ type signalRequest struct {
|
||||
// postSignal records a visitor's tip. Tips stay on this node: they hide
|
||||
// nothing and are not gossiped; the operator reads them and may sign a report.
|
||||
func (s *server) postSignal(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.limiter.allow(clientIP(r)) {
|
||||
if !s.limiter.allow(s.clientIP(r)) {
|
||||
w.Header().Set("Retry-After", "60")
|
||||
fail(w, http.StatusTooManyRequests, "too many requests from this address; try again in a minute")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user