mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
* Implemented robust length-prefix framing logic for non-blocking sockets (previously used character sequences to determine length, but you cannot use character sequences on protocol buffers as its binary data. This logic should fix all problems regarding some commands not getting networked properly to the server and stuff not getting printed on the client). * Increased buffer size to std::vector::max_size when netconsole is authenticated (MAX_NETCONSOLE_INPUT_LEN still remains enforced on accepted but not authenticated connections to prevent attackers from crashing the server). * Process max 1024 bytes each recv buffer iteration. * Additional optimizations and cleanup.
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#pragma once
|
|
#include "tier1/NetAdr2.h"
|
|
#include "tier2/SocketCreator.h"
|
|
#include "protoc/sv_rcon.pb.h"
|
|
#include "protoc/cl_rcon.pb.h"
|
|
|
|
class CRConClient
|
|
{
|
|
public:
|
|
CRConClient(void);
|
|
~CRConClient(void);
|
|
|
|
void Init(void);
|
|
void Shutdown(void);
|
|
|
|
bool SetPassword(const char* pszPassword);
|
|
void RunFrame(void);
|
|
|
|
bool Connect(void);
|
|
bool Connect(const std::string& svInAdr, const std::string& svInPort);
|
|
void Disconnect(void);
|
|
|
|
void Send(const std::string& svMessage) const;
|
|
void Recv(void);
|
|
|
|
void ProcessBuffer(const char* pRecvBuf, int nRecvLen, CConnectedNetConsoleData* pData);
|
|
void ProcessMessage(const sv_rcon::response& sv_response) const;
|
|
|
|
std::string Serialize(const std::string& svReqBuf, const std::string& svReqVal, cl_rcon::request_t request_t) const;
|
|
sv_rcon::response Deserialize(const std::string& svBuf) const;
|
|
|
|
bool IsInitialized(void) const;
|
|
bool IsConnected(void) const;
|
|
|
|
private:
|
|
CNetAdr2* m_pNetAdr2;
|
|
CSocketCreator* m_pSocket;
|
|
|
|
bool m_bInitialized = false;
|
|
bool m_bConnEstablished = false;
|
|
};
|
|
extern CRConClient* g_pRConClient;
|
|
CRConClient* RCONClient(); |