2023-04-19 01:35:31 +02:00
|
|
|
#ifndef BASE_RCON_H
|
|
|
|
#define BASE_RCON_H
|
|
|
|
|
|
|
|
#include "tier1/NetAdr.h"
|
2024-06-01 11:24:47 +02:00
|
|
|
#include "tier2/cryptutils.h"
|
2023-04-19 01:35:31 +02:00
|
|
|
#include "tier2/socketcreator.h"
|
|
|
|
#include "protobuf/message_lite.h"
|
|
|
|
|
2024-06-01 11:24:47 +02:00
|
|
|
// Max size of the payload in the envelope frame
|
|
|
|
#define RCON_MAX_PAYLOAD_SIZE 1024*1024
|
|
|
|
|
2023-04-19 01:35:31 +02:00
|
|
|
class CNetConBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CNetConBase(void)
|
2024-06-01 11:24:47 +02:00
|
|
|
{
|
|
|
|
memset(m_NetKey, 0, sizeof(m_NetKey));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetKey(const char* pBase64NetKey, const bool bUseDefaultOnFailure = false);
|
|
|
|
const char* GetKey(void) const;
|
2023-04-19 01:35:31 +02:00
|
|
|
|
2024-01-14 11:31:16 +01:00
|
|
|
virtual bool Connect(const char* pHostName, const int nHostPort = SOCKET_ERROR);
|
2023-04-19 01:35:31 +02:00
|
|
|
virtual void Disconnect(const char* szReason = nullptr) { NOTE_UNUSED(szReason); };
|
|
|
|
|
2023-08-04 17:41:55 +02:00
|
|
|
virtual bool ProcessBuffer(CConnectedNetConsoleData& data, const char* pRecvBuf, int nRecvLen, const int nMaxLen = SOCKET_ERROR);
|
2023-04-19 01:35:31 +02:00
|
|
|
virtual bool ProcessMessage(const char* /*pMsgBuf*/, int /*nMsgLen*/) { return true; };
|
|
|
|
|
2024-06-01 11:24:47 +02:00
|
|
|
virtual bool Encrypt(CryptoContext_s& ctx, const char* pInBuf, char* pOutBuf, const size_t nDataLen) const;
|
|
|
|
virtual bool Decrypt(CryptoContext_s& ctx, const char* pInBuf, char* pOutBuf, const size_t nDataLen) const;
|
|
|
|
|
2023-08-04 17:45:30 +02:00
|
|
|
virtual bool Encode(google::protobuf::MessageLite* pMsg, char* pMsgBuf, const size_t nMsgLen) const;
|
|
|
|
virtual bool Decode(google::protobuf::MessageLite* pMsg, const char* pMsgBuf, const size_t nMsgLen) const;
|
|
|
|
|
|
|
|
virtual bool Send(const SocketHandle_t hSocket, const char* pMsgBuf, const int nMsgLen) const;
|
|
|
|
virtual void Recv(CConnectedNetConsoleData& data, const int nMaxLen = SOCKET_ERROR);
|
|
|
|
|
2023-04-19 01:35:31 +02:00
|
|
|
CSocketCreator* GetSocketCreator(void) { return &m_Socket; }
|
|
|
|
netadr_t* GetNetAddress(void) { return &m_Address; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CSocketCreator m_Socket;
|
|
|
|
netadr_t m_Address;
|
2024-06-01 11:24:47 +02:00
|
|
|
CryptoKey_t m_NetKey;
|
|
|
|
CUtlString m_Base64NetKey;
|
2023-04-19 01:35:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BASE_RCON_H
|