diff options
author | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-07-12 14:05:02 +0100 |
---|---|---|
committer | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-07-12 14:05:02 +0100 |
commit | 6ae30c9b15fcc200c7b642016e7adbfdf9b979f4 (patch) | |
tree | f645afba242a092e1e920582f37ae396e35b5e06 /NorthstarDLL/limits.h | |
parent | 1068b3daeb95322461e69a2d8f0203309bd22830 (diff) | |
download | NorthstarLauncher-6ae30c9b15fcc200c7b642016e7adbfdf9b979f4.tar.gz NorthstarLauncher-6ae30c9b15fcc200c7b642016e7adbfdf9b979f4.zip |
move exploit prevention and limits code out of serverauthentication, and have actual defs for CBasePlayer
Diffstat (limited to 'NorthstarDLL/limits.h')
-rw-r--r-- | NorthstarDLL/limits.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/NorthstarDLL/limits.h b/NorthstarDLL/limits.h new file mode 100644 index 00000000..2303ba5e --- /dev/null +++ b/NorthstarDLL/limits.h @@ -0,0 +1,44 @@ +#pragma once
+#include "r2server.h"
+#include "convar.h"
+#include <unordered_map>
+
+struct PlayerLimitData
+{
+ double lastClientCommandQuotaStart = -1.0;
+ int numClientCommandsInQuota = 0;
+
+ double lastNetChanProcessingLimitStart = -1.0;
+ double netChanProcessingLimitTime = 0.0;
+
+ double lastSayTextLimitStart = -1.0;
+ int sayTextLimitCount = 0;
+};
+
+struct UnconnectedPlayerLimitData
+{
+ char ip[16];
+ double lastQuotaStart = 0.0;
+ int packetCount = 0;
+ double timeoutEnd = -1.0;
+};
+
+class ServerLimitsManager
+{
+ public:
+ ConVar* CVar_sv_quota_stringcmdspersecond;
+ ConVar* Cvar_net_chan_limit_mode;
+ ConVar* Cvar_net_chan_limit_msec_per_sec;
+ ConVar* Cvar_sv_querylimit_per_sec;
+ ConVar* Cvar_sv_max_chat_messages_per_sec;
+
+ std::unordered_map<R2::CBasePlayer*, PlayerLimitData> m_PlayerLimitData;
+ std::vector<UnconnectedPlayerLimitData> m_UnconnectedPlayerLimitData;
+
+ public:
+ void AddPlayer(R2::CBasePlayer* player);
+ bool CheckStringCommandLimits(R2::CBasePlayer* player);
+ bool CheckChatLimits(R2::CBasePlayer* player);
+};
+
+extern ServerLimitsManager* g_pServerLimits;
|