2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

Merge pull request #660 from dreamstalker/cll_hookchain

Add hookchain for connectionless limiter
This commit is contained in:
theAsmodai 2018-09-29 12:47:42 +03:00 committed by GitHub
commit 89be2166ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 9 deletions

View File

@ -3601,7 +3601,7 @@ void SV_ReadPackets(void)
if (*(uint32 *)net_message.data == 0xFFFFFFFF) if (*(uint32 *)net_message.data == 0xFFFFFFFF)
{ {
// Connectionless packet // Connectionless packet
if (SV_CheckConnectionLessRateLimits(net_from)) if (g_RehldsHookchains.m_SV_CheckConnectionLessRateLimits.callChain([](netadr_t& net_from, const uint8_t *, int) { return SV_CheckConnectionLessRateLimits(net_from); }, net_from, net_message.data, net_message.cursize))
{ {
#ifdef REHLDS_FIXES #ifdef REHLDS_FIXES
if (SV_FilterPacket()) if (SV_FilterPacket())

View File

@ -37,7 +37,7 @@
#include "pr_dlls.h" #include "pr_dlls.h"
#define REHLDS_API_VERSION_MAJOR 3 #define REHLDS_API_VERSION_MAJOR 3
#define REHLDS_API_VERSION_MINOR 4 #define REHLDS_API_VERSION_MINOR 5
//Steam_NotifyClientConnect hook //Steam_NotifyClientConnect hook
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect; typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@ -195,6 +195,10 @@ typedef IHookChainRegistry<bool, edict_t *, IGameClient *, int, const char*, flo
typedef IHookChain<edict_t *, const char *> IRehldsHook_CreateFakeClient; typedef IHookChain<edict_t *, const char *> IRehldsHook_CreateFakeClient;
typedef IHookChainRegistry<edict_t *, const char *> IRehldsHookRegistry_CreateFakeClient; typedef IHookChainRegistry<edict_t *, const char *> IRehldsHookRegistry_CreateFakeClient;
//SV_CheckConnectionLessRateLimits
typedef IHookChain<bool, netadr_t &, const uint8_t *, int> IRehldsHook_SV_CheckConnectionLessRateLimits;
typedef IHookChainRegistry<bool, netadr_t &, const uint8_t *, int> IRehldsHookRegistry_SV_CheckConnectionLessRateLimits;
class IRehldsHookchains { class IRehldsHookchains {
public: public:
virtual ~IRehldsHookchains() { } virtual ~IRehldsHookchains() { }
@ -238,6 +242,7 @@ public:
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0; virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0;
virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0; virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0;
virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient() = 0; virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient() = 0;
virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits() = 0;
}; };
struct RehldsFuncs_t { struct RehldsFuncs_t {

View File

@ -571,6 +571,11 @@ IRehldsHookRegistry_CreateFakeClient* CRehldsHookchains::CreateFakeClient() {
return &m_CreateFakeClient; return &m_CreateFakeClient;
} }
IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* CRehldsHookchains::SV_CheckConnectionLessRateLimits()
{
return &m_SV_CheckConnectionLessRateLimits;
}
int EXT_FUNC CRehldsApi::GetMajorVersion() int EXT_FUNC CRehldsApi::GetMajorVersion()
{ {
return REHLDS_API_VERSION_MAJOR; return REHLDS_API_VERSION_MAJOR;

View File

@ -190,6 +190,10 @@ typedef IHookChainRegistryImpl<bool, edict_t *, IGameClient *, int, const char*,
typedef IHookChainImpl<edict_t *, const char *> CRehldsHook_CreateFakeClient; typedef IHookChainImpl<edict_t *, const char *> CRehldsHook_CreateFakeClient;
typedef IHookChainRegistryImpl<edict_t *, const char *> CRehldsHookRegistry_CreateFakeClient; typedef IHookChainRegistryImpl<edict_t *, const char *> CRehldsHookRegistry_CreateFakeClient;
//SV_CheckConnectionLessRateLimits hook
typedef IHookChainImpl<bool, netadr_t &, const uint8_t *, int> CRehldsHook_SV_CheckConnectionLessRateLimits;
typedef IHookChainRegistryImpl<bool, netadr_t &, const uint8_t *, int> CRehldsHookRegistry_SV_CheckConnectionLessRateLimits;
class CRehldsHookchains : public IRehldsHookchains { class CRehldsHookchains : public IRehldsHookchains {
public: public:
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
@ -231,6 +235,7 @@ public:
CRehldsHookRegistry_SV_CreatePacketEntities m_SV_CreatePacketEntities; CRehldsHookRegistry_SV_CreatePacketEntities m_SV_CreatePacketEntities;
CRehldsHookRegistry_SV_EmitSound2 m_SV_EmitSound2; CRehldsHookRegistry_SV_EmitSound2 m_SV_EmitSound2;
CRehldsHookRegistry_CreateFakeClient m_CreateFakeClient; CRehldsHookRegistry_CreateFakeClient m_CreateFakeClient;
CRehldsHookRegistry_SV_CheckConnectionLessRateLimits m_SV_CheckConnectionLessRateLimits;
public: public:
EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
@ -260,18 +265,19 @@ public:
EXT_FUNC virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I(); EXT_FUNC virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I();
EXT_FUNC virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate(); EXT_FUNC virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate();
EXT_FUNC virtual IRehldsHookRegistry_SV_CheckConsistencyResponse* SV_CheckConsistencyResponse(); EXT_FUNC virtual IRehldsHookRegistry_SV_CheckConsistencyResponse* SV_CheckConsistencyResponse();
EXT_FUNC virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient(); EXT_FUNC virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient();
EXT_FUNC virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer(); EXT_FUNC virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer();
EXT_FUNC virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec(); EXT_FUNC virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec();
EXT_FUNC virtual IRehldsHookRegistry_Steam_GSGetSteamID* Steam_GSGetSteamID(); EXT_FUNC virtual IRehldsHookRegistry_Steam_GSGetSteamID* Steam_GSGetSteamID();
EXT_FUNC virtual IRehldsHookRegistry_SV_TransferConsistencyInfo* SV_TransferConsistencyInfo(); EXT_FUNC virtual IRehldsHookRegistry_SV_TransferConsistencyInfo* SV_TransferConsistencyInfo();
EXT_FUNC virtual IRehldsHookRegistry_Steam_GSBUpdateUserData* Steam_GSBUpdateUserData(); EXT_FUNC virtual IRehldsHookRegistry_Steam_GSBUpdateUserData* Steam_GSBUpdateUserData();
EXT_FUNC virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet(); EXT_FUNC virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet();
EXT_FUNC virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase(); EXT_FUNC virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase();
EXT_FUNC virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f(); EXT_FUNC virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f();
EXT_FUNC virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities(); EXT_FUNC virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities();
EXT_FUNC virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2(); EXT_FUNC virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2();
EXT_FUNC virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient(); EXT_FUNC virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient();
EXT_FUNC virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits();
}; };
extern CRehldsHookchains g_RehldsHookchains; extern CRehldsHookchains g_RehldsHookchains;