From 693b51c8839847270048be40b62fb1d37f9954ae Mon Sep 17 00:00:00 2001 From: s1lentq Date: Fri, 10 May 2024 18:04:43 +0700 Subject: [PATCH] Improved behavior of sv_filterban 0. Fixes #1027 --- README.md | 1 + rehlds/engine/sv_main.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b824c15..9098f12 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
  • sv_net_incoming_decompression_max_size <16|65536> // Sets the max allowed size for decompressed file transfer data. Default: 65536 bytes
  • sv_net_incoming_decompression_punish // Time in minutes for which the player will be banned for malformed/abnormal bzip2 fragments (0 - Permanent, use a negative number for a kick). Default: -1
  • sv_tags <comma-delimited string list of tags> // Sets a string defining the "gametags" for this server, this is optional, but if it is set it allows users/scripts to filter in the matchmaking/server-browser interfaces based on the value. Default: "" +
  • sv_filterban <-1|0|1>// Set packet filtering by IP mode. -1 - All players will be rejected without any exceptions. 0 - No checks will happen. 1 - All incoming players will be checked if they're IP banned (if they have an IP filter entry), if they are, they will be kicked. Default: 1 diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 8f99c0f..dc2c517 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -3836,13 +3836,20 @@ void SV_ProcessFile(client_t *cl, char *filename) qboolean SV_FilterPacket(void) { + // sv_filterban filtering IP mode + // -1: all players will be rejected without any exceptions + // 0: no checks will happen + // 1: all incoming players will be checked if they're IP banned (if they have an IP filter entry), if they are, they will be kicked + + qboolean bNegativeFilter = (sv_filterban.value == 1) ? TRUE : FALSE; + for (int i = numipfilters - 1; i >= 0; i--) { ipfilter_t* curFilter = &ipfilters[i]; if (curFilter->compare.u32 == 0xFFFFFFFF || curFilter->banEndTime == 0.0f || curFilter->banEndTime > realtime) { if ((*(uint32*)net_from.ip & curFilter->mask) == curFilter->compare.u32) - return (int)sv_filterban.value; + return bNegativeFilter; } else { @@ -3852,7 +3859,8 @@ qboolean SV_FilterPacket(void) --numipfilters; } } - return sv_filterban.value == 0.0f; + + return !bNegativeFilter; } void SV_SendBan(void)