ioQuake3/Tremulous already has a packet limiter exactly for the relevant purposes. unfortunately, it is applied only for getstatus requests, but not getinfo requests. here's an example patch to fix that (includes a bit of my limiting preferences):
--- a/src/server/sv_main.c
+++ b/src/server/sv_main.c
@@ -566,6 +566,8 @@ static qboolean SVC_RateLimitAddress( netadr_t from, int burst, int period ) {
return SVC_RateLimit( bucket, burst, period );
}
+static leakyBucket_t outboundLeakyBucket;
+
/*
================
SVC_Status
@@ -584,10 +586,9 @@ static void SVC_Status( netadr_t from ) {
int statusLength;
int playerLength;
char infostring[MAX_INFO_STRING];
- static leakyBucket_t bucket;
// Prevent using getstatus as an amplifier
- if ( SVC_RateLimitAddress( from, 10, 1000 ) ) {
+ if ( SVC_RateLimitAddress( from, 10, 2000 ) ) {
Com_DPrintf( "SVC_Status: rate limit from %s exceeded, dropping request\n",
NET_AdrToString( from ) );
return;
@@ -595,7 +596,7 @@ static void SVC_Status( netadr_t from ) {
// Allow getstatus to be DoSed relatively easily, but prevent
// excess outbound bandwidth usage when being flooded inbound
- if ( SVC_RateLimit( &bucket, 10, 100 ) ) {
+ if ( SVC_RateLimit( &outboundLeakyBucket, 20, 100 ) ) {
Com_DPrintf( "SVC_Status: rate limit exceeded, dropping request\n" );
return;
}
@@ -640,6 +641,20 @@ void SVC_Info( netadr_t from ) {
char *gamedir;
char infostring[MAX_INFO_STRING];
+ // Prevent using getinfo as an amplifier
+ if ( SVC_RateLimitAddress( from, 10, 2000 ) ) {
+ Com_DPrintf( "SVC_Info: rate limit from %s exceeded, dropping request\n",
+ NET_AdrToString( from ) );
+ return;
+ }
+
+ // Allow getinfo to be DoSed relatively easily, but prevent
+ // excess outbound bandwidth usage when being flooded inbound
+ if ( SVC_RateLimit( &outboundLeakyBucket, 20, 100 ) ) {
+ Com_DPrintf( "SVC_Info: rate limit exceeded, dropping request\n" );
+ return;
+ }
+
/*
* Check whether Cmd_Argv(1) has a sane length. This was not done in the original Quake3 version which led
* to the Infostring bug discovered by Luigi Auriemma. See http://aluigi.altervista.org/ for the advisory.