diff options
author | Tim Angus <tim@ngus.net> | 2013-06-10 20:30:48 +0100 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2014-06-17 17:43:32 +0100 |
commit | fd7072f74ce183c840dd65d8983dfa159374c7c0 (patch) | |
tree | 1c7cbe5bdda98a8d752bac9460ed2ea8e30bb848 /src/server/sv_main.c | |
parent | 92844d4646be3fa958e5d9e1ce2ff4b282018b20 (diff) |
Rate limit getchallenge
Diffstat (limited to 'src/server/sv_main.c')
-rw-r--r-- | src/server/sv_main.c | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/src/server/sv_main.c b/src/server/sv_main.c index d7d8e2f6..aad063e2 100644 --- a/src/server/sv_main.c +++ b/src/server/sv_main.c @@ -371,30 +371,13 @@ CONNECTIONLESS COMMANDS ============================================================================== */ -typedef struct leakyBucket_s leakyBucket_t; -struct leakyBucket_s { - netadrtype_t type; - - union { - byte _4[4]; - byte _6[16]; - } ipv; - - int lastTime; - signed char burst; - - long hash; - - leakyBucket_t *prev, *next; -}; - // This is deliberately quite large to make it more of an effort to DoS #define MAX_BUCKETS 16384 #define MAX_HASHES 1024 static leakyBucket_t buckets[ MAX_BUCKETS ]; static leakyBucket_t *bucketHashes[ MAX_HASHES ]; -static leakyBucket_t outboundLeakyBucket; +leakyBucket_t outboundLeakyBucket; /* ================ @@ -511,7 +494,7 @@ static leakyBucket_t *SVC_BucketForAddress( netadr_t address, int burst, int per SVC_RateLimit ================ */ -static qboolean SVC_RateLimit( leakyBucket_t *bucket, int burst, int period ) { +qboolean SVC_RateLimit( leakyBucket_t *bucket, int burst, int period ) { if ( bucket != NULL ) { int now = Sys_Milliseconds(); int interval = now - bucket->lastTime; @@ -543,7 +526,7 @@ SVC_RateLimitAddress Rate limit for a particular address ================ */ -static qboolean SVC_RateLimitAddress( netadr_t from, int burst, int period ) { +qboolean SVC_RateLimitAddress( netadr_t from, int burst, int period ) { leakyBucket_t *bucket = SVC_BucketForAddress( from, burst, period ); return SVC_RateLimit( bucket, burst, period ); |