2022-02-06 16:48:52 +01:00
|
|
|
#pragma once
|
2023-01-29 15:24:24 +01:00
|
|
|
#include "tier1/NetAdr.h"
|
2022-02-08 16:32:00 +01:00
|
|
|
#include "tier2/socketcreator.h"
|
2022-02-13 15:10:38 +01:00
|
|
|
#include "protoc/sv_rcon.pb.h"
|
|
|
|
#include "protoc/cl_rcon.pb.h"
|
2023-04-19 01:35:31 +02:00
|
|
|
#include "engine/shared/base_rcon.h"
|
2022-02-06 16:48:52 +01:00
|
|
|
|
2023-04-16 17:51:48 +02:00
|
|
|
#define RCON_MIN_PASSWORD_LEN 8
|
|
|
|
#define RCON_MAX_BANNEDLIST_SIZE 512
|
|
|
|
|
2023-04-19 01:35:31 +02:00
|
|
|
class CRConServer : public CNetConBase
|
2022-02-06 16:48:52 +01:00
|
|
|
{
|
|
|
|
public:
|
2022-08-03 09:32:48 +02:00
|
|
|
CRConServer(void);
|
|
|
|
~CRConServer(void);
|
2022-05-28 23:05:10 +02:00
|
|
|
|
2022-02-06 16:48:52 +01:00
|
|
|
void Init(void);
|
2022-02-14 23:16:24 +01:00
|
|
|
void Shutdown(void);
|
2023-04-16 17:51:48 +02:00
|
|
|
|
2022-07-25 19:35:08 +02:00
|
|
|
bool SetPassword(const char* pszPassword);
|
2023-04-16 17:51:48 +02:00
|
|
|
bool SetWhiteListAddress(const char* pszAddress);
|
2022-02-06 16:48:52 +01:00
|
|
|
|
2022-02-14 03:02:38 +01:00
|
|
|
void Think(void);
|
2022-02-06 16:48:52 +01:00
|
|
|
void RunFrame(void);
|
|
|
|
|
2023-04-19 01:35:31 +02:00
|
|
|
bool SendEncode(const char* pResponseMsg, const char* pResponseVal, const sv_rcon::response_t responseType,
|
|
|
|
const int nMessageId = static_cast<int>(eDLL_T::NETCON), const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
|
|
|
bool SendEncode(const SocketHandle_t hSocket, const char* pResponseMsg, const char* pResponseVal, const sv_rcon::response_t responseType,
|
|
|
|
const int nMessageId = static_cast<int>(eDLL_T::NETCON), const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
|
|
|
|
|
|
|
bool SendToAll(const char* pMsgBuf, int nMsgLen) const;
|
2022-02-06 16:48:52 +01:00
|
|
|
|
2023-04-19 01:35:31 +02:00
|
|
|
bool Serialize(vector<char>& vecBuf, const char* pResponseMsg, const char* pResponseVal, const sv_rcon::response_t responseType,
|
2023-03-27 02:01:48 +02:00
|
|
|
const int nMessageId = static_cast<int>(eDLL_T::NETCON), const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
2022-02-06 16:48:52 +01:00
|
|
|
|
2022-02-13 15:10:38 +01:00
|
|
|
void Authenticate(const cl_rcon::request& cl_request, CConnectedNetConsoleData* pData);
|
2022-02-14 03:02:38 +01:00
|
|
|
bool Comparator(std::string svPassword) const;
|
2022-02-13 15:10:38 +01:00
|
|
|
|
2023-04-19 01:35:31 +02:00
|
|
|
virtual bool ProcessMessage(const char* pMsgBug, int nMsgLen) override;
|
2022-02-13 15:10:38 +01:00
|
|
|
|
2022-11-14 21:00:41 +01:00
|
|
|
void Execute(const cl_rcon::request& cl_request, const bool bConVar) const;
|
2022-02-08 16:32:00 +01:00
|
|
|
bool CheckForBan(CConnectedNetConsoleData* pData);
|
2022-02-13 15:10:38 +01:00
|
|
|
|
2023-04-19 01:35:31 +02:00
|
|
|
virtual void Disconnect(const char* szReason = nullptr) override;
|
2022-02-08 16:32:00 +01:00
|
|
|
void CloseNonAuthConnection(void);
|
2022-02-06 16:48:52 +01:00
|
|
|
|
2023-03-13 21:20:20 +01:00
|
|
|
bool ShouldSend(const sv_rcon::response_t responseType) const;
|
2022-08-11 11:07:45 +02:00
|
|
|
bool IsInitialized(void) const;
|
|
|
|
|
2022-02-06 16:48:52 +01:00
|
|
|
private:
|
2022-08-02 23:58:43 +02:00
|
|
|
int m_nConnIndex;
|
2023-04-19 01:35:31 +02:00
|
|
|
int m_nAuthConnections;
|
|
|
|
bool m_bInitialized;
|
2023-04-16 17:51:48 +02:00
|
|
|
std::unordered_set<std::string> m_BannedList;
|
2022-02-14 03:02:38 +01:00
|
|
|
std::string m_svPasswordHash;
|
2023-04-16 17:51:48 +02:00
|
|
|
netadr_t m_WhiteListAddress;
|
2022-02-06 16:48:52 +01:00
|
|
|
};
|
2022-11-14 21:00:41 +01:00
|
|
|
|
2023-04-16 17:51:48 +02:00
|
|
|
CRConServer* RCONServer();
|