From 2df9b984a1f73ec54cb546e3f57707ec22468392 Mon Sep 17 00:00:00 2001 From: "Tony J. White" Date: Fri, 19 Jan 2007 18:18:13 +0000 Subject: * rate limit the acknowledgment of gamestat messages in the master server to prevent DoS --- src/master/messages.c | 13 ++++++++++--- src/master/servers.h | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src/master') diff --git a/src/master/messages.c b/src/master/messages.c index b30bc334..90fb223c 100644 --- a/src/master/messages.c +++ b/src/master/messages.c @@ -544,9 +544,16 @@ void HandleMessage (const char* msg, size_t length, HandleGetMotd (msg + strlen (C2M_GETMOTD), address); } - // If it's a game statistic + // If it's a game statistic else if( !strncmp( S2M_GAMESTAT, msg, strlen ( S2M_GAMESTAT ) ) ) - { - HandleGameStat( msg + strlen( S2M_GAMESTAT ), address ); + { + server = Sv_GetByAddr(address, qfalse); + if (server == NULL) + return; + if( crt_time - server->lastGameStat > MIN_GAMESTAT_DELAY ) + HandleGameStat( msg + strlen( S2M_GAMESTAT ), address ); + else + MsgPrint( MSG_NORMAL, "%s flooding GAMESTAT messages\n", peer_address ); + server->lastGameStat = crt_time; } } diff --git a/src/master/servers.h b/src/master/servers.h index fbeef1c2..8165b66b 100644 --- a/src/master/servers.h +++ b/src/master/servers.h @@ -38,6 +38,9 @@ #define CHALLENGE_MIN_LENGTH 9 #define CHALLENGE_MAX_LENGTH 12 +// Minimum number of seconds between gamestat messages per server +#define MIN_GAMESTAT_DELAY 120 + // ---------- Types ---------- // // Address mapping @@ -63,6 +66,7 @@ typedef struct server_s time_t challenge_timeout; const struct addrmap_s* addrmap; qboolean active; + time_t lastGameStat; } server_t; -- cgit