diff --git a/server/config.example.toml b/server/config.example.toml index 50431d9..5c7f257 100644 --- a/server/config.example.toml +++ b/server/config.example.toml @@ -14,6 +14,7 @@ charlimit = 100 agentsDir = "agents/" maxConnectionsPerIP = 2 adminPasswordHash = "f52fbd32b2b3b86ff88ef6c490628285f482af15ddcb29541f94bcf526a3f6c7" +bannedWords = [] [chat.ratelimits] chat = {seconds = 10, limit = 8} diff --git a/server/src/client.ts b/server/src/client.ts index f2b87de..fb9372e 100644 --- a/server/src/client.ts +++ b/server/src/client.ts @@ -103,6 +103,10 @@ export class Client extends EventEmitter { return; } let username = htmlentities.encode(joinMsg.data.username); + if (this.room.config.bannedWords.some(w => username.indexOf(w) !== -1)) { + this.socket.close(); + return; + } if (this.room.clients.some(u => u.username === username)) { let i = 1; let uo = username; @@ -125,6 +129,9 @@ export class Client extends EventEmitter { return; } if (talkMsg.data.msg.length > this.room.config.charlimit) return; + if (this.room.config.bannedWords.some(w => talkMsg.data.msg.indexOf(w) !== -1)) { + return; + } this.emit('talk', talkMsg.data.msg); break; } diff --git a/server/src/config.ts b/server/src/config.ts index ac4d0ae..3c468a0 100644 --- a/server/src/config.ts +++ b/server/src/config.ts @@ -24,6 +24,7 @@ export interface ChatConfig { agentsDir: string; maxConnectionsPerIP: number; adminPasswordHash: string; + bannedWords: string[]; ratelimits: { chat: RateLimitConfig; }