From 8f7533f9c3f88def39a7054f822453c084e9bbad Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Tue, 24 Feb 2026 14:16:21 +0330 Subject: ratelimit var --- layer/broadlayer.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/layer/broadlayer.ts b/layer/broadlayer.ts index 2f1ccd6..8b6ed31 100644 --- a/layer/broadlayer.ts +++ b/layer/broadlayer.ts @@ -227,7 +227,8 @@ async function establishUDP(hostname: string, port: number, clientIp: string): P return id } -const eviction_timeout = 60_000 +const eviction_timeout = 15_000 +const ratelimit_count = 32 setInterval(() => { for (const key of Object.keys(sessions)) { @@ -258,7 +259,7 @@ Bun.serve({ // ratelimit const clientIp = req.headers.get('x-forwarded-for')?.split(',')[0]?.trim() || 'unknown' let count = connectionsPerIp.get(clientIp) || 0 - if (count >= 4) { + if (count >= ratelimit_count) { return new Response('err_toomany', { status: 429 }) } @@ -277,7 +278,7 @@ Bun.serve({ // ratelimit const clientIp = req.headers.get('x-forwarded-for')?.split(',')[0]?.trim() || 'unknown' let count = connectionsPerIp.get(clientIp) || 0 - if (count >= 4) { + if (count >= ratelimit_count) { return new Response('err_toomany', { status: 429 }) } @@ -343,7 +344,7 @@ Bun.serve({ // ratelimit const clientIp = req.headers.get('x-forwarded-for')?.split(',')[0]?.trim() || 'unknown' let count = connectionsPerIp.get(clientIp) || 0 - if (count >= 4) { + if (count >= ratelimit_count) { return new Response('err_toomany', { status: 429 }) } @@ -370,7 +371,7 @@ Bun.serve({ // ratelimit const clientIp = req.headers.get('x-forwarded-for')?.split(',')[0]?.trim() || 'unknown' let count = connectionsPerIp.get(clientIp) || 0 - if (count >= 4) { + if (count >= ratelimit_count) { return new Response('err_toomany', { status: 429 }) } connectionsPerIp.set(clientIp, count + 1) -- cgit v1.2.3