Skip to content

Commit

Permalink
Added sv_rehlds_maxclients_from_single_ip cvar (#610)
Browse files Browse the repository at this point in the history
Correctly reject overlimit connections
  • Loading branch information
theAsmodai committed May 7, 2018
1 parent 19c22d7 commit 87a10a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -54,6 +54,7 @@ Bugfixed version of rehlds contains an additional cvars:
<li>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
<li>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: ""
<li>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
<li>sv_rehlds_maxclients_from_single_ip // Limit number of connections from the single ip address. Default: 5
</ul>

## Commands
Expand Down
11 changes: 11 additions & 0 deletions rehlds/engine/sv_main.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 87a10a1

Please sign in to comment.