diff --git a/README.md b/README.md index c5aabb9..f6406e0 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Bugfixed version of rehlds contains an additional cvars:
  • sv_rehlds_stringcmdrate_burst_punish // Time in minutes for which the player will be banned (0 - Permanent, use a negative number for a kick). Default: 5
  • sv_rehlds_userinfo_transmitted_fields // Userinfo fields only with these keys will be transmitted to clients via network. If not set then all fields will be transmitted (except prefixed with underscore). Each key must be prefixed by backslash, for example "\name\model\*sid\*hltv\bottomcolor\topcolor". See [wiki](https://github.com/dreamstalker/rehlds/wiki/Userinfo-keys) to collect sufficient set of keys for your server. Default: ""
  • sv_rehlds_attachedentities_playeranimationspeed_fix // Fixes bug with gait animation speed increase when player has some attached entities (aiments). Can cause animation lags when cl_updaterate is low. Default: 0 +
  • sv_rehlds_maxclients_from_single_ip // Limit number of connections from the single ip address. Default: 5 ## Commands diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 5e1ef8a..8bec12a 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -202,6 +202,7 @@ cvar_t sv_rehlds_userinfo_transmitted_fields = { "sv_rehlds_userinfo_transmitted cvar_t sv_rehlds_attachedentities_playeranimationspeed_fix = {"sv_rehlds_attachedentities_playeranimationspeed_fix", "0", 0, 0.0f, nullptr}; cvar_t sv_rehlds_local_gametime = {"sv_rehlds_local_gametime", "0", 0, 0.0f, nullptr}; cvar_t sv_rehlds_send_mapcycle = { "sv_rehlds_send_mapcycle", "0", 0, 0.0f, nullptr }; +cvar_t sv_rehlds_maxclients_from_single_ip = { "sv_rehlds_maxclients_from_single_ip", "5", 0, 5.0f, nullptr }; #endif delta_t *SV_LookupDelta(char *name) @@ -1860,11 +1861,20 @@ int SV_CheckIPConnectionReuse(netadr_t *adr) } } +#ifdef REHLDS_FIXES + if (count > (int)sv_rehlds_maxclients_from_single_ip.value) + { + Log_Printf("Too many connect packets from %s (%i>%i)\n", NET_AdrToString(*adr), count, (int)sv_rehlds_maxclients_from_single_ip.value); + SV_RejectConnection(adr, "Too many connect packets from your ip address\n"); + return 0; + } +#else if (count > 5) { Log_Printf("Too many connect packets from %s\n", NET_AdrToString(*adr)); return 0; } +#endif return 1; } @@ -7798,6 +7808,7 @@ void SV_Init(void) Cvar_RegisterVariable(&sv_rehlds_attachedentities_playeranimationspeed_fix); Cvar_RegisterVariable(&sv_rehlds_local_gametime); Cvar_RegisterVariable(&sv_rehlds_send_mapcycle); + Cvar_RegisterVariable(&sv_rehlds_maxclients_from_single_ip); Cvar_RegisterVariable(&sv_rollspeed); Cvar_RegisterVariable(&sv_rollangle);