2022-02-06 16:48:52 +01:00
|
|
|
#pragma once
|
|
|
|
#include "tier1/NetAdr2.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"
|
2022-02-06 16:48:52 +01:00
|
|
|
|
|
|
|
constexpr char s_pszNoAuthMessage[] = "This server is password protected for console access. Must send 'PASS <password>' command.\n\r";
|
|
|
|
constexpr char s_pszWrongPwMessage[] = "Password incorrect.\n\r";
|
|
|
|
constexpr char s_pszBannedMessage[] = "Go away.\n\r";
|
2022-02-24 16:44:33 +01:00
|
|
|
constexpr char s_pszAuthMessage[] = "RCON authentication succesfull.\n\r";
|
2022-02-06 16:48:52 +01:00
|
|
|
|
|
|
|
class CRConServer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Init(void);
|
2022-02-14 23:16:24 +01:00
|
|
|
void Shutdown(void);
|
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);
|
|
|
|
|
2022-02-13 15:10:38 +01:00
|
|
|
void Send(const std::string& svMessage) const;
|
2022-02-08 16:32:00 +01:00
|
|
|
void Recv(void);
|
2022-02-06 16:48:52 +01:00
|
|
|
|
2022-02-13 15:10:38 +01:00
|
|
|
std::string Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t response_t) const;
|
|
|
|
cl_rcon::request Deserialize(const std::string& svBuf) 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
|
|
|
|
|
|
|
void ProcessBuffer(const char* pszIn, int nRecvLen, CConnectedNetConsoleData* pData);
|
|
|
|
void ProcessMessage(const cl_rcon::request& cl_request);
|
|
|
|
|
|
|
|
void Execute(const cl_rcon::request& cl_request) const;
|
2022-02-08 16:32:00 +01:00
|
|
|
bool CheckForBan(CConnectedNetConsoleData* pData);
|
2022-02-13 15:10:38 +01:00
|
|
|
|
2022-02-08 16:32:00 +01:00
|
|
|
void CloseConnection(void);
|
|
|
|
void CloseNonAuthConnection(void);
|
2022-02-06 16:48:52 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2022-02-08 16:32:00 +01:00
|
|
|
bool m_bInitialized = false;
|
|
|
|
int m_nConnIndex = 0;
|
|
|
|
CNetAdr2* m_pAdr2 = new CNetAdr2();
|
|
|
|
CSocketCreator* m_pSocket = new CSocketCreator();
|
2022-02-06 16:48:52 +01:00
|
|
|
std::vector<std::string> m_vBannedAddress;
|
2022-02-14 03:02:38 +01:00
|
|
|
std::string m_svPasswordHash;
|
2022-02-06 16:48:52 +01:00
|
|
|
};
|
|
|
|
extern CRConServer* g_pRConServer;
|