From 407faf77c80a8cfd10a59f85066a32e39d0020e5 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Thu, 12 Aug 2021 18:57:43 +0200 Subject: :sparkles: config add rate limit --- src/util/Config.ts | 60 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 13 deletions(-) (limited to 'src/util') diff --git a/src/util/Config.ts b/src/util/Config.ts index 903a5d59..78b44315 100644 --- a/src/util/Config.ts +++ b/src/util/Config.ts @@ -20,8 +20,10 @@ export default { }; export interface RateLimitOptions { + bot?: number; count: number; - timespan: number; + window: number; + onyIp?: boolean; } export interface Region { @@ -78,15 +80,16 @@ export interface DefaultOptions { maxTopic: number; }; rate: { - ip: { - enabled: boolean; - count: number; - timespan: number; - }; + ip: Omit; + global: RateLimitOptions; + error: RateLimitOptions; routes: { - auth?: { - login?: RateLimitOptions; - register?: RateLimitOptions; + guild: RateLimitOptions; + webhook: RateLimitOptions; + channel: RateLimitOptions; + auth: { + login: RateLimitOptions; + register: RateLimitOptions; }; // TODO: rate limit configuration for all routes }; @@ -183,11 +186,42 @@ export const DefaultOptions: DefaultOptions = { }, rate: { ip: { - enabled: true, - count: 1000, - timespan: 1000 * 60 * 10, + count: 500, + window: 5, + }, + global: { + count: 20, + window: 5, + bot: 250, + }, + error: { + count: 10, + window: 5, + }, + routes: { + guild: { + count: 5, + window: 5, + }, + webhook: { + count: 5, + window: 5, + }, + channel: { + count: 5, + window: 5, + }, + auth: { + login: { + count: 5, + window: 60, + }, + register: { + count: 2, + window: 60 * 60 * 12, + }, + }, }, - routes: {}, }, }, security: { -- cgit 1.4.1