From 8390334d1e1dbe1bb835b9ce1ab9e24670881b7b Mon Sep 17 00:00:00 2001 From: deathride58 Date: Wed, 1 Jan 2020 18:59:05 -0500 Subject: [PATCH] mirrors tgstation 48524 --- code/modules/goonchat/browserOutput.dm | 25 ++++++++++++++++++- .../browserassets/js/browserOutput.js | 4 +-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/code/modules/goonchat/browserOutput.dm b/code/modules/goonchat/browserOutput.dm index c273690571..6f1e19d5e0 100644 --- a/code/modules/goonchat/browserOutput.dm +++ b/code/modules/goonchat/browserOutput.dm @@ -8,6 +8,8 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("tmp/iconCache.sav")) //Cache of ico //On client, created on login /datum/chatOutput var/client/owner //client ref + var/total_checks = 0 + var/last_check = 0 var/loaded = FALSE // Has the client loaded the browser output area? var/list/messageQueue //If they haven't loaded chat, this is where messages will go until they do var/cookieSent = FALSE // Has the client sent a cookie for analysis @@ -150,6 +152,18 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("tmp/iconCache.sav")) //Cache of ico //Called by client, sent data to investigate (cookie history so far) /datum/chatOutput/proc/analyzeClientData(cookie = "") + //Spam check + if(world.time > last_check + (3 SECONDS)) + last_check = world.time + total_checks = 0 + + total_checks += 1 + + if(total_checks > SPAM_TRIGGER_AUTOMUTE) + message_admins("[key_name(owner)] kicked for goonchat topic spam") + qdel(owner) + return + if(!cookie) return @@ -158,13 +172,22 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("tmp/iconCache.sav")) //Cache of ico if (connData && islist(connData) && connData.len > 0 && connData["connData"]) connectionHistory = connData["connData"] //lol fuck var/list/found = new() - for(var/i in connectionHistory.len to 1 step -1) + if(connectionHistory.len > 5) + message_admins("[key_name(src.owner)] was kicked for an invalid ban cookie)") + qdel(owner) + return + + for(var/i in min(connectionHistory.len, 5) to 1 step -1) + if(QDELETED(owner)) + //he got cleaned up before we were done + return var/list/row = src.connectionHistory[i] if (!row || row.len < 3 || (!row["ckey"] || !row["compid"] || !row["ip"])) //Passed malformed history object return if (world.IsBanned(row["ckey"], row["ip"], row["compid"], real_bans_only=TRUE)) found = row break + CHECK_TICK //Uh oh this fucker has a history of playing on a banned account!! if (found.len > 0) diff --git a/code/modules/goonchat/browserassets/js/browserOutput.js b/code/modules/goonchat/browserassets/js/browserOutput.js index abd05d29ed..823ad107d2 100644 --- a/code/modules/goonchat/browserassets/js/browserOutput.js +++ b/code/modules/goonchat/browserassets/js/browserOutput.js @@ -421,8 +421,8 @@ function handleClientData(ckey, ip, compid) { return; //Record already exists } } - - if (opts.clientData.length >= opts.clientDataLimit) { + //Lets make sure we obey our limit (can connect from server with higher limit) + while (opts.clientData.length >= opts.clientDataLimit) { opts.clientData.shift(); } } else {