diff options
author | Tony J. White <tjw@tjw.org> | 2007-01-19 18:18:13 +0000 |
---|---|---|
committer | Tony J. White <tjw@tjw.org> | 2007-01-19 18:18:13 +0000 |
commit | 2df9b984a1f73ec54cb546e3f57707ec22468392 (patch) | |
tree | eca71b187cb2546c7a6152e3ec2c5938113b75e0 /src/master | |
parent | f57b74635da93485851fb2e722bd765194c899a9 (diff) |
* rate limit the acknowledgment of gamestat messages in the master server
to prevent DoS
Diffstat (limited to 'src/master')
-rw-r--r-- | src/master/messages.c | 13 | ||||
-rw-r--r-- | src/master/servers.h | 4 |
2 files changed, 14 insertions, 3 deletions
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; |