diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-12 18:57:43 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-12 18:57:43 +0200 |
commit | 407faf77c80a8cfd10a59f85066a32e39d0020e5 (patch) | |
tree | b9fc6d2fc0c08bcfd79b4fea3dc9077ab18ecd92 /src/util/Config.ts | |
parent | 1.3.51 (diff) | |
download | server-407faf77c80a8cfd10a59f85066a32e39d0020e5.tar.xz |
:sparkles: config add rate limit
Diffstat (limited to '')
-rw-r--r-- | src/util/Config.ts | 60 |
1 files changed, 47 insertions, 13 deletions
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<RateLimitOptions, "bot_count">; + 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: { |