From 4b70bb0e79dcc43666fcaed345496c036977cafd Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Sat, 13 Jul 2024 00:32:39 -0400 Subject: [PATCH] Add rate limit for unban and fix admin rate limits --- config/ratelimits.yml | 6 +++--- src/ws/ratelimit/config.ts | 4 ++++ src/ws/ratelimit/limits/admin.ts | 27 ++++++++++++++------------- src/ws/ratelimit/limits/crown.ts | 1 + src/ws/ratelimit/limits/user.ts | 1 + 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/config/ratelimits.yml b/config/ratelimits.yml index 42076cb..60031d8 100644 --- a/config/ratelimits.yml +++ b/config/ratelimits.yml @@ -4,6 +4,7 @@ user: m: 50 ch: 1000 kickban: 125 + unban: 125 t: 7.8125 +ls: 16.666666666666668 -ls: 16.666666666666668 @@ -11,7 +12,6 @@ user: hi: 50 bye: 50 devices: 50 - admin_message: 50 admin message: 50 chains: userset: @@ -29,6 +29,7 @@ crown: m: 50 ch: 1000 kickban: 125 + unban: 125 t: 7.8125 +ls: 16.666666666666668 -ls: 16.666666666666668 @@ -36,7 +37,6 @@ crown: hi: 50 bye: 50 devices: 50 - admin_message: 50 admin message: 50 chains: userset: @@ -54,6 +54,7 @@ admin: m: 16.666666666666668 ch: 100 kickban: 16.666666666666668 + unban: 125 t: 3.90625 +ls: 16.666666666666668 -ls: 16.666666666666668 @@ -61,7 +62,6 @@ admin: hi: 50 bye: 50 devices: 50 - admin_message: 16.666666666666668 admin message: 16.666666666666668 chains: userset: diff --git a/src/ws/ratelimit/config.ts b/src/ws/ratelimit/config.ts index 14eb745..ea77159 100644 --- a/src/ws/ratelimit/config.ts +++ b/src/ws/ratelimit/config.ts @@ -11,6 +11,7 @@ export interface RateLimitConfigList< m: RL; ch: RL; kickban: RL; + unban: RL; t: RL; "+ls": RL; "-ls": RL; @@ -50,6 +51,7 @@ export const config = loadConfig("config/ratelimits.yml", { m: 1000 / 20, ch: 1000 / 1, kickban: 1000 / 8, + unban: 1000 / 8, t: 1000 / 128, "+ls": 1000 / 60, "-ls": 1000 / 60, @@ -81,6 +83,7 @@ export const config = loadConfig("config/ratelimits.yml", { m: 1000 / 20, ch: 1000 / 1, kickban: 1000 / 8, + unban: 1000 / 8, t: 1000 / 128, "+ls": 1000 / 60, "-ls": 1000 / 60, @@ -112,6 +115,7 @@ export const config = loadConfig("config/ratelimits.yml", { m: 1000 / 60, ch: 1000 / 10, kickban: 1000 / 60, + unban: 1000 / 8, t: 1000 / 256, "+ls": 1000 / 60, "-ls": 1000 / 60, diff --git a/src/ws/ratelimit/limits/admin.ts b/src/ws/ratelimit/limits/admin.ts index 395576c..7b7bb98 100644 --- a/src/ws/ratelimit/limits/admin.ts +++ b/src/ws/ratelimit/limits/admin.ts @@ -7,16 +7,17 @@ export const adminLimits: RateLimitConstructorList = { a: () => new RateLimit(config.admin.normal.a), m: () => new RateLimit(config.admin.normal.m), ch: () => new RateLimit(config.admin.normal.ch), - kickban: () => new RateLimit(config.crown.normal.kickban), - t: () => new RateLimit(config.crown.normal.t), - "+ls": () => new RateLimit(config.crown.normal["+ls"]), - "-ls": () => new RateLimit(config.crown.normal["-ls"]), - chown: () => new RateLimit(config.crown.normal.chown), + kickban: () => new RateLimit(config.admin.normal.kickban), + unban: () => new RateLimit(config.admin.normal.unban), + t: () => new RateLimit(config.admin.normal.t), + "+ls": () => new RateLimit(config.admin.normal["+ls"]), + "-ls": () => new RateLimit(config.admin.normal["-ls"]), + chown: () => new RateLimit(config.admin.normal.chown), - hi: () => new RateLimit(config.crown.normal.hi), - bye: () => new RateLimit(config.crown.normal.bye), - devices: () => new RateLimit(config.crown.normal.devices), - "admin message": () => new RateLimit(config.crown.normal["admin message"]) + hi: () => new RateLimit(config.admin.normal.hi), + bye: () => new RateLimit(config.admin.normal.bye), + devices: () => new RateLimit(config.admin.normal.devices), + "admin message": () => new RateLimit(config.admin.normal["admin message"]) }, chains: { userset: () => @@ -26,13 +27,13 @@ export const adminLimits: RateLimitConstructorList = { ), chset: () => new RateLimitChain( - config.crown.chains.chset.interval, - config.crown.chains.userset.num + config.admin.chains.chset.interval, + config.admin.chains.userset.num ), n: () => new RateLimitChain( - config.crown.chains.n.interval, - config.crown.chains.userset.num + config.admin.chains.n.interval, + config.admin.chains.userset.num ) } }; diff --git a/src/ws/ratelimit/limits/crown.ts b/src/ws/ratelimit/limits/crown.ts index 480a1e4..c7e0e4b 100644 --- a/src/ws/ratelimit/limits/crown.ts +++ b/src/ws/ratelimit/limits/crown.ts @@ -8,6 +8,7 @@ export const crownLimits: RateLimitConstructorList = { m: () => new RateLimit(config.crown.normal.m), ch: () => new RateLimit(config.crown.normal.ch), kickban: () => new RateLimit(config.crown.normal.kickban), + unban: () => new RateLimit(config.crown.normal.unban), t: () => new RateLimit(config.crown.normal.t), "+ls": () => new RateLimit(config.crown.normal["+ls"]), "-ls": () => new RateLimit(config.crown.normal["-ls"]), diff --git a/src/ws/ratelimit/limits/user.ts b/src/ws/ratelimit/limits/user.ts index 3b53c98..9fb3cbd 100644 --- a/src/ws/ratelimit/limits/user.ts +++ b/src/ws/ratelimit/limits/user.ts @@ -8,6 +8,7 @@ export const userLimits: RateLimitConstructorList = { m: () => new RateLimit(config.user.normal.m), ch: () => new RateLimit(config.user.normal.ch), kickban: () => new RateLimit(config.user.normal.kickban), + unban: () => new RateLimit(config.user.normal.unban), t: () => new RateLimit(config.user.normal.t), "+ls": () => new RateLimit(config.user.normal["+ls"]), "-ls": () => new RateLimit(config.user.normal["-ls"]),