From c7d01ae844961770b6c4b16430eea6d91fe1e2dc Mon Sep 17 00:00:00 2001 From: Laura Date: Fri, 20 Jun 2025 22:54:07 +0200 Subject: [PATCH] limit receive aswell --- server/protocol.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/protocol.go b/server/protocol.go index fab30bd..58f6c15 100644 --- a/server/protocol.go +++ b/server/protocol.go @@ -286,6 +286,18 @@ func HandleReceiveRequest(w http.ResponseWriter, r *http.Request) { sessions.Delete(token) + current, _, fail := rates.Inc(ip) + defer fail() + + if current > MaxClientParallel || current == 0 { + w.WriteHeader(http.StatusTooManyRequests) + + log.Warning("receive: too many requests") + log.WarningE(err) + + return + } + session := entry.(internal.SessionEntry) if session.Client != ip {