diff --git a/src/d_clisrv.c b/src/d_clisrv.c index be16c4254..dce348edc 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -222,6 +222,8 @@ consvar_t cv_httpsource = CVAR_INIT ("http_source", "", CV_SAVE, NULL, NULL); consvar_t cv_kicktime = CVAR_INIT ("kicktime", "10", CV_SAVE, CV_Unsigned, NULL); +static tic_t stop_spamming[MAXPLAYERS]; + // Generate a message for an authenticating client to sign, with some guarantees about who we are. void GenerateChallenge(uint8_t *buf) { @@ -5250,6 +5252,36 @@ static void HandlePacketFromPlayer(SINT8 node) if (playernode[say.source] != node) break; // Spoofed source! + if ((cv_mute.value || say.flags & (HU_CSAY|HU_SHOUT)) && say.source != serverplayer && !(IsPlayerAdmin(say.source))) + { + CONS_Debug(DBG_NETPLAY,"Received SAY cmd from Player %d (%s), but cv_mute is on.\n", say.source+1, player_names[say.source]); + break; + } + + { + size_t i; + const size_t j = strlen(say.message); + for (i = 0; i < j; i++) + { + if (say.message[i] & 0x80) + { + CONS_Alert(CONS_WARNING, M_GetText("Illegal say command received from %s containing invalid characters\n"), player_names[say.source]); + if (server) + SendKick(say.source, KICK_MSG_CON_FAIL); + return; + } + } + } + + if (stop_spamming[say.source] != 0 && consoleplayer != say.source && cv_chatspamprotection.value && !(say.flags & (HU_CSAY|HU_SHOUT))) + { + CONS_Debug(DBG_NETPLAY,"Received SAY cmd too quickly from Player %d (%s), assuming as spam and blocking message.\n", say.source+1, player_names[say.source]); + stop_spamming[say.source] = 4; + break; + } + + stop_spamming[say.source] = 4; + DoSayCommand(say.message, say.target, say.flags, say.source); break; case PT_LOGIN: @@ -6806,6 +6838,15 @@ void NetUpdate(void) } } + if (server) + { + for(; (i 0) + stop_spamming[i]--; + } + } + Net_AckTicker(); HandleNodeTimeouts(); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index a64c5548b..6c0311f51 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -66,12 +66,6 @@ #define HU_INPUTX 0 #define HU_INPUTY 0 -typedef enum -{ - HU_SHOUT = 1, // Shout message - HU_CSAY = 1<<1, // Middle-of-screen server message -} sayflags_t; - //------------------------------------------- // heads up font //------------------------------------------- @@ -622,8 +616,6 @@ static void Command_Shout(void) DoSayPacketFromCommand(0, 1, HU_SHOUT); } -static tic_t stop_spamming[MAXPLAYERS]; - /** Receives a message, processing an ::XD_SAY command. * \sa DoSayPacket * \author Graue @@ -930,13 +922,6 @@ void HU_Ticker(void) { size_t i = 0; - // handle spam while we're at it: - for(; (i 0) - stop_spamming[i]--; - } - // handle chat timers for (i=0; (i