blob: 23ca211871a4cb0de4ac7fd50a615a4641343d06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#pragma once
#include "NetAdr2.h"
#include "socketcreator.h"
#include "sv_rcon.pb.h"
#include "cl_rcon.pb.h"
#include "igameserverdata.h"
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";
constexpr char s_pszAuthMessage[] = "RCON authentication succesfull.\n\r";
class CRConServer
{
public:
void Init(void);
void Shutdown(void);
void Think(void);
void RunFrame(void);
void Send(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) 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) const;
bool CheckForBan(CConnectedNetConsoleData* pData);
void CloseConnection(void);
void CloseNonAuthConnection(void);
private:
bool m_bInitialized = false;
int m_nConnIndex = 0;
CNetAdr2* m_pAdr2 = new CNetAdr2();
CSocketCreator* m_pSocket = new CSocketCreator();
std::vector<std::string> m_vBannedAddress;
std::string m_svPasswordHash;
};
extern CRConServer* g_pRConServer;
|