mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
* Decoding and encoding is done into a single buffer, from raw buffers to avoid extraneous copies. * Added base class holding all core logic for encoding, decoding, receiving and processing of the RCON protocol. This code was initially identical between all implementations of RCON, deduplicating this avoids bugs. * Added more sophisticated error handling, stop right away when decoding for example fails. * Added ability to have more than one active authenticated net console on the server. Controlled by cvar 'sv_rcon_maxconnections' (default 1). * Max packet size for accepted, but not authenticated sockets is now controled by cvar 'sv_rcon_maxpacketsize' (default 1024).
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
#ifndef BASE_RCON_H
|
|
#define BASE_RCON_H
|
|
|
|
#include "tier1/NetAdr.h"
|
|
#include "tier2/socketcreator.h"
|
|
#include "protobuf/message_lite.h"
|
|
|
|
class CNetConBase
|
|
{
|
|
public:
|
|
CNetConBase(void)
|
|
{}
|
|
|
|
virtual bool Encode(google::protobuf::MessageLite* pMsg, char* pMsgBuf, size_t nMsgLen) const;
|
|
virtual bool Decode(google::protobuf::MessageLite* pMsg, const char* pMsgBuf, size_t nMsgLen) const;
|
|
|
|
virtual bool Connect(const char* pHostAdr, const int nHostPort = -1);
|
|
virtual void Disconnect(const char* szReason = nullptr) { NOTE_UNUSED(szReason); };
|
|
|
|
virtual bool Send(const SocketHandle_t hSocket, const char* pMsgBuf, int nMsgLen) const;
|
|
virtual void Recv(CConnectedNetConsoleData* pData, const int nMaxLen = -1);
|
|
|
|
virtual bool ProcessBuffer(CConnectedNetConsoleData* pData, const char* pRecvBuf, int nRecvLen, int nMaxLen = -1);
|
|
virtual bool ProcessMessage(const char* /*pMsgBuf*/, int /*nMsgLen*/) { return true; };
|
|
|
|
CSocketCreator* GetSocketCreator(void) { return &m_Socket; }
|
|
netadr_t* GetNetAddress(void) { return &m_Address; }
|
|
|
|
protected:
|
|
CSocketCreator m_Socket;
|
|
netadr_t m_Address;
|
|
};
|
|
|
|
#endif // BASE_RCON_H
|