mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Gateway: log rejected connections over the per-IP limit
Rejections at the WebSocket upgrade (429) were silent, so a client hammering MAX_CONNECTIONS_PER_IP left no trace. Now logged as a [ratelimit] line like the connect rate limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
169d32a292
commit
4e04ddb526
1 file changed
+1
@@ -583,6 +583,7 @@ const wss = new WebSocketServer({
|
||||
}
|
||||
const ip = clientIp(req);
|
||||
if (MAX_CONNECTIONS_PER_IP > 0 && (connectionsPerIp.get(ip) ?? 0) >= MAX_CONNECTIONS_PER_IP) {
|
||||
console.warn(`[ratelimit] too many open connections from one IP (limit ${MAX_CONNECTIONS_PER_IP})`);
|
||||
return done(false, 429, "Too many connections");
|
||||
}
|
||||
done(true);
|
||||
|
||||
Reference in new issue
Block a user