r5sdk/r5dev/engine/server/sv_rcon.h
Kawe Mazidjatari 3f8476db88 Logging system light refactor
* Use responceid from server to determine in which context to log.
* Moved all script loggers from combined enums to minus instead (SERVER = -3, CLIENT = -2, UI = -1 SERVER_CODE = 0, etc), this makes it much easier to align stuff in combined systems such as the RUI logger or NetMsg().
* Color log networked RCON messages properly on the client.
* Added dedicated logger for all received RCON messages (net_console.log).
* Log commands submitted through in-game console (allows for easier debugging when going through log files).
2022-08-03 18:34:44 +02:00

54 lines
1.8 KiB
C++

#pragma once
#include "tier1/NetAdr2.h"
#include "tier2/socketcreator.h"
#include "protoc/sv_rcon.pb.h"
#include "protoc/cl_rcon.pb.h"
constexpr char s_pszNoAuthMessage[] = "This server is password protected for console access. Authenticate with 'PASS <password>' command.\n";
constexpr char s_pszWrongPwMessage[] = "Admin password incorrect.\n";
constexpr char s_pszBannedMessage[] = "Go away.\n";
constexpr char s_pszAuthMessage[] = "RCON authentication successfull.\n";
class CRConServer
{
public:
CRConServer(void);
~CRConServer(void);
void Init(void);
void Shutdown(void);
bool SetPassword(const char* pszPassword);
void Think(void);
void RunFrame(void);
void Send(const std::string& svMessage) const;
void Send(SocketHandle_t hSocket, const std::string& svMessage) const;
void Recv(void);
std::string Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t response_t, int nResponseId = -4) const;
cl_rcon::request Deserialize(const std::string& svBuf) const;
void Authenticate(const cl_rcon::request& cl_request, CConnectedNetConsoleData* pData);
bool Comparator(std::string svPassword) const;
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, bool bConVar) const;
bool CheckForBan(CConnectedNetConsoleData* pData);
void CloseConnection(void);
void CloseNonAuthConnection(void);
private:
bool m_bInitialized;
int m_nConnIndex;
CNetAdr2* m_pAdr2;
CSocketCreator* m_pSocket;
std::vector<std::string> m_vBannedAddress;
std::string m_svPasswordHash;
};
extern CRConServer* g_pRConServer;
CRConServer* RCONServer();