mirror of
https://github.com/rehlds/rehlds.git
synced 2024-12-29 08:05:50 +03:00
Merge pull request #235 from Adidasman1/master
Fix already spawn and add cvar rehlds_security.
This commit is contained in:
commit
f18dbc8ce1
@ -47,7 +47,7 @@ Bugfixed version of rehlds contains an additional cvars:
|
||||
<li>sv_rehlds_stringcmdrate_max_avg // Max average level of 'string' cmds for ban. Default: 80
|
||||
<li>sv_rehlds_stringcmdrate_avg_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_stringcmdrate_max_burst // Max burst level of 'string' cmds for ban. Default: 400
|
||||
<li>sv_rehldsstringcmdrate_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_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". Default: ""
|
||||
</ul>
|
||||
|
||||
|
@ -570,7 +570,6 @@ void Host_Status_f(void)
|
||||
qboolean bConnectedToSteam3;
|
||||
const char *pchConnectionString = "";
|
||||
const char *pchSteamUniverse = "";
|
||||
char szfile[260];
|
||||
|
||||
if (cmd_source == src_command)
|
||||
{
|
||||
@ -583,12 +582,15 @@ void Host_Status_f(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef REHLDS_FIXES // Remove Useless Stuff
|
||||
char szfile[260];
|
||||
if (Cmd_Argc() == 2 && !Q_stricmp(Cmd_Argv(1), "log"))
|
||||
{
|
||||
log = TRUE;
|
||||
Q_snprintf(szfile, sizeof(szfile), "%s", "status.log");
|
||||
_unlink(szfile);
|
||||
}
|
||||
#endif // REHLDS_FIXES
|
||||
|
||||
Host_Status_Printf(conprint, log, "hostname: %s\n", Cvar_VariableString("hostname"));
|
||||
|
||||
|
@ -1060,7 +1060,11 @@ qboolean NET_QueuePacket(netsrc_t sock)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef REHLDS_FIXES
|
||||
Con_DPrintf("Invalid split packet length %i\n", in_message.cursize);
|
||||
#else
|
||||
Con_Printf("Invalid split packet length %i\n", in_message.cursize);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1690,6 +1690,14 @@ void EXT_FUNC SV_Spawn_f_internal(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
// Is already spawn
|
||||
if (host_client->spawned)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif // REHLDS_FIXES
|
||||
|
||||
host_client->crcValue = Q_atoi(Cmd_Argv(2));
|
||||
|
||||
COM_UnMunge2((unsigned char *)&host_client->crcValue, 4, (-1 - g_psvs.spawncount) & 0xFF);
|
||||
|
@ -53,7 +53,11 @@ qboolean nofind;
|
||||
*/
|
||||
#ifndef HOOK_ENGINE
|
||||
|
||||
#if defined(SWDS) && defined(REHLDS_FIXES)
|
||||
command_t clcommands[] = { "status", "name", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "setinfo", "sendents", "fullupdate", "setpause", "unpause", NULL };
|
||||
#else
|
||||
command_t clcommands[23] = { "status", "god", "notarget", "fly", "name", "noclip", "kill", "pause", "spawn", "new", "sendres", "dropclient", "kick", "ping", "dlfile", "nextdl", "setinfo", "showinfo", "sendents", "fullupdate", "setpause", "unpause", NULL };
|
||||
#endif
|
||||
|
||||
cvar_t sv_edgefriction = { "edgefriction", "2", FCVAR_SERVER, 0.0f, NULL };
|
||||
cvar_t sv_maxspeed = { "sv_maxspeed", "320", FCVAR_SERVER, 0.0f, NULL };
|
||||
@ -1817,7 +1821,12 @@ void SV_ShowServerinfo_f(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef REHLDS_FIXES
|
||||
// fix print message client console
|
||||
SV_ClientPrintf(Info_Serverinfo());
|
||||
#else
|
||||
Info_Print(Info_Serverinfo());
|
||||
#endif // REHLDS_FIXES
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ struct RehldsFuncs_t {
|
||||
void(*Steam_NotifyClientDisconnect)(IGameClient* cl);
|
||||
void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch);
|
||||
bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin);
|
||||
void (* SV_UpdateUserInfo)(IGameClient *pGameClient);
|
||||
void(*SV_UpdateUserInfo)(IGameClient *pGameClient);
|
||||
};
|
||||
|
||||
class IRehldsApi {
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
cvar_t sv_rehlds_movecmdrate_max_avg = { "sv_rehlds_movecmdrate_max_avg", "400", 0, 400.0f, NULL };
|
||||
cvar_t sv_rehlds_movecmdrate_max_burst = { "sv_rehlds_movecmdrate_max_burst", "2500", 0, 2500.0f, NULL };
|
||||
cvar_t sv_rehlds_stringcmdrate_max_avg = {"sv_rehlds_stringcmdrate_max_avg", "80", 0, 80.0f, NULL};
|
||||
cvar_t sv_rehlds_stringcmdrate_max_burst = {"sv_rehlds_stringcmdrate_max_burst", "400", 0, 400.0f, NULL};
|
||||
cvar_t sv_rehlds_movecmdrate_max_avg = { "sv_rehlds_movecmdrate_max_avg", "1800", 0, 1800.0f, NULL };
|
||||
cvar_t sv_rehlds_movecmdrate_max_burst = { "sv_rehlds_movecmdrate_max_burst", "5500", 0, 5500.0f, NULL };
|
||||
cvar_t sv_rehlds_stringcmdrate_max_avg = { "sv_rehlds_stringcmdrate_max_avg", "250", 0, 250.0f, NULL };
|
||||
cvar_t sv_rehlds_stringcmdrate_max_burst = { "sv_rehlds_stringcmdrate_max_burst", "500", 0, 500.0f, NULL };
|
||||
|
||||
cvar_t sv_rehlds_movecmdrate_avg_punish = { "sv_rehlds_movecmdrate_avg_punish", "5", 0, 5.0f, NULL };
|
||||
cvar_t sv_rehlds_movecmdrate_burst_punish = { "sv_rehlds_movecmdrate_burst_punish", "5", 0, 5.0f, NULL };
|
||||
cvar_t sv_rehlds_stringcmdrate_avg_punish = {"sv_rehlds_stringcmdrate_avg_punish", "5", 0, 5.0f, NULL};
|
||||
cvar_t sv_rehlds_stringcmdrate_burst_punish = {"sv_rehlds_stringcmdrate_burst_punish", "5", 0, 5.0f, NULL};
|
||||
cvar_t sv_rehlds_stringcmdrate_avg_punish = { "sv_rehlds_stringcmdrate_avg_punish", "5", 0, 5.0f, NULL };
|
||||
cvar_t sv_rehlds_stringcmdrate_burst_punish = { "sv_rehlds_stringcmdrate_burst_punish", "5", 0, 5.0f, NULL };
|
||||
|
||||
CMoveCommandRateLimiter g_MoveCommandRateLimiter;
|
||||
CStringCommandsRateLimiter g_StringCommandsRateLimiter;
|
||||
@ -62,9 +62,12 @@ void CMoveCommandRateLimiter::CheckBurstRate(unsigned int clientId) {
|
||||
}
|
||||
if ((m_CurrentMoveCmds[clientId] / dt) > sv_rehlds_movecmdrate_max_burst.value) {
|
||||
if(sv_rehlds_movecmdrate_burst_punish.value < 0) {
|
||||
Con_DPrintf("%s Kicked for move commands flooding (burst) (%.1f)\n", cl->name, (m_CurrentMoveCmds[clientId] / dt));
|
||||
SV_DropClient(cl, false, "Kicked for move commands flooding (burst)");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
Con_DPrintf("%s Banned for move commands flooding (burst) (%.1f)\n", cl->name, (m_CurrentMoveCmds[clientId] / dt));
|
||||
Cbuf_AddText(va("addip %.1f %s\n", sv_rehlds_movecmdrate_burst_punish.value, NET_BaseAdrToString(cl->netchan.remote_address)));
|
||||
SV_DropClient(cl, false, "Banned for move commands flooding (burst)");
|
||||
}
|
||||
@ -76,12 +79,15 @@ void CMoveCommandRateLimiter::CheckAverageRate(unsigned int clientId) {
|
||||
if (!cl->active || sv_rehlds_movecmdrate_max_burst.value <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (m_AverageMoveCmdRate[clientId] > sv_rehlds_movecmdrate_max_avg.value) {
|
||||
if(sv_rehlds_movecmdrate_avg_punish.value < 0) {
|
||||
Con_DPrintf("%s Kicked for move commands flooding (Avg) (%.1f)\n", cl->name, m_AverageMoveCmdRate[clientId]);
|
||||
SV_DropClient(cl, false, "Kicked for move commands flooding (Avg)");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
Con_DPrintf("%s Banned for move commands flooding (Avg) (%.1f)\n", cl->name, m_AverageMoveCmdRate[clientId]);
|
||||
Cbuf_AddText(va("addip %.1f %s\n", sv_rehlds_movecmdrate_avg_punish.value, NET_BaseAdrToString(cl->netchan.remote_address)));
|
||||
SV_DropClient(cl, false, "Banned for move commands flooding (Avg)");
|
||||
}
|
||||
@ -137,9 +143,12 @@ void CStringCommandsRateLimiter::CheckBurstRate(unsigned int clientId) {
|
||||
}
|
||||
if ((m_CurrentStringCmds[clientId] / dt) > sv_rehlds_stringcmdrate_max_burst.value) {
|
||||
if(sv_rehlds_stringcmdrate_burst_punish.value < 0) {
|
||||
Con_DPrintf("%s Kicked for string commands flooding (burst) (%.1f)\n", cl->name, (m_CurrentStringCmds[clientId] / dt));
|
||||
SV_DropClient(cl, false, "Kicked for string commands flooding (burst)");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
Con_DPrintf("%s Banned for string commands flooding (burst) (%.1f)\n", cl->name, (m_CurrentStringCmds[clientId] / dt));
|
||||
Cbuf_AddText(va("addip %.1f %s\n", sv_rehlds_stringcmdrate_burst_punish.value, NET_BaseAdrToString(cl->netchan.remote_address)));
|
||||
SV_DropClient(cl, false, "Banned for string commands flooding (burst)");
|
||||
}
|
||||
@ -154,9 +163,12 @@ void CStringCommandsRateLimiter::CheckAverageRate(unsigned int clientId) {
|
||||
|
||||
if (m_AverageStringCmdRate[clientId] > sv_rehlds_stringcmdrate_max_avg.value) {
|
||||
if(sv_rehlds_stringcmdrate_avg_punish.value < 0) {
|
||||
Con_DPrintf("%s Kicked for string commands flooding (Avg) (%.1f)\n", cl->name, m_AverageStringCmdRate[clientId]);
|
||||
SV_DropClient(cl, false, "Kicked for string commands flooding (Avg)");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
Con_DPrintf("%s Banned for string commands flooding (Avg) (%.1f)\n", cl->name, m_AverageStringCmdRate[clientId]);
|
||||
Cbuf_AddText(va("addip %.1f %s\n", sv_rehlds_stringcmdrate_avg_punish.value, NET_BaseAdrToString(cl->netchan.remote_address)));
|
||||
SV_DropClient(cl, false, "Banned for string commands flooding (Avg)");
|
||||
}
|
||||
@ -169,6 +181,11 @@ void Rehlds_Security_Init() {
|
||||
Cvar_RegisterVariable(&sv_rehlds_movecmdrate_max_burst);
|
||||
Cvar_RegisterVariable(&sv_rehlds_stringcmdrate_max_avg);
|
||||
Cvar_RegisterVariable(&sv_rehlds_stringcmdrate_max_burst);
|
||||
|
||||
Cvar_RegisterVariable(&sv_rehlds_movecmdrate_avg_punish);
|
||||
Cvar_RegisterVariable(&sv_rehlds_movecmdrate_burst_punish);
|
||||
Cvar_RegisterVariable(&sv_rehlds_stringcmdrate_avg_punish);
|
||||
Cvar_RegisterVariable(&sv_rehlds_stringcmdrate_burst_punish);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user