mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Engine: implement encryption for RCON protocol
RCON lacked encryption, added AES-CTR encryption on RCON frames. Slightly adjusted protocol to take this into account (sending nonces, encrypted data itself, etc).
This commit is contained in:
parent
cb0c3ef95b
commit
f8dd1fe88c
@ -10,6 +10,7 @@
|
|||||||
#include "tier0/fasttimer.h"
|
#include "tier0/fasttimer.h"
|
||||||
#include "tier1/cvar.h"
|
#include "tier1/cvar.h"
|
||||||
#include "tier1/fmtstr.h"
|
#include "tier1/fmtstr.h"
|
||||||
|
#include "engine/shared/shared_rcon.h"
|
||||||
#ifndef CLIENT_DLL
|
#ifndef CLIENT_DLL
|
||||||
#include "engine/server/sv_rcon.h"
|
#include "engine/server/sv_rcon.h"
|
||||||
#endif // !CLIENT_DLL
|
#endif // !CLIENT_DLL
|
||||||
@ -248,7 +249,7 @@ void NET_UseSocketsForLoopbackChanged_f(IConVar* pConVar, const char* pOldString
|
|||||||
{
|
{
|
||||||
Msg(eDLL_T::SERVER, "Rebooting RCON server...\n");
|
Msg(eDLL_T::SERVER, "Rebooting RCON server...\n");
|
||||||
RCONServer()->Shutdown();
|
RCONServer()->Shutdown();
|
||||||
RCONServer()->Init();
|
RCONServer()->Init(rcon_password.GetString(), RCONServer()->GetKey());
|
||||||
}
|
}
|
||||||
#endif // !CLIENT_DLL
|
#endif // !CLIENT_DLL
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,7 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE
|
|||||||
|
|
||||||
"SigCache_Pb"
|
"SigCache_Pb"
|
||||||
"LiveAPI_Pb"
|
"LiveAPI_Pb"
|
||||||
"SV_RCon_Pb"
|
"NetCon_Pb"
|
||||||
"CL_RCon_Pb"
|
|
||||||
|
|
||||||
"rson"
|
"rson"
|
||||||
"rtech_game"
|
"rtech_game"
|
||||||
@ -81,6 +80,10 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE
|
|||||||
"EAThread"
|
"EAThread"
|
||||||
"DirtySDK"
|
"DirtySDK"
|
||||||
|
|
||||||
|
"libmbedcrypto"
|
||||||
|
"libmbedtls"
|
||||||
|
"libmbedx509"
|
||||||
|
|
||||||
"networksystem"
|
"networksystem"
|
||||||
"pluginsystem"
|
"pluginsystem"
|
||||||
"filesystem"
|
"filesystem"
|
||||||
@ -115,9 +118,6 @@ endif()
|
|||||||
|
|
||||||
if( NOT ${PROJECT_NAME} STREQUAL "client" )
|
if( NOT ${PROJECT_NAME} STREQUAL "client" )
|
||||||
target_link_libraries( ${PROJECT_NAME} PRIVATE
|
target_link_libraries( ${PROJECT_NAME} PRIVATE
|
||||||
"libmbedcrypto"
|
|
||||||
"libmbedtls"
|
|
||||||
"libmbedx509"
|
|
||||||
"libjwt"
|
"libjwt"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@ -284,9 +284,9 @@ void EngineLoggerSink(LogType_t logType, LogLevel_t logLevel, eDLL_T context,
|
|||||||
if (bToConsole)
|
if (bToConsole)
|
||||||
{
|
{
|
||||||
#ifndef CLIENT_DLL
|
#ifndef CLIENT_DLL
|
||||||
if (!LoggedFromClient(context) && RCONServer()->ShouldSend(sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG))
|
if (!LoggedFromClient(context) && RCONServer()->ShouldSend(netcon::response_e::SERVERDATA_RESPONSE_CONSOLE_LOG))
|
||||||
{
|
{
|
||||||
RCONServer()->SendEncode(formatted.c_str(), pszUpTime, sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG,
|
RCONServer()->SendEncoded(formatted.c_str(), pszUpTime, netcon::response_e::SERVERDATA_RESPONSE_CONSOLE_LOG,
|
||||||
int(context), int(logType));
|
int(context), int(logType));
|
||||||
}
|
}
|
||||||
#endif // !CLIENT_DLL
|
#endif // !CLIENT_DLL
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
#include "core/stdafx.h"
|
#include "core/stdafx.h"
|
||||||
#include "tier1/cmd.h"
|
#include "tier1/cmd.h"
|
||||||
#include "tier1/cvar.h"
|
#include "tier1/cvar.h"
|
||||||
#include "protoc/sv_rcon.pb.h"
|
#include "protoc/netcon.pb.h"
|
||||||
#include "protoc/cl_rcon.pb.h"
|
|
||||||
#include "engine/client/cl_rcon.h"
|
#include "engine/client/cl_rcon.h"
|
||||||
#include "engine/shared/shared_rcon.h"
|
#include "engine/shared/shared_rcon.h"
|
||||||
#include "engine/net.h"
|
#include "engine/net.h"
|
||||||
@ -19,16 +18,18 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: console variables
|
// Purpose: console variables
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
static ConVar rcon_address("rcon_address", "[loopback]:37015", FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access address");
|
static void RCON_AddressChanged_f(IConVar* pConVar, const char* pOldString);
|
||||||
|
static void RCON_InputOnlyChanged_f(IConVar* pConVar, const char* pOldString);
|
||||||
|
|
||||||
|
static ConVar cl_rcon_address("cl_rcon_address", "", FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access address (rcon client is disabled if empty)", &RCON_AddressChanged_f);
|
||||||
|
static ConVar cl_rcon_inputonly("cl_rcon_inputonly", "0", FCVAR_RELEASE, "Tells the rcon server whether or not we are input only.", RCON_InputOnlyChanged_f);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: console commands
|
// Purpose: console commands
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
static void RCON_Disconnect_f();
|
|
||||||
static void RCON_CmdQuery_f(const CCommand& args);
|
static void RCON_CmdQuery_f(const CCommand& args);
|
||||||
|
|
||||||
static ConCommand rcon("rcon", RCON_CmdQuery_f, "Forward RCON query to remote server", FCVAR_CLIENTDLL | FCVAR_RELEASE, nullptr, "rcon \"<query>\"");
|
static ConCommand rcon("rcon", RCON_CmdQuery_f, "Forward RCON query to remote server", FCVAR_CLIENTDLL | FCVAR_RELEASE, nullptr, "rcon \"<query>\"");
|
||||||
static ConCommand rcon_disconnect("rcon_disconnect", RCON_Disconnect_f, "Disconnect from RCON server", FCVAR_CLIENTDLL | FCVAR_RELEASE);
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
@ -51,8 +52,9 @@ CRConClient::~CRConClient(void)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: NETCON systems init
|
// Purpose: NETCON systems init
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CRConClient::Init(void)
|
void CRConClient::Init(const char* pNetKey)
|
||||||
{
|
{
|
||||||
|
SetKey(pNetKey);
|
||||||
m_bInitialized = true;
|
m_bInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,18 +107,17 @@ void CRConClient::Disconnect(const char* szReason)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CRConClient::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
bool CRConClient::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
||||||
{
|
{
|
||||||
sv_rcon::response response;
|
netcon::response response;
|
||||||
bool bSuccess = Decode(&response, pMsgBuf, nMsgLen);
|
|
||||||
|
|
||||||
if (!bSuccess)
|
if (!SH_NetConUnpackEnvelope(this, pMsgBuf, nMsgLen, &response, rcon_debug.GetBool()))
|
||||||
{
|
{
|
||||||
Error(eDLL_T::CLIENT, NO_ERROR, "Failed to decode RCON buffer\n");
|
Disconnect("received invalid message");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (response.responsetype())
|
switch (response.responsetype())
|
||||||
{
|
{
|
||||||
case sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH:
|
case netcon::response_e::SERVERDATA_RESPONSE_AUTH:
|
||||||
{
|
{
|
||||||
if (!response.responseval().empty())
|
if (!response.responseval().empty())
|
||||||
{
|
{
|
||||||
@ -132,7 +133,7 @@ bool CRConClient::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
|||||||
Msg(eDLL_T::NETCON, "%s", response.responsemsg().c_str());
|
Msg(eDLL_T::NETCON, "%s", response.responsemsg().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG:
|
case netcon::response_e::SERVERDATA_RESPONSE_CONSOLE_LOG:
|
||||||
{
|
{
|
||||||
NetMsg(static_cast<LogType_t>(response.messagetype()),
|
NetMsg(static_cast<LogType_t>(response.messagetype()),
|
||||||
static_cast<eDLL_T>(response.messageid()),
|
static_cast<eDLL_T>(response.messageid()),
|
||||||
@ -165,7 +166,7 @@ void CRConClient::RequestConsoleLog(const bool bWantLog)
|
|||||||
const SocketHandle_t hSocket = GetSocket();
|
const SocketHandle_t hSocket = GetSocket();
|
||||||
|
|
||||||
vector<char> vecMsg;
|
vector<char> vecMsg;
|
||||||
bool ret = Serialize(vecMsg, "", szEnable, cl_rcon::request_t::SERVERDATA_REQUEST_SEND_CONSOLE_LOG);
|
bool ret = Serialize(vecMsg, "", szEnable, netcon::request_e::SERVERDATA_REQUEST_SEND_CONSOLE_LOG);
|
||||||
|
|
||||||
if (ret && !Send(hSocket, vecMsg.data(), int(vecMsg.size())))
|
if (ret && !Send(hSocket, vecMsg.data(), int(vecMsg.size())))
|
||||||
{
|
{
|
||||||
@ -181,9 +182,10 @@ void CRConClient::RequestConsoleLog(const bool bWantLog)
|
|||||||
// Output : serialized results as string
|
// Output : serialized results as string
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CRConClient::Serialize(vector<char>& vecBuf, const char* szReqBuf,
|
bool CRConClient::Serialize(vector<char>& vecBuf, const char* szReqBuf,
|
||||||
const char* szReqVal, const cl_rcon::request_t requestType) const
|
const char* szReqVal, const netcon::request_e requestType) const
|
||||||
{
|
{
|
||||||
return CL_NetConSerialize(this, vecBuf, szReqBuf, szReqVal, requestType);
|
return CL_NetConSerialize(this, vecBuf, szReqBuf, szReqVal, requestType,
|
||||||
|
rcon_encryptframes.GetBool(), rcon_debug.GetBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -204,17 +206,6 @@ SocketHandle_t CRConClient::GetSocket(void)
|
|||||||
return SH_GetNetConSocketHandle(this, 0);
|
return SH_GetNetConSocketHandle(this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: request whether to recv logs from RCON server when cvar changes
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
static void RCON_InputOnlyChanged_f(IConVar* pConVar, const char* pOldString)
|
|
||||||
{
|
|
||||||
RCONClient()->RequestConsoleLog(RCONClient()->ShouldReceive());
|
|
||||||
}
|
|
||||||
|
|
||||||
static ConVar cl_rcon_inputonly("cl_rcon_inputonly", "0", FCVAR_RELEASE, "Tells the rcon server whether or not we are input only.",
|
|
||||||
false, 0.f, false, 0.f, RCON_InputOnlyChanged_f);
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: returns whether or not we should receive logs from the server
|
// Purpose: returns whether or not we should receive logs from the server
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -254,6 +245,49 @@ CRConClient* RCONClient() // Singleton RCON Client.
|
|||||||
return &s_RCONClient;
|
return &s_RCONClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=====================
|
||||||
|
RCON_AddressChanged_f
|
||||||
|
|
||||||
|
|
||||||
|
=====================
|
||||||
|
*/
|
||||||
|
static void RCON_AddressChanged_f(IConVar* pConVar, const char* pOldString)
|
||||||
|
{
|
||||||
|
if (ConVar* pConVarRef = g_pCVar->FindVar(pConVar->GetName()))
|
||||||
|
{
|
||||||
|
const char* pNewString = pConVarRef->GetString();
|
||||||
|
|
||||||
|
if (strcmp(pOldString, pNewString) == NULL)
|
||||||
|
{
|
||||||
|
return; // Same address.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!*pNewString) // Empty address means nothing to network to; shutdown client...
|
||||||
|
{
|
||||||
|
RCONClient()->Shutdown();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RCON_InitClientAndTrySyncKeys();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=====================
|
||||||
|
RCON_InputOnlyChanged_f
|
||||||
|
|
||||||
|
request whether to recv logs
|
||||||
|
from RCON server when cvar
|
||||||
|
changes
|
||||||
|
=====================
|
||||||
|
*/
|
||||||
|
static void RCON_InputOnlyChanged_f(IConVar* pConVar, const char* pOldString)
|
||||||
|
{
|
||||||
|
RCONClient()->RequestConsoleLog(RCONClient()->ShouldReceive());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=====================
|
=====================
|
||||||
RCON_CmdQuery_f
|
RCON_CmdQuery_f
|
||||||
@ -268,7 +302,7 @@ static void RCON_CmdQuery_f(const CCommand& args)
|
|||||||
|
|
||||||
if (argCount < 2)
|
if (argCount < 2)
|
||||||
{
|
{
|
||||||
const char* pszAddress = rcon_address.GetString();
|
const char* pszAddress = cl_rcon_address.GetString();
|
||||||
|
|
||||||
if (RCONClient()->IsInitialized()
|
if (RCONClient()->IsInitialized()
|
||||||
&& !RCONClient()->IsConnected()
|
&& !RCONClient()->IsConnected()
|
||||||
@ -290,16 +324,23 @@ static void RCON_CmdQuery_f(const CCommand& args)
|
|||||||
bool bSuccess = false;
|
bool bSuccess = false;
|
||||||
const SocketHandle_t hSocket = RCONClient()->GetSocket();
|
const SocketHandle_t hSocket = RCONClient()->GetSocket();
|
||||||
|
|
||||||
if (strcmp(args.Arg(1), "PASS") == 0) // Auth with RCON server using rcon_password ConVar value.
|
if (strcmp(args.Arg(1), "PASS") == 0)
|
||||||
{
|
{
|
||||||
if (argCount > 2)
|
if (argCount > 2)
|
||||||
{
|
{
|
||||||
bSuccess = RCONClient()->Serialize(vecMsg, args.Arg(2), "", cl_rcon::request_t::SERVERDATA_REQUEST_AUTH);
|
bSuccess = RCONClient()->Serialize(vecMsg, args.Arg(2), "", netcon::request_e::SERVERDATA_REQUEST_AUTH);
|
||||||
}
|
}
|
||||||
else
|
else // Auth with RCON server using rcon_password ConVar value.
|
||||||
{
|
{
|
||||||
Warning(eDLL_T::CLIENT, "Failed to issue command to RCON server: %s\n", "no password given");
|
const char* storedPassword = rcon_password.GetString();
|
||||||
return;
|
|
||||||
|
if (!strlen(storedPassword))
|
||||||
|
{
|
||||||
|
Warning(eDLL_T::CLIENT, "Failed to issue command to RCON server: %s\n", "no password given");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bSuccess = RCONClient()->Serialize(vecMsg, storedPassword, "", netcon::request_e::SERVERDATA_REQUEST_AUTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bSuccess)
|
if (bSuccess)
|
||||||
@ -311,11 +352,11 @@ static void RCON_CmdQuery_f(const CCommand& args)
|
|||||||
}
|
}
|
||||||
else if (strcmp(args.Arg(1), "disconnect") == 0) // Disconnect from RCON server.
|
else if (strcmp(args.Arg(1), "disconnect") == 0) // Disconnect from RCON server.
|
||||||
{
|
{
|
||||||
RCONClient()->Disconnect("issued by user");
|
RCONClient()->Disconnect("ordered by user");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bSuccess = RCONClient()->Serialize(vecMsg, args.Arg(1), args.ArgS(), cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
|
bSuccess = RCONClient()->Serialize(vecMsg, args.Arg(1), args.ArgS(), netcon::request_e::SERVERDATA_REQUEST_EXECCOMMAND);
|
||||||
if (bSuccess)
|
if (bSuccess)
|
||||||
{
|
{
|
||||||
RCONClient()->Send(hSocket, vecMsg.data(), int(vecMsg.size()));
|
RCONClient()->Send(hSocket, vecMsg.data(), int(vecMsg.size()));
|
||||||
@ -329,21 +370,3 @@ static void RCON_CmdQuery_f(const CCommand& args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=====================
|
|
||||||
RCON_Disconnect_f
|
|
||||||
|
|
||||||
Disconnect from RCON server
|
|
||||||
=====================
|
|
||||||
*/
|
|
||||||
static void RCON_Disconnect_f()
|
|
||||||
{
|
|
||||||
const bool bIsConnected = RCONClient()->IsConnected();
|
|
||||||
RCONClient()->Disconnect("issued by user");
|
|
||||||
|
|
||||||
if (bIsConnected) // Log if client was indeed connected.
|
|
||||||
{
|
|
||||||
Msg(eDLL_T::CLIENT, "User closed RCON connection\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "tier1/NetAdr.h"
|
#include "tier1/NetAdr.h"
|
||||||
#include "tier2/socketcreator.h"
|
#include "tier2/socketcreator.h"
|
||||||
#include "protoc/sv_rcon.pb.h"
|
#include "protoc/netcon.pb.h"
|
||||||
#include "protoc/cl_rcon.pb.h"
|
|
||||||
#include "engine/shared/base_rcon.h"
|
#include "engine/shared/base_rcon.h"
|
||||||
|
|
||||||
class CRConClient : public CNetConBase
|
class CRConClient : public CNetConBase
|
||||||
@ -11,7 +10,7 @@ public:
|
|||||||
CRConClient(void);
|
CRConClient(void);
|
||||||
~CRConClient(void);
|
~CRConClient(void);
|
||||||
|
|
||||||
void Init(void);
|
void Init(const char* pNetKey = nullptr);
|
||||||
void Shutdown(void);
|
void Shutdown(void);
|
||||||
void RunFrame(void);
|
void RunFrame(void);
|
||||||
|
|
||||||
@ -19,7 +18,7 @@ public:
|
|||||||
virtual bool ProcessMessage(const char* pMsgBuf, const int nMsgLen) override;
|
virtual bool ProcessMessage(const char* pMsgBuf, const int nMsgLen) override;
|
||||||
|
|
||||||
bool Serialize(vector<char>& vecBuf, const char* szReqBuf,
|
bool Serialize(vector<char>& vecBuf, const char* szReqBuf,
|
||||||
const char* szReqVal, const cl_rcon::request_t requestType) const;
|
const char* szReqVal, const netcon::request_e requestType) const;
|
||||||
|
|
||||||
void RequestConsoleLog(const bool bWantLog);
|
void RequestConsoleLog(const bool bWantLog);
|
||||||
bool ShouldReceive(void);
|
bool ShouldReceive(void);
|
||||||
|
@ -299,13 +299,6 @@ void CHostState::Setup(void)
|
|||||||
#endif // !CLIENT_DLL
|
#endif // !CLIENT_DLL
|
||||||
ConVar_PurgeHostNames();
|
ConVar_PurgeHostNames();
|
||||||
|
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
RCONServer()->Init();
|
|
||||||
#endif // !CLIENT_DLL
|
|
||||||
#ifndef DEDICATED
|
|
||||||
RCONClient()->Init();
|
|
||||||
#endif // !DEDICATED
|
|
||||||
|
|
||||||
#ifndef CLIENT_DLL
|
#ifndef CLIENT_DLL
|
||||||
LiveAPISystem()->Init();
|
LiveAPISystem()->Init();
|
||||||
#endif // !CLIENT_DLL
|
#endif // !CLIENT_DLL
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
constexpr unsigned int AES_128_KEY_SIZE = 16;
|
||||||
|
constexpr unsigned int AES_128_B64_ENCODED_SIZE = 24;
|
||||||
|
constexpr const char* DEFAULT_NET_ENCRYPTION_KEY = "WDNWLmJYQ2ZlM0VoTid3Yg==";
|
||||||
|
|
||||||
#ifndef _TOOLS
|
#ifndef _TOOLS
|
||||||
#include "engine/net_chan.h"
|
#include "engine/net_chan.h"
|
||||||
#include "tier1/lzss.h"
|
#include "tier1/lzss.h"
|
||||||
@ -14,10 +18,6 @@
|
|||||||
#define NETMSG_LENGTH_BITS 12 // 512 bytes (11 in Valve Source, 256 bytes).
|
#define NETMSG_LENGTH_BITS 12 // 512 bytes (11 in Valve Source, 256 bytes).
|
||||||
#define NET_MIN_MESSAGE 5 // Even connectionless packets require int32 value (-1) + 1 byte content
|
#define NET_MIN_MESSAGE 5 // Even connectionless packets require int32 value (-1) + 1 byte content
|
||||||
|
|
||||||
constexpr unsigned int AES_128_KEY_SIZE = 16;
|
|
||||||
constexpr unsigned int AES_128_B64_ENCODED_SIZE = 24;
|
|
||||||
constexpr const char* DEFAULT_NET_ENCRYPTION_KEY = "WDNWLmJYQ2ZlM0VoTid3Yg==";
|
|
||||||
|
|
||||||
/* ==== CNETCHAN ======================================================================================================================================================== */
|
/* ==== CNETCHAN ======================================================================================================================================================== */
|
||||||
inline void*(*v_NET_Init)(bool bDeveloper);
|
inline void*(*v_NET_Init)(bool bDeveloper);
|
||||||
inline void(*v_NET_SetKey)(netkey_t* pKey, const char* szHash);
|
inline void(*v_NET_SetKey)(netkey_t* pKey, const char* szHash);
|
||||||
|
@ -11,10 +11,13 @@
|
|||||||
#include "engine/cmd.h"
|
#include "engine/cmd.h"
|
||||||
#include "engine/net.h"
|
#include "engine/net.h"
|
||||||
#include "engine/server/sv_rcon.h"
|
#include "engine/server/sv_rcon.h"
|
||||||
#include "protoc/sv_rcon.pb.h"
|
#include "protoc/netcon.pb.h"
|
||||||
#include "protoc/cl_rcon.pb.h"
|
|
||||||
#include "common/igameserverdata.h"
|
#include "common/igameserverdata.h"
|
||||||
#include "mbedtls/include/mbedtls/sha512.h"
|
#include "mbedtls/include/mbedtls/sha512.h"
|
||||||
|
#include <thirdparty/mbedtls/include/mbedtls/aes.h>
|
||||||
|
#include <random>
|
||||||
|
#include <thirdparty/mbedtls/include/mbedtls/ctr_drbg.h>
|
||||||
|
#include <engine/shared/shared_rcon.h>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: constants
|
// Purpose: constants
|
||||||
@ -29,13 +32,8 @@ static const char s_BannedMessage[] = "Go away.\n";
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
static void RCON_WhiteListAddresChanged_f(IConVar* pConVar, const char* pOldString);
|
static void RCON_WhiteListAddresChanged_f(IConVar* pConVar, const char* pOldString);
|
||||||
static void RCON_ConnectionCountChanged_f(IConVar* pConVar, const char* pOldString);
|
static void RCON_ConnectionCountChanged_f(IConVar* pConVar, const char* pOldString);
|
||||||
static void RCON_PasswordChanged_f(IConVar* pConVar, const char* pOldString);
|
|
||||||
|
|
||||||
static ConVar rcon_password("rcon_password", "", FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access password (rcon is disabled if empty)", false, 0.f, false, 0.f, &RCON_PasswordChanged_f);
|
|
||||||
|
|
||||||
static ConVar sv_rcon_debug("sv_rcon_debug", "0", FCVAR_RELEASE, "Show rcon debug information ( !slower! )");
|
|
||||||
static ConVar sv_rcon_sendlogs("sv_rcon_sendlogs", "0", FCVAR_RELEASE, "Network console logs to connected and authenticated sockets");
|
static ConVar sv_rcon_sendlogs("sv_rcon_sendlogs", "0", FCVAR_RELEASE, "Network console logs to connected and authenticated sockets");
|
||||||
|
|
||||||
//static ConVar sv_rcon_banpenalty("sv_rcon_banpenalty" , "10", FCVAR_RELEASE, "Number of minutes to ban users who fail rcon authentication");
|
//static ConVar sv_rcon_banpenalty("sv_rcon_banpenalty" , "10", FCVAR_RELEASE, "Number of minutes to ban users who fail rcon authentication");
|
||||||
|
|
||||||
static ConVar sv_rcon_maxfailures("sv_rcon_maxfailures", "10", FCVAR_RELEASE, "Max number of times an user can fail rcon authentication before being banned", true, 1.f, false, 0.f);
|
static ConVar sv_rcon_maxfailures("sv_rcon_maxfailures", "10", FCVAR_RELEASE, "Max number of times an user can fail rcon authentication before being banned", true, 1.f, false, 0.f);
|
||||||
@ -43,7 +41,7 @@ static ConVar sv_rcon_maxignores("sv_rcon_maxignores", "15", FCVAR_RELEASE, "Max
|
|||||||
static ConVar sv_rcon_maxsockets("sv_rcon_maxsockets", "32", FCVAR_RELEASE, "Max number of accepted sockets before the server starts closing redundant sockets", true, 1.f, true, MAX_PLAYERS);
|
static ConVar sv_rcon_maxsockets("sv_rcon_maxsockets", "32", FCVAR_RELEASE, "Max number of accepted sockets before the server starts closing redundant sockets", true, 1.f, true, MAX_PLAYERS);
|
||||||
|
|
||||||
static ConVar sv_rcon_maxconnections("sv_rcon_maxconnections", "1", FCVAR_RELEASE, "Max number of authenticated connections before the server closes the listen socket", true, 1.f, true, MAX_PLAYERS, &RCON_ConnectionCountChanged_f);
|
static ConVar sv_rcon_maxconnections("sv_rcon_maxconnections", "1", FCVAR_RELEASE, "Max number of authenticated connections before the server closes the listen socket", true, 1.f, true, MAX_PLAYERS, &RCON_ConnectionCountChanged_f);
|
||||||
static ConVar sv_rcon_maxpacketsize("sv_rcon_maxpacketsize", "1024", FCVAR_RELEASE, "Max number of bytes allowed in a command packet from a non-authenticated netconsole", true, 0.f, false, 0.f);
|
static ConVar sv_rcon_maxframesize("sv_rcon_maxframesize", "1024", FCVAR_RELEASE, "Max number of bytes allowed in a command frame from a non-authenticated netconsole", true, 0.f, false, 0.f);
|
||||||
static ConVar sv_rcon_whitelist_address("sv_rcon_whitelist_address", "", FCVAR_RELEASE, "This address is not considered a 'redundant' socket and will never be banned for failed authentication attempts", &RCON_WhiteListAddresChanged_f, "Format: '::ffff:127.0.0.1'");
|
static ConVar sv_rcon_whitelist_address("sv_rcon_whitelist_address", "", FCVAR_RELEASE, "This address is not considered a 'redundant' socket and will never be banned for failed authentication attempts", &RCON_WhiteListAddresChanged_f, "Format: '::ffff:127.0.0.1'");
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -54,6 +52,7 @@ CRConServer::CRConServer(void)
|
|||||||
, m_nAuthConnections(0)
|
, m_nAuthConnections(0)
|
||||||
, m_bInitialized(false)
|
, m_bInitialized(false)
|
||||||
{
|
{
|
||||||
|
memset(m_PasswordHash, 0, sizeof(m_PasswordHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -62,18 +61,20 @@ CRConServer::CRConServer(void)
|
|||||||
CRConServer::~CRConServer(void)
|
CRConServer::~CRConServer(void)
|
||||||
{
|
{
|
||||||
// NOTE: do not call Shutdown() from the destructor as the OS's socket
|
// NOTE: do not call Shutdown() from the destructor as the OS's socket
|
||||||
// system would be shutdown by now, call Shutdown() in application
|
// system would be shutdown by then, call Shutdown() in application
|
||||||
// shutdown code instead
|
// shutdown code instead
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: NETCON systems init
|
// Purpose: NETCON systems init
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CRConServer::Init(void)
|
void CRConServer::Init(const char* pPassword, const char* pNetKey)
|
||||||
{
|
{
|
||||||
if (!m_bInitialized)
|
if (!m_bInitialized)
|
||||||
{
|
{
|
||||||
if (!SetPassword(rcon_password.GetString()))
|
SetKey(pNetKey);
|
||||||
|
|
||||||
|
if (!SetPassword(pPassword))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -89,7 +90,9 @@ void CRConServer::Init(void)
|
|||||||
m_Address.SetFromString(Format("[%s]:%i", pszAddress, hostport->GetInt()).c_str(), true);
|
m_Address.SetFromString(Format("[%s]:%i", pszAddress, hostport->GetInt()).c_str(), true);
|
||||||
m_Socket.CreateListenSocket(m_Address);
|
m_Socket.CreateListenSocket(m_Address);
|
||||||
|
|
||||||
Msg(eDLL_T::SERVER, "Remote server access initialized ('%s')\n", m_Address.ToString());
|
Msg(eDLL_T::SERVER, "Remote server access initialized ('%s') with key %s'%s%s%s'\n",
|
||||||
|
m_Address.ToString(), g_svReset, g_svGreyB, GetKey(), g_svReset);
|
||||||
|
|
||||||
m_bInitialized = true;
|
m_bInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,14 +235,14 @@ void CRConServer::RunFrame(void)
|
|||||||
|
|
||||||
if (CheckForBan(data))
|
if (CheckForBan(data))
|
||||||
{
|
{
|
||||||
SendEncode(data.m_hSocket, s_BannedMessage, "",
|
SendEncoded(data.m_hSocket, s_BannedMessage, "",
|
||||||
sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH, int(eDLL_T::NETCON));
|
netcon::response_e::SERVERDATA_RESPONSE_AUTH, int(eDLL_T::NETCON));
|
||||||
|
|
||||||
Disconnect("banned");
|
Disconnect("banned");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Recv(data, sv_rcon_maxpacketsize.GetInt());
|
Recv(data, sv_rcon_maxframesize.GetInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,8 +295,8 @@ bool CRConServer::SendToAll(const char* pMsgBuf, const int nMsgLen) const
|
|||||||
// nMessageType -
|
// nMessageType -
|
||||||
// Output: true on success, false otherwise
|
// Output: true on success, false otherwise
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CRConServer::SendEncode(const char* pResponseMsg, const char* pResponseVal,
|
bool CRConServer::SendEncoded(const char* pResponseMsg, const char* pResponseVal,
|
||||||
const sv_rcon::response_t responseType, const int nMessageId, const int nMessageType) const
|
const netcon::response_e responseType, const int nMessageId, const int nMessageType) const
|
||||||
{
|
{
|
||||||
vector<char> vecMsg;
|
vector<char> vecMsg;
|
||||||
if (!Serialize(vecMsg, pResponseMsg, pResponseVal,
|
if (!Serialize(vecMsg, pResponseMsg, pResponseVal,
|
||||||
@ -320,8 +323,8 @@ bool CRConServer::SendEncode(const char* pResponseMsg, const char* pResponseVal,
|
|||||||
// nMessageType -
|
// nMessageType -
|
||||||
// Output: true on success, false otherwise
|
// Output: true on success, false otherwise
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CRConServer::SendEncode(const SocketHandle_t hSocket, const char* pResponseMsg, const char* pResponseVal,
|
bool CRConServer::SendEncoded(const SocketHandle_t hSocket, const char* pResponseMsg, const char* pResponseVal,
|
||||||
const sv_rcon::response_t responseType, const int nMessageId, const int nMessageType) const
|
const netcon::response_e responseType, const int nMessageId, const int nMessageType) const
|
||||||
{
|
{
|
||||||
vector<char> vecMsg;
|
vector<char> vecMsg;
|
||||||
if (!Serialize(vecMsg, pResponseMsg, pResponseVal,
|
if (!Serialize(vecMsg, pResponseMsg, pResponseVal,
|
||||||
@ -349,26 +352,10 @@ bool CRConServer::SendEncode(const SocketHandle_t hSocket, const char* pResponse
|
|||||||
// Output : serialized results as string
|
// Output : serialized results as string
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CRConServer::Serialize(vector<char>& vecBuf, const char* pResponseMsg, const char* pResponseVal,
|
bool CRConServer::Serialize(vector<char>& vecBuf, const char* pResponseMsg, const char* pResponseVal,
|
||||||
const sv_rcon::response_t responseType, const int nMessageId, const int nMessageType) const
|
const netcon::response_e responseType, const int nMessageId, const int nMessageType) const
|
||||||
{
|
{
|
||||||
sv_rcon::response response;
|
return SV_NetConSerialize(this, vecBuf, pResponseMsg, pResponseVal, responseType, nMessageId, nMessageType,
|
||||||
|
rcon_encryptframes.GetBool(), rcon_debug.GetBool());
|
||||||
response.set_messageid(nMessageId);
|
|
||||||
response.set_messagetype(nMessageType);
|
|
||||||
response.set_responsetype(responseType);
|
|
||||||
response.set_responsemsg(pResponseMsg);
|
|
||||||
response.set_responseval(pResponseVal);
|
|
||||||
|
|
||||||
const size_t msgLen = response.ByteSizeLong();
|
|
||||||
vecBuf.resize(msgLen);
|
|
||||||
|
|
||||||
if (!Encode(&response, &vecBuf[0], msgLen))
|
|
||||||
{
|
|
||||||
Error(eDLL_T::SERVER, NO_ERROR, "Failed to encode RCON buffer\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -376,7 +363,7 @@ bool CRConServer::Serialize(vector<char>& vecBuf, const char* pResponseMsg, cons
|
|||||||
// Input : &request -
|
// Input : &request -
|
||||||
// &data -
|
// &data -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CRConServer::Authenticate(const cl_rcon::request& request, CConnectedNetConsoleData& data)
|
void CRConServer::Authenticate(const netcon::request& request, CConnectedNetConsoleData& data)
|
||||||
{
|
{
|
||||||
if (data.m_bAuthorized)
|
if (data.m_bAuthorized)
|
||||||
{
|
{
|
||||||
@ -395,19 +382,19 @@ void CRConServer::Authenticate(const cl_rcon::request& request, CConnectedNetCon
|
|||||||
|
|
||||||
const char* pSendLogs = (!sv_rcon_sendlogs.GetBool() || data.m_bInputOnly) ? "0" : "1";
|
const char* pSendLogs = (!sv_rcon_sendlogs.GetBool() || data.m_bInputOnly) ? "0" : "1";
|
||||||
|
|
||||||
SendEncode(data.m_hSocket, s_AuthMessage, pSendLogs,
|
SendEncoded(data.m_hSocket, s_AuthMessage, pSendLogs,
|
||||||
sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH, static_cast<int>(eDLL_T::NETCON));
|
netcon::response_e::SERVERDATA_RESPONSE_AUTH, static_cast<int>(eDLL_T::NETCON));
|
||||||
}
|
}
|
||||||
else // Bad password.
|
else // Bad password.
|
||||||
{
|
{
|
||||||
const netadr_t& netAdr = m_Socket.GetAcceptedSocketAddress(m_nConnIndex);
|
const netadr_t& netAdr = m_Socket.GetAcceptedSocketAddress(m_nConnIndex);
|
||||||
if (sv_rcon_debug.GetBool())
|
if (rcon_debug.GetBool())
|
||||||
{
|
{
|
||||||
Msg(eDLL_T::SERVER, "Bad RCON password attempt from '%s'\n", netAdr.ToString());
|
Msg(eDLL_T::SERVER, "Bad RCON password attempt from '%s'\n", netAdr.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
SendEncode(data.m_hSocket, s_WrongPwMessage, "",
|
SendEncoded(data.m_hSocket, s_WrongPwMessage, "",
|
||||||
sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH, static_cast<int>(eDLL_T::NETCON));
|
netcon::response_e::SERVERDATA_RESPONSE_AUTH, static_cast<int>(eDLL_T::NETCON));
|
||||||
|
|
||||||
data.m_bAuthorized = false;
|
data.m_bAuthorized = false;
|
||||||
data.m_bValidated = false;
|
data.m_bValidated = false;
|
||||||
@ -442,21 +429,22 @@ bool CRConServer::Comparator(const string& svPassword) const
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CRConServer::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
bool CRConServer::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
||||||
{
|
{
|
||||||
CConnectedNetConsoleData& data = m_Socket.GetAcceptedSocketData(m_nConnIndex);
|
netcon::request request;
|
||||||
|
|
||||||
cl_rcon::request request;
|
if (!SH_NetConUnpackEnvelope(this, pMsgBuf, nMsgLen, &request, rcon_debug.GetBool()))
|
||||||
if (!Decode(&request, pMsgBuf, nMsgLen))
|
|
||||||
{
|
{
|
||||||
Error(eDLL_T::SERVER, NO_ERROR, "Failed to decode RCON buffer\n");
|
Disconnect("received invalid message");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CConnectedNetConsoleData& data = m_Socket.GetAcceptedSocketData(m_nConnIndex);
|
||||||
|
|
||||||
if (!data.m_bAuthorized &&
|
if (!data.m_bAuthorized &&
|
||||||
request.requesttype() != cl_rcon::request_t::SERVERDATA_REQUEST_AUTH)
|
request.requesttype() != netcon::request_e::SERVERDATA_REQUEST_AUTH)
|
||||||
{
|
{
|
||||||
// Notify netconsole that authentication is required.
|
// Notify netconsole that authentication is required.
|
||||||
SendEncode(data.m_hSocket, s_NoAuthMessage, "",
|
SendEncoded(data.m_hSocket, s_NoAuthMessage, "",
|
||||||
sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH, static_cast<int>(eDLL_T::NETCON));
|
netcon::response_e::SERVERDATA_RESPONSE_AUTH, static_cast<int>(eDLL_T::NETCON));
|
||||||
|
|
||||||
data.m_bValidated = false;
|
data.m_bValidated = false;
|
||||||
data.m_nIgnoredMessage++;
|
data.m_nIgnoredMessage++;
|
||||||
@ -464,12 +452,12 @@ bool CRConServer::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
|||||||
}
|
}
|
||||||
switch (request.requesttype())
|
switch (request.requesttype())
|
||||||
{
|
{
|
||||||
case cl_rcon::request_t::SERVERDATA_REQUEST_AUTH:
|
case netcon::request_e::SERVERDATA_REQUEST_AUTH:
|
||||||
{
|
{
|
||||||
Authenticate(request, data);
|
Authenticate(request, data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND:
|
case netcon::request_e::SERVERDATA_REQUEST_EXECCOMMAND:
|
||||||
{
|
{
|
||||||
if (data.m_bAuthorized) // Only execute if auth was successful.
|
if (data.m_bAuthorized) // Only execute if auth was successful.
|
||||||
{
|
{
|
||||||
@ -477,7 +465,7 @@ bool CRConServer::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cl_rcon::request_t::SERVERDATA_REQUEST_SEND_CONSOLE_LOG:
|
case netcon::request_e::SERVERDATA_REQUEST_SEND_CONSOLE_LOG:
|
||||||
{
|
{
|
||||||
if (data.m_bAuthorized)
|
if (data.m_bAuthorized)
|
||||||
{
|
{
|
||||||
@ -507,7 +495,7 @@ bool CRConServer::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
|||||||
// Purpose: execute commands issued from netconsole (ignores all protection flags)
|
// Purpose: execute commands issued from netconsole (ignores all protection flags)
|
||||||
// Input : &request -
|
// Input : &request -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CRConServer::Execute(const cl_rcon::request& request) const
|
void CRConServer::Execute(const netcon::request& request) const
|
||||||
{
|
{
|
||||||
const string& commandString = request.requestmsg();
|
const string& commandString = request.requestmsg();
|
||||||
const char* const pCommandString = commandString.c_str();
|
const char* const pCommandString = commandString.c_str();
|
||||||
@ -590,7 +578,7 @@ bool CRConServer::CheckForBan(CConnectedNetConsoleData& data)
|
|||||||
// Only allow whitelisted at this point.
|
// Only allow whitelisted at this point.
|
||||||
if (!m_WhiteListAddress.CompareAdr(netAdr))
|
if (!m_WhiteListAddress.CompareAdr(netAdr))
|
||||||
{
|
{
|
||||||
if (sv_rcon_debug.GetBool())
|
if (rcon_debug.GetBool())
|
||||||
{
|
{
|
||||||
Msg(eDLL_T::SERVER, "Banned list is full; dropping '%s'\n", szNetAdr);
|
Msg(eDLL_T::SERVER, "Banned list is full; dropping '%s'\n", szNetAdr);
|
||||||
}
|
}
|
||||||
@ -680,7 +668,7 @@ void CRConServer::CloseNonAuthConnection(void)
|
|||||||
// Input : responseType -
|
// Input : responseType -
|
||||||
// Output : true if it should send, false otherwise
|
// Output : true if it should send, false otherwise
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CRConServer::ShouldSend(const sv_rcon::response_t responseType) const
|
bool CRConServer::ShouldSend(const netcon::response_e responseType) const
|
||||||
{
|
{
|
||||||
if (!IsInitialized() || !m_Socket.GetAcceptedSocketCount())
|
if (!IsInitialized() || !m_Socket.GetAcceptedSocketCount())
|
||||||
{
|
{
|
||||||
@ -688,7 +676,7 @@ bool CRConServer::ShouldSend(const sv_rcon::response_t responseType) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseType == sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG)
|
if (responseType == netcon::response_e::SERVERDATA_RESPONSE_CONSOLE_LOG)
|
||||||
{
|
{
|
||||||
if (!sv_rcon_sendlogs.GetBool() || !m_Socket.GetAuthorizedSocketCount())
|
if (!sv_rcon_sendlogs.GetBool() || !m_Socket.GetAuthorizedSocketCount())
|
||||||
{
|
{
|
||||||
@ -772,23 +760,6 @@ static void RCON_ConnectionCountChanged_f(IConVar* pConVar, const char* pOldStri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: change RCON password on server and drop all connections
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void RCON_PasswordChanged_f(IConVar* pConVar, const char* pOldString)
|
|
||||||
{
|
|
||||||
if (ConVar* pConVarRef = g_pCVar->FindVar(pConVar->GetName()))
|
|
||||||
{
|
|
||||||
if (strcmp(pOldString, pConVarRef->GetString()) == NULL)
|
|
||||||
return; // Same password.
|
|
||||||
|
|
||||||
if (RCONServer()->IsInitialized())
|
|
||||||
RCONServer()->SetPassword(pConVarRef->GetString());
|
|
||||||
else
|
|
||||||
RCONServer()->Init(); // Initialize first.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
static CRConServer s_RCONServer;
|
static CRConServer s_RCONServer;
|
||||||
CRConServer* RCONServer() // Singleton RCON Server.
|
CRConServer* RCONServer() // Singleton RCON Server.
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "tier1/NetAdr.h"
|
#include "tier1/NetAdr.h"
|
||||||
#include "tier2/socketcreator.h"
|
#include "tier2/socketcreator.h"
|
||||||
#include "protoc/sv_rcon.pb.h"
|
#include "protoc/netcon.pb.h"
|
||||||
#include "protoc/cl_rcon.pb.h"
|
|
||||||
#include "engine/shared/base_rcon.h"
|
#include "engine/shared/base_rcon.h"
|
||||||
|
|
||||||
#define RCON_MIN_PASSWORD_LEN 8
|
#define RCON_MIN_PASSWORD_LEN 8
|
||||||
@ -15,7 +14,7 @@ public:
|
|||||||
CRConServer(void);
|
CRConServer(void);
|
||||||
~CRConServer(void);
|
~CRConServer(void);
|
||||||
|
|
||||||
void Init(void);
|
void Init(const char* pPassword, const char* pNetKey = nullptr);
|
||||||
void Shutdown(void);
|
void Shutdown(void);
|
||||||
|
|
||||||
bool SetPassword(const char* pszPassword);
|
bool SetPassword(const char* pszPassword);
|
||||||
@ -24,36 +23,37 @@ public:
|
|||||||
void Think(void);
|
void Think(void);
|
||||||
void RunFrame(void);
|
void RunFrame(void);
|
||||||
|
|
||||||
bool SendEncode(const char* pResponseMsg, const char* pResponseVal,
|
bool SendEncoded(const char* pResponseMsg, const char* pResponseVal,
|
||||||
const sv_rcon::response_t responseType,
|
const netcon::response_e responseType,
|
||||||
const int nMessageId = static_cast<int>(eDLL_T::NETCON),
|
const int nMessageId = static_cast<int>(eDLL_T::NETCON),
|
||||||
const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
||||||
|
|
||||||
bool SendEncode(const SocketHandle_t hSocket, const char* pResponseMsg,
|
bool SendEncoded(const SocketHandle_t hSocket, const char* pResponseMsg,
|
||||||
const char* pResponseVal, const sv_rcon::response_t responseType,
|
const char* pResponseVal, const netcon::response_e responseType,
|
||||||
const int nMessageId = static_cast<int>(eDLL_T::NETCON),
|
const int nMessageId = static_cast<int>(eDLL_T::NETCON),
|
||||||
const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
||||||
|
|
||||||
bool SendToAll(const char* pMsgBuf, const int nMsgLen) const;
|
bool SendToAll(const char* pMsgBuf, const int nMsgLen) const;
|
||||||
bool Serialize(vector<char>& vecBuf, const char* pResponseMsg, const char* pResponseVal, const sv_rcon::response_t responseType,
|
bool Serialize(vector<char>& vecBuf, const char* pResponseMsg, const char* pResponseVal, const netcon::response_e responseType,
|
||||||
const int nMessageId = static_cast<int>(eDLL_T::NETCON), const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
const int nMessageId = static_cast<int>(eDLL_T::NETCON), const int nMessageType = static_cast<int>(LogType_t::LOG_NET)) const;
|
||||||
|
|
||||||
void Authenticate(const cl_rcon::request& request, CConnectedNetConsoleData& data);
|
void Authenticate(const netcon::request& request, CConnectedNetConsoleData& data);
|
||||||
bool Comparator(const string& svPassword) const;
|
bool Comparator(const string& svPassword) const;
|
||||||
|
|
||||||
virtual bool ProcessMessage(const char* pMsgBuf, const int nMsgLen) override;
|
virtual bool ProcessMessage(const char* pMsgBuf, const int nMsgLen) override;
|
||||||
|
|
||||||
void Execute(const cl_rcon::request& request) const;
|
void Execute(const netcon::request& request) const;
|
||||||
bool CheckForBan(CConnectedNetConsoleData& data);
|
bool CheckForBan(CConnectedNetConsoleData& data);
|
||||||
|
|
||||||
virtual void Disconnect(const char* szReason = nullptr) override;
|
virtual void Disconnect(const char* szReason = nullptr) override;
|
||||||
void Disconnect(const int nIndex, const char* szReason = nullptr);
|
void Disconnect(const int nIndex, const char* szReason = nullptr);
|
||||||
void CloseNonAuthConnection(void);
|
void CloseNonAuthConnection(void);
|
||||||
|
|
||||||
bool ShouldSend(const sv_rcon::response_t responseType) const;
|
bool ShouldSend(const netcon::response_e responseType) const;
|
||||||
bool IsInitialized(void) const;
|
bool IsInitialized(void) const;
|
||||||
|
|
||||||
int GetAuthenticatedCount(void) const;
|
int GetAuthenticatedCount(void) const;
|
||||||
|
void CloseAllSockets() { m_Socket.CloseAllAcceptedSockets(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_nConnIndex;
|
int m_nConnIndex;
|
||||||
|
@ -4,9 +4,126 @@
|
|||||||
//
|
//
|
||||||
//===========================================================================//
|
//===========================================================================//
|
||||||
#include "core/stdafx.h"
|
#include "core/stdafx.h"
|
||||||
|
#include "tier2/cryptutils.h"
|
||||||
#include "base_rcon.h"
|
#include "base_rcon.h"
|
||||||
#include "engine/net.h"
|
#include "engine/net.h"
|
||||||
#include "shared_rcon.h"
|
#include "shared_rcon.h"
|
||||||
|
#include "protoc/netcon.pb.h"
|
||||||
|
#include "mbedtls/base64.h"
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: sets the encryption key, a key will always be set, either random or
|
||||||
|
// the default key on failure
|
||||||
|
// Input : *pBase64NetKey -
|
||||||
|
// bUseDefaultOnFailure -
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CNetConBase::SetKey(const char* pBase64NetKey, const bool bUseDefaultOnFailure/* = false*/)
|
||||||
|
{
|
||||||
|
// Drop all connections as they would be unable to decipher the message
|
||||||
|
// frames once the key has been swapped.
|
||||||
|
m_Socket.CloseAllAcceptedSockets();
|
||||||
|
|
||||||
|
bool parseInput = pBase64NetKey && *pBase64NetKey;
|
||||||
|
bool genRandom = !parseInput;
|
||||||
|
|
||||||
|
bool failure = false;
|
||||||
|
|
||||||
|
if (parseInput)
|
||||||
|
{
|
||||||
|
const size_t keyLen = strlen(pBase64NetKey);
|
||||||
|
string tokenizedKey;
|
||||||
|
|
||||||
|
if (keyLen != AES_128_B64_ENCODED_SIZE || !IsValidBase64(pBase64NetKey, &tokenizedKey))
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "RCON Key: invalid key (%s)\n", pBase64NetKey);
|
||||||
|
failure = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t numBytesDecoded = 0;
|
||||||
|
|
||||||
|
const int decodeRet = mbedtls_base64_decode(m_NetKey, sizeof(m_NetKey), &numBytesDecoded,
|
||||||
|
reinterpret_cast<const unsigned char*>(tokenizedKey.c_str()), tokenizedKey.length());
|
||||||
|
|
||||||
|
if (decodeRet != 0)
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "RCON Key: decode error (%d)\n", decodeRet);
|
||||||
|
failure = true;
|
||||||
|
}
|
||||||
|
else if (numBytesDecoded != sizeof(m_NetKey))
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "RCON Key: read error (%zu != %zu)\n", numBytesDecoded, sizeof(m_NetKey));
|
||||||
|
failure = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Base64NetKey = tokenizedKey.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool useDefaultKey = false; // Last resort
|
||||||
|
|
||||||
|
if (genRandom || failure) // Generate random key
|
||||||
|
{
|
||||||
|
if (failure && bUseDefaultOnFailure)
|
||||||
|
{
|
||||||
|
useDefaultKey = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char* errorMsg = nullptr;
|
||||||
|
|
||||||
|
if (!CryptoGenRandom(m_NetKey, sizeof(m_NetKey), errorMsg))
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "RCON Key: generate error (%s)\n", errorMsg);
|
||||||
|
useDefaultKey = true;
|
||||||
|
}
|
||||||
|
else // Try to encode it
|
||||||
|
{
|
||||||
|
char encodedKey[45];
|
||||||
|
memset(encodedKey, 0, sizeof(encodedKey));
|
||||||
|
|
||||||
|
size_t numBytesEncoded = 0;
|
||||||
|
|
||||||
|
const int encodeRet = mbedtls_base64_encode(reinterpret_cast<unsigned char*>(&encodedKey),
|
||||||
|
sizeof(encodedKey), &numBytesEncoded, m_NetKey, sizeof(m_NetKey));
|
||||||
|
|
||||||
|
if (encodeRet != 0)
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "RCON Key: encode error (%d)\n", encodeRet);
|
||||||
|
useDefaultKey = true;
|
||||||
|
}
|
||||||
|
else if (numBytesEncoded != sizeof(m_NetKey))
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "RCON Key: write error (%zu != %zu)\n", numBytesEncoded, sizeof(m_NetKey));
|
||||||
|
failure = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Base64NetKey = encodedKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useDefaultKey) // Use the default key if everything failed (unlikely)
|
||||||
|
{
|
||||||
|
size_t numBytesDecoded = 0;
|
||||||
|
mbedtls_base64_decode(m_NetKey, sizeof(m_NetKey), &numBytesDecoded,
|
||||||
|
reinterpret_cast<const unsigned char*>(DEFAULT_NET_ENCRYPTION_KEY), AES_128_B64_ENCODED_SIZE);
|
||||||
|
|
||||||
|
m_Base64NetKey = DEFAULT_NET_ENCRYPTION_KEY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: gets the encryption key as a base64 encoded string
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
const char* CNetConBase::GetKey(void) const
|
||||||
|
{
|
||||||
|
return m_Base64NetKey.String();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: connect to remote
|
// Purpose: connect to remote
|
||||||
@ -56,7 +173,7 @@ bool CNetConBase::ProcessBuffer(CConnectedNetConsoleData& data,
|
|||||||
data.m_nPayloadRead = 0;
|
data.m_nPayloadRead = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (data.m_nPayloadRead+1 <= sizeof(int)) // Read size field.
|
else if (data.m_nPayloadRead < sizeof(int)) // Read size field.
|
||||||
{
|
{
|
||||||
data.m_RecvBuffer[data.m_nPayloadRead++] = *pRecvBuf;
|
data.m_RecvBuffer[data.m_nPayloadRead++] = *pRecvBuf;
|
||||||
|
|
||||||
@ -95,6 +212,39 @@ bool CNetConBase::ProcessBuffer(CConnectedNetConsoleData& data,
|
|||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: encrypt message to buffer
|
||||||
|
// Input : &ctx -
|
||||||
|
// *pInBuf -
|
||||||
|
// *pOutBuf -
|
||||||
|
// nDataLen -
|
||||||
|
// Output : true on success, false otherwise
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CNetConBase::Encrypt(CryptoContext_s& ctx, const char* pInBuf,
|
||||||
|
char* pOutBuf, const size_t nDataLen) const
|
||||||
|
{
|
||||||
|
if (Crypto_GenerateIV(ctx, reinterpret_cast<const unsigned char*>(pInBuf), nDataLen))
|
||||||
|
return Crypto_CTREncrypt(ctx, reinterpret_cast<const unsigned char*>(pInBuf),
|
||||||
|
reinterpret_cast<unsigned char*>(pOutBuf), m_NetKey, nDataLen);
|
||||||
|
|
||||||
|
return false; // failure
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: decrypt message to buffer
|
||||||
|
// Input : &ctx -
|
||||||
|
// *pInBuf -
|
||||||
|
// *pOutBuf -
|
||||||
|
// nDataLen -
|
||||||
|
// Output : true on success, false otherwise
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool CNetConBase::Decrypt(CryptoContext_s& ctx, const char* pInBuf,
|
||||||
|
char* pOutBuf, const size_t nDataLen) const
|
||||||
|
{
|
||||||
|
return Crypto_CTRDecrypt(ctx, reinterpret_cast<const unsigned char*>(pInBuf),
|
||||||
|
reinterpret_cast<unsigned char*>(pOutBuf), m_NetKey, nDataLen);
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: encode message to buffer
|
// Purpose: encode message to buffer
|
||||||
// Input : *pMsg -
|
// Input : *pMsg -
|
||||||
|
@ -2,14 +2,23 @@
|
|||||||
#define BASE_RCON_H
|
#define BASE_RCON_H
|
||||||
|
|
||||||
#include "tier1/NetAdr.h"
|
#include "tier1/NetAdr.h"
|
||||||
|
#include "tier2/cryptutils.h"
|
||||||
#include "tier2/socketcreator.h"
|
#include "tier2/socketcreator.h"
|
||||||
#include "protobuf/message_lite.h"
|
#include "protobuf/message_lite.h"
|
||||||
|
|
||||||
|
// Max size of the payload in the envelope frame
|
||||||
|
#define RCON_MAX_PAYLOAD_SIZE 1024*1024
|
||||||
|
|
||||||
class CNetConBase
|
class CNetConBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CNetConBase(void)
|
CNetConBase(void)
|
||||||
{}
|
{
|
||||||
|
memset(m_NetKey, 0, sizeof(m_NetKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetKey(const char* pBase64NetKey, const bool bUseDefaultOnFailure = false);
|
||||||
|
const char* GetKey(void) const;
|
||||||
|
|
||||||
virtual bool Connect(const char* pHostName, const int nHostPort = SOCKET_ERROR);
|
virtual bool Connect(const char* pHostName, const int nHostPort = SOCKET_ERROR);
|
||||||
virtual void Disconnect(const char* szReason = nullptr) { NOTE_UNUSED(szReason); };
|
virtual void Disconnect(const char* szReason = nullptr) { NOTE_UNUSED(szReason); };
|
||||||
@ -17,6 +26,9 @@ public:
|
|||||||
virtual bool ProcessBuffer(CConnectedNetConsoleData& data, const char* pRecvBuf, int nRecvLen, const int nMaxLen = SOCKET_ERROR);
|
virtual bool ProcessBuffer(CConnectedNetConsoleData& data, const char* pRecvBuf, int nRecvLen, const int nMaxLen = SOCKET_ERROR);
|
||||||
virtual bool ProcessMessage(const char* /*pMsgBuf*/, int /*nMsgLen*/) { return true; };
|
virtual bool ProcessMessage(const char* /*pMsgBuf*/, int /*nMsgLen*/) { return true; };
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
virtual bool Encode(google::protobuf::MessageLite* pMsg, char* pMsgBuf, const size_t nMsgLen) const;
|
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 Decode(google::protobuf::MessageLite* pMsg, const char* pMsgBuf, const size_t nMsgLen) const;
|
||||||
|
|
||||||
@ -29,6 +41,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
CSocketCreator m_Socket;
|
CSocketCreator m_Socket;
|
||||||
netadr_t m_Address;
|
netadr_t m_Address;
|
||||||
|
CryptoKey_t m_NetKey;
|
||||||
|
CUtlString m_Base64NetKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BASE_RCON_H
|
#endif // BASE_RCON_H
|
||||||
|
@ -6,6 +6,39 @@
|
|||||||
#include "core/stdafx.h"
|
#include "core/stdafx.h"
|
||||||
#include "base_rcon.h"
|
#include "base_rcon.h"
|
||||||
#include "shared_rcon.h"
|
#include "shared_rcon.h"
|
||||||
|
#include "protoc/netcon.pb.h"
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: serialize message to vector
|
||||||
|
// Input : *pBase -
|
||||||
|
// &vecBuf -
|
||||||
|
// *pResponseMsg -
|
||||||
|
// *pResponseVal -
|
||||||
|
// responseType -
|
||||||
|
// nMessageId -
|
||||||
|
// nMessageType -
|
||||||
|
// bEncrypt -
|
||||||
|
// bDebug -
|
||||||
|
// Output : true on success, false otherwise
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool SV_NetConSerialize(const CNetConBase* pBase, vector<char>& vecBuf, const char* pResponseMsg, const char* pResponseVal,
|
||||||
|
const netcon::response_e responseType, const int nMessageId, const int nMessageType, const bool bEncrypt, const bool bDebug)
|
||||||
|
{
|
||||||
|
netcon::response response;
|
||||||
|
|
||||||
|
response.set_messageid(nMessageId);
|
||||||
|
response.set_messagetype(nMessageType);
|
||||||
|
response.set_responsetype(responseType);
|
||||||
|
response.set_responsemsg(pResponseMsg);
|
||||||
|
response.set_responseval(pResponseVal);
|
||||||
|
|
||||||
|
if (!SH_NetConPackEnvelope(pBase, vecBuf, response.ByteSizeLong(), &response, bEncrypt, bDebug))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: serialize message to vector
|
// Purpose: serialize message to vector
|
||||||
@ -14,24 +47,22 @@
|
|||||||
// *szReqBuf -
|
// *szReqBuf -
|
||||||
// *szReqVal -
|
// *szReqVal -
|
||||||
// *requestType -
|
// *requestType -
|
||||||
|
// bEncrypt -
|
||||||
|
// bDebug -
|
||||||
// Output : true on success, false otherwise
|
// Output : true on success, false otherwise
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CL_NetConSerialize(const CNetConBase* pBase, vector<char>& vecBuf, const char* szReqBuf,
|
bool CL_NetConSerialize(const CNetConBase* pBase, vector<char>& vecBuf, const char* szReqBuf,
|
||||||
const char* szReqVal, const cl_rcon::request_t requestType)
|
const char* szReqVal, const netcon::request_e requestType, const bool bEncrypt, const bool bDebug)
|
||||||
{
|
{
|
||||||
cl_rcon::request request;
|
netcon::request request;
|
||||||
|
|
||||||
request.set_messageid(-1);
|
request.set_messageid(-1);
|
||||||
request.set_requesttype(requestType);
|
request.set_requesttype(requestType);
|
||||||
request.set_requestmsg(szReqBuf);
|
request.set_requestmsg(szReqBuf);
|
||||||
request.set_requestval(szReqVal);
|
request.set_requestval(szReqVal);
|
||||||
|
|
||||||
const size_t msgLen = request.ByteSizeLong();
|
if (!SH_NetConPackEnvelope(pBase, vecBuf, request.ByteSizeLong(), &request, bEncrypt, bDebug))
|
||||||
vecBuf.resize(msgLen);
|
|
||||||
|
|
||||||
if (!pBase->Encode(&request, &vecBuf[0], msgLen))
|
|
||||||
{
|
{
|
||||||
Error(eDLL_T::CLIENT, NO_ERROR, "Failed to encode RCON buffer\n");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +114,165 @@ bool CL_NetConConnect(CNetConBase* pBase, const char* pHostAdr, const int nHostP
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: packs a message envelope
|
||||||
|
// Input : *pBase -
|
||||||
|
// &outMsgBuf -
|
||||||
|
// nMsgLen -
|
||||||
|
// *inMsg -
|
||||||
|
// bEncrypt -
|
||||||
|
// bDebug -
|
||||||
|
// Output : true on success, false otherwise
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool SH_NetConPackEnvelope(const CNetConBase* pBase, vector<char>& outMsgBuf, const size_t nMsgLen,
|
||||||
|
google::protobuf::MessageLite* inMsg, const bool bEncrypt, const bool bDebug)
|
||||||
|
{
|
||||||
|
char* encodeBuf = new char[nMsgLen];
|
||||||
|
std::unique_ptr<char[]> encodedContainer(encodeBuf);
|
||||||
|
|
||||||
|
if (!pBase->Encode(inMsg, encodeBuf, nMsgLen))
|
||||||
|
{
|
||||||
|
if (bDebug)
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "Failed to encode RCON message data\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
netcon::envelope envelope;
|
||||||
|
envelope.set_encrypted(bEncrypt);
|
||||||
|
|
||||||
|
const char* dataBuf = encodeBuf;
|
||||||
|
std::unique_ptr<char[]> container;
|
||||||
|
|
||||||
|
if (bEncrypt)
|
||||||
|
{
|
||||||
|
char* encryptBuf = new char[nMsgLen];
|
||||||
|
container.reset(encryptBuf);
|
||||||
|
|
||||||
|
CryptoContext_s ctx;
|
||||||
|
if (!pBase->Encrypt(ctx, encodeBuf, encryptBuf, nMsgLen))
|
||||||
|
{
|
||||||
|
if (bDebug)
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "Failed to encrypt RCON message data\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
envelope.set_nonce(ctx.ivData, sizeof(ctx.ivData));
|
||||||
|
dataBuf = encryptBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
envelope.set_data(dataBuf, nMsgLen);
|
||||||
|
const size_t envelopeSize = envelope.ByteSizeLong();
|
||||||
|
|
||||||
|
outMsgBuf.resize(envelopeSize);
|
||||||
|
|
||||||
|
if (!pBase->Encode(&envelope, &outMsgBuf[0], envelopeSize))
|
||||||
|
{
|
||||||
|
if (bDebug)
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "Failed to encode RCON message envelope\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: unpacks a message envelope
|
||||||
|
// Input : *pBase -
|
||||||
|
// *pMsgBuf -
|
||||||
|
// nMsgLen -
|
||||||
|
// *outMsg -
|
||||||
|
// bEncrypt -
|
||||||
|
// bDebug -
|
||||||
|
// Output : true on success, false otherwise
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool SH_NetConUnpackEnvelope(const CNetConBase* pBase, const char* pMsgBuf, const size_t nMsgLen,
|
||||||
|
google::protobuf::MessageLite* outMsg, const bool bDebug)
|
||||||
|
{
|
||||||
|
netcon::envelope envelope;
|
||||||
|
|
||||||
|
if (!pBase->Decode(&envelope, pMsgBuf, nMsgLen))
|
||||||
|
{
|
||||||
|
if (bDebug)
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "Failed to decode RCON message envelope\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t msgLen = envelope.data().size();
|
||||||
|
|
||||||
|
if (msgLen > RCON_MAX_PAYLOAD_SIZE)
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "Data in RCON message envelope is too large (%zu > %zu)\n",
|
||||||
|
msgLen, RCON_MAX_PAYLOAD_SIZE);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* netMsg = envelope.data().c_str();
|
||||||
|
const char* dataBuf = netMsg;
|
||||||
|
|
||||||
|
std::unique_ptr<char[]> container;
|
||||||
|
|
||||||
|
if (envelope.encrypted())
|
||||||
|
{
|
||||||
|
char* decryptBuf = new char[msgLen];
|
||||||
|
container.reset(decryptBuf);
|
||||||
|
|
||||||
|
const size_t ivLen = envelope.nonce().size();
|
||||||
|
|
||||||
|
if (ivLen != sizeof(CryptoIV_t))
|
||||||
|
{
|
||||||
|
if (bDebug)
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "Nonce in RCON message envelope is invalid (%zu != %zu)\n",
|
||||||
|
ivLen, sizeof(CryptoIV_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CryptoContext_s ctx;
|
||||||
|
memcpy(ctx.ivData, envelope.nonce().data(), ivLen);
|
||||||
|
|
||||||
|
if (!pBase->Decrypt(ctx, netMsg, decryptBuf, msgLen))
|
||||||
|
{
|
||||||
|
if (bDebug)
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "Failed to decrypt RCON message data\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataBuf = decryptBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert(dataBuf);
|
||||||
|
|
||||||
|
if (!pBase->Decode(outMsg, dataBuf, msgLen))
|
||||||
|
{
|
||||||
|
if (bDebug)
|
||||||
|
{
|
||||||
|
Error(eDLL_T::ENGINE, NO_ERROR, "Failed to decode RCON message data\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: gets the netconsole data
|
// Purpose: gets the netconsole data
|
||||||
// Input : *pBase -
|
// Input : *pBase -
|
||||||
@ -119,3 +309,116 @@ SocketHandle_t SH_GetNetConSocketHandle(CNetConBase* pBase, const int iSocket)
|
|||||||
|
|
||||||
return pData->m_hSocket;
|
return pData->m_hSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _TOOLS
|
||||||
|
|
||||||
|
#ifndef CLIENT_DLL
|
||||||
|
#include "engine/server/sv_rcon.h"
|
||||||
|
#endif // !CLIENT_DLL
|
||||||
|
#ifndef DEDICATED
|
||||||
|
#include "engine/client/cl_rcon.h"
|
||||||
|
#endif // !DEDICATED
|
||||||
|
|
||||||
|
void RCON_KeyChanged_f(IConVar* pConVar, const char* pOldString);
|
||||||
|
void RCON_PasswordChanged_f(IConVar* pConVar, const char* pOldString);
|
||||||
|
|
||||||
|
ConVar rcon_debug("rcon_debug", "0", FCVAR_RELEASE, "Show rcon debug information ( !slower! )");
|
||||||
|
ConVar rcon_encryptframes("rcon_encryptframes", "1", FCVAR_RELEASE, "Whether to encrypt RCON messages");
|
||||||
|
ConVar rcon_key("rcon_key", "", FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Base64 remote server access encryption key (random if empty or invalid)", &RCON_KeyChanged_f);
|
||||||
|
ConVar rcon_password("rcon_password", "", FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access password (rcon server is disabled if empty)", &RCON_PasswordChanged_f);
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: change RCON key on server and client
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void RCON_KeyChanged_f(IConVar* pConVar, const char* pOldString)
|
||||||
|
{
|
||||||
|
if (ConVar* pConVarRef = g_pCVar->FindVar(pConVar->GetName()))
|
||||||
|
{
|
||||||
|
const char* pNewString = pConVarRef->GetString();
|
||||||
|
|
||||||
|
if (strcmp(pOldString, pNewString) == NULL)
|
||||||
|
return; // Same key.
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(DEDICATED) && !defined(CLIENT_DLL)
|
||||||
|
RCONServer()->SetKey(pNewString);
|
||||||
|
RCONClient()->SetKey(RCONServer()->GetKey()); // Sync server & client keys
|
||||||
|
|
||||||
|
Msg(eDLL_T::ENGINE, "Installed RCON Key: %s'%s%s%s'\n",
|
||||||
|
g_svReset, g_svGreyB, RCONClient()->GetKey(), g_svReset);
|
||||||
|
#else
|
||||||
|
#ifdef DEDICATED
|
||||||
|
RCONServer()->SetKey(pNewString);
|
||||||
|
|
||||||
|
Msg(eDLL_T::SERVER, "Installed RCON Key: %s'%s%s%s'\n",
|
||||||
|
g_svReset, g_svGreyB, RCONServer()->GetKey(), g_svReset);
|
||||||
|
#endif // DEDICATED
|
||||||
|
#ifdef CLIENT_DLL
|
||||||
|
RCONClient()->SetKey(pNewString);
|
||||||
|
|
||||||
|
Msg(eDLL_T::CLIENT, "Installed RCON Key: %s'%s%s%s'\n",
|
||||||
|
g_svReset, g_svGreyB, RCONClient()->GetKey(), g_svReset);
|
||||||
|
#endif // CLIENT_DLL
|
||||||
|
|
||||||
|
#endif // !DEDICATED && !CLIENT_DLL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: change RCON password on server and drop all connections
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void RCON_PasswordChanged_f(IConVar* pConVar, const char* pOldString)
|
||||||
|
{
|
||||||
|
if (ConVar* pConVarRef = g_pCVar->FindVar(pConVar->GetName()))
|
||||||
|
{
|
||||||
|
const char* pNewString = pConVarRef->GetString();
|
||||||
|
|
||||||
|
if (strcmp(pOldString, pNewString) == NULL)
|
||||||
|
return; // Same password.
|
||||||
|
|
||||||
|
#ifndef CLIENT_DLL
|
||||||
|
if (RCONServer()->IsInitialized())
|
||||||
|
{
|
||||||
|
RCONServer()->SetPassword(pNewString);
|
||||||
|
}
|
||||||
|
else // Initialize first
|
||||||
|
#endif // !CLIENT_DLL
|
||||||
|
{
|
||||||
|
#if !defined(DEDICATED) && !defined(CLIENT_DLL)
|
||||||
|
RCONServer()->Init(pNewString, rcon_key.GetString());
|
||||||
|
|
||||||
|
if (RCONServer()->IsInitialized())
|
||||||
|
{
|
||||||
|
// Sync server & client keys
|
||||||
|
RCONClient()->SetKey(RCONServer()->GetKey());
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#ifdef DEDICATED
|
||||||
|
RCONServer()->Init(pNewString, rcon_key.GetString());
|
||||||
|
#endif // DEDICATED
|
||||||
|
#ifdef CLIENT_DLL
|
||||||
|
RCONClient()->Init(rcon_key.GetString());
|
||||||
|
#endif // CLIENT_DLL
|
||||||
|
#endif // !DEDICATED && !CLIENT_DLL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef DEDICATED
|
||||||
|
void RCON_InitClientAndTrySyncKeys()
|
||||||
|
{
|
||||||
|
#ifndef CLIENT_DLL
|
||||||
|
if (RCONServer()->IsInitialized())
|
||||||
|
{
|
||||||
|
// Sync server & client keys
|
||||||
|
RCONClient()->Init(RCONServer()->GetKey());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // !CLIENT_DLL
|
||||||
|
{
|
||||||
|
RCONClient()->Init(rcon_key.GetString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // !DEDICATED
|
||||||
|
|
||||||
|
#endif // !_TOOLS
|
||||||
|
@ -1,13 +1,29 @@
|
|||||||
#ifndef SHARED_RCON_H
|
#ifndef SHARED_RCON_H
|
||||||
#define SHARED_RCON_H
|
#define SHARED_RCON_H
|
||||||
#include "base_rcon.h"
|
#include "base_rcon.h"
|
||||||
#include "protoc/sv_rcon.pb.h"
|
#include "protoc/netcon.pb.h"
|
||||||
#include "protoc/cl_rcon.pb.h"
|
|
||||||
|
#ifndef _TOOLS
|
||||||
|
extern ConVar rcon_debug;
|
||||||
|
extern ConVar rcon_encryptframes;
|
||||||
|
extern ConVar rcon_key;
|
||||||
|
extern ConVar rcon_password;
|
||||||
|
|
||||||
|
#ifndef DEDICATED
|
||||||
|
extern void RCON_InitClientAndTrySyncKeys();
|
||||||
|
#endif // !DEDICATED
|
||||||
|
#endif // _TOOLS
|
||||||
|
|
||||||
|
bool SV_NetConSerialize(const CNetConBase* pBase, vector<char>& vecBuf, const char* pResponseMsg, const char* pResponseVal,
|
||||||
|
const netcon::response_e responseType, const int nMessageId, const int nMessageType, const bool bEncrypt, const bool bDebug);
|
||||||
|
|
||||||
bool CL_NetConSerialize(const CNetConBase* pBase, vector<char>& vecBuf, const char* szReqBuf,
|
bool CL_NetConSerialize(const CNetConBase* pBase, vector<char>& vecBuf, const char* szReqBuf,
|
||||||
const char* szReqVal, const cl_rcon::request_t requestType);
|
const char* szReqVal, const netcon::request_e requestType, const bool bEncrypt, const bool bDebug);
|
||||||
bool CL_NetConConnect(CNetConBase* pBase, const char* pHostAdr, const int nHostPort);
|
bool CL_NetConConnect(CNetConBase* pBase, const char* pHostAdr, const int nHostPort);
|
||||||
|
|
||||||
|
bool SH_NetConPackEnvelope(const CNetConBase* pBase, vector<char>& outMsgBuf, const size_t nMsgLen, google::protobuf::MessageLite* inMsg, const bool bEncrypt, const bool bDebug);
|
||||||
|
bool SH_NetConUnpackEnvelope(const CNetConBase* pBase, const char* pMsgBuf, const size_t nMsgLen, google::protobuf::MessageLite* outMsg, const bool bDebug);
|
||||||
|
|
||||||
CConnectedNetConsoleData* SH_GetNetConData(CNetConBase* pBase, const int iSocket);
|
CConnectedNetConsoleData* SH_GetNetConData(CNetConBase* pBase, const int iSocket);
|
||||||
SocketHandle_t SH_GetNetConSocketHandle(CNetConBase* pBase, const int iSocket);
|
SocketHandle_t SH_GetNetConSocketHandle(CNetConBase* pBase, const int iSocket);
|
||||||
|
|
||||||
|
@ -48,8 +48,15 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE
|
|||||||
"tier2"
|
"tier2"
|
||||||
"libprotobuf"
|
"libprotobuf"
|
||||||
"libspdlog"
|
"libspdlog"
|
||||||
"SV_RCon_Pb"
|
"libmbedcrypto"
|
||||||
"CL_RCon_Pb"
|
"libmbedtls"
|
||||||
|
"libmbedx509"
|
||||||
|
"NetCon_Pb"
|
||||||
"Rpcrt4.lib"
|
"Rpcrt4.lib"
|
||||||
"ws2_32.lib"
|
"ws2_32.lib"
|
||||||
|
"bcrypt.lib"
|
||||||
|
"crypt32.lib"
|
||||||
|
)
|
||||||
|
target_include_directories( ${PROJECT_NAME} PRIVATE
|
||||||
|
"${THIRDPARTY_SOURCE_DIR}/mbedtls/include"
|
||||||
)
|
)
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
#include "tier1/NetAdr.h"
|
#include "tier1/NetAdr.h"
|
||||||
#include "tier2/socketcreator.h"
|
#include "tier2/socketcreator.h"
|
||||||
#include "windows/console.h"
|
#include "windows/console.h"
|
||||||
#include "protoc/sv_rcon.pb.h"
|
#include "protoc/netcon.pb.h"
|
||||||
#include "protoc/cl_rcon.pb.h"
|
|
||||||
#include "engine/net.h"
|
#include "engine/net.h"
|
||||||
#include "engine/shared/shared_rcon.h"
|
#include "engine/shared/shared_rcon.h"
|
||||||
#include "netconsole/netconsole.h"
|
#include "netconsole/netconsole.h"
|
||||||
@ -25,6 +24,7 @@ CNetCon::CNetCon(void)
|
|||||||
: m_bInitialized(false)
|
: m_bInitialized(false)
|
||||||
, m_bQuitting(false)
|
, m_bQuitting(false)
|
||||||
, m_bPromptConnect(true)
|
, m_bPromptConnect(true)
|
||||||
|
, m_bEncryptFrames(true)
|
||||||
, m_flTickInterval(0.05f)
|
, m_flTickInterval(0.05f)
|
||||||
{
|
{
|
||||||
// Empty character set used for ip addresses if we still need to initiate a
|
// Empty character set used for ip addresses if we still need to initiate a
|
||||||
@ -216,17 +216,17 @@ void CNetCon::RunInput(const string& lineInput)
|
|||||||
if (V_strcmp(cmd.Arg(0), "PASS") == 0) // Auth with RCON server.
|
if (V_strcmp(cmd.Arg(0), "PASS") == 0) // Auth with RCON server.
|
||||||
{
|
{
|
||||||
bSend = Serialize(vecMsg, cmd.Arg(1), "",
|
bSend = Serialize(vecMsg, cmd.Arg(1), "",
|
||||||
cl_rcon::request_t::SERVERDATA_REQUEST_AUTH);
|
netcon::request_e::SERVERDATA_REQUEST_AUTH);
|
||||||
}
|
}
|
||||||
else // Execute command query.
|
else // Execute command query.
|
||||||
{
|
{
|
||||||
bSend = Serialize(vecMsg, cmd.Arg(0), cmd.GetCommandString(),
|
bSend = Serialize(vecMsg, cmd.Arg(0), cmd.GetCommandString(),
|
||||||
cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
|
netcon::request_e::SERVERDATA_REQUEST_EXECCOMMAND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Single arg command query.
|
else // Single arg command query.
|
||||||
{
|
{
|
||||||
bSend = Serialize(vecMsg, lineInput.c_str(), "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND);
|
bSend = Serialize(vecMsg, lineInput.c_str(), "", netcon::request_e::SERVERDATA_REQUEST_EXECCOMMAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bSend) // Only send if serialization process was successful.
|
if (bSend) // Only send if serialization process was successful.
|
||||||
@ -244,25 +244,47 @@ void CNetCon::RunInput(const string& lineInput)
|
|||||||
|
|
||||||
if (cmd.ArgC() > 1)
|
if (cmd.ArgC() > 1)
|
||||||
{
|
{
|
||||||
const char* inAddr = cmd.Arg(0);
|
const char* inAdr = cmd.Arg(0);
|
||||||
const char* inPort = cmd.Arg(1);
|
const char* inKey = cmd.Arg(1);
|
||||||
|
|
||||||
if (!*inAddr || !*inPort)
|
if (!*inAdr)
|
||||||
{
|
{
|
||||||
Warning(eDLL_T::CLIENT, "No IP address or port provided\n");
|
Warning(eDLL_T::CLIENT, "No address provided\n");
|
||||||
SetPrompting(true);
|
SetPrompting(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Connect(inAddr, atoi(inPort)))
|
if (!*inKey)
|
||||||
|
{
|
||||||
|
Warning(eDLL_T::CLIENT, "No key provided; using default %s'%s%s%s'\n",
|
||||||
|
g_svReset, g_svGreyB, DEFAULT_NET_ENCRYPTION_KEY, g_svReset);
|
||||||
|
|
||||||
|
SetKey(DEFAULT_NET_ENCRYPTION_KEY, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetKey(inKey, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bEncryptFrames = true;
|
||||||
|
|
||||||
|
Msg(eDLL_T::CLIENT, "Attempting connection to '%s' with key %s'%s%s%s'\n",
|
||||||
|
inAdr, g_svReset, g_svGreyB, GetKey(), g_svReset);
|
||||||
|
|
||||||
|
if (!Connect(inAdr))
|
||||||
{
|
{
|
||||||
SetPrompting(true);
|
SetPrompting(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else // No encryption
|
||||||
{
|
{
|
||||||
if (!Connect(cmd.GetCommandString()))
|
const char* inAdr = cmd.GetCommandString();
|
||||||
|
m_bEncryptFrames = false;
|
||||||
|
|
||||||
|
Msg(eDLL_T::CLIENT, "Attempting connection to '%s'\n", inAdr);
|
||||||
|
|
||||||
|
if (!Connect(inAdr))
|
||||||
{
|
{
|
||||||
SetPrompting(true);
|
SetPrompting(true);
|
||||||
return;
|
return;
|
||||||
@ -287,7 +309,7 @@ bool CNetCon::RunFrame(void)
|
|||||||
}
|
}
|
||||||
else if (GetPrompting())
|
else if (GetPrompting())
|
||||||
{
|
{
|
||||||
Msg(eDLL_T::NONE, "Enter [<IP>]:<PORT> or <IP> <PORT>: ");
|
Msg(eDLL_T::NONE, "Enter [<address>]:<port> and <key>: ");
|
||||||
SetPrompting(false);
|
SetPrompting(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,18 +382,17 @@ void CNetCon::Disconnect(const char* szReason)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CNetCon::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
bool CNetCon::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
||||||
{
|
{
|
||||||
sv_rcon::response response;
|
netcon::response response;
|
||||||
bool bSuccess = Decode(&response, pMsgBuf, nMsgLen);
|
|
||||||
|
|
||||||
if (!bSuccess)
|
if (!SH_NetConUnpackEnvelope(this, pMsgBuf, nMsgLen, &response, true))
|
||||||
{
|
{
|
||||||
Error(eDLL_T::CLIENT, NO_ERROR, "Failed to decode RCON buffer\n");
|
Disconnect("received invalid message");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (response.responsetype())
|
switch (response.responsetype())
|
||||||
{
|
{
|
||||||
case sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH:
|
case netcon::response_e::SERVERDATA_RESPONSE_AUTH:
|
||||||
{
|
{
|
||||||
if (!response.responseval().empty())
|
if (!response.responseval().empty())
|
||||||
{
|
{
|
||||||
@ -379,7 +400,7 @@ bool CNetCon::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
|||||||
if (!i) // Means we are marked 'input only' on the rcon server.
|
if (!i) // Means we are marked 'input only' on the rcon server.
|
||||||
{
|
{
|
||||||
vector<char> vecMsg;
|
vector<char> vecMsg;
|
||||||
bool ret = Serialize(vecMsg, "", "1", cl_rcon::request_t::SERVERDATA_REQUEST_SEND_CONSOLE_LOG);
|
bool ret = Serialize(vecMsg, "", "1", netcon::request_e::SERVERDATA_REQUEST_SEND_CONSOLE_LOG);
|
||||||
|
|
||||||
if (ret && !Send(GetSocket(), vecMsg.data(), int(vecMsg.size())))
|
if (ret && !Send(GetSocket(), vecMsg.data(), int(vecMsg.size())))
|
||||||
{
|
{
|
||||||
@ -391,7 +412,7 @@ bool CNetCon::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
|||||||
Msg(eDLL_T::NETCON, "%s", response.responsemsg().c_str());
|
Msg(eDLL_T::NETCON, "%s", response.responsemsg().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG:
|
case netcon::response_e::SERVERDATA_RESPONSE_CONSOLE_LOG:
|
||||||
{
|
{
|
||||||
NetMsg(static_cast<LogType_t>(response.messagetype()),
|
NetMsg(static_cast<LogType_t>(response.messagetype()),
|
||||||
static_cast<eDLL_T>(response.messageid()),
|
static_cast<eDLL_T>(response.messageid()),
|
||||||
@ -416,9 +437,9 @@ bool CNetCon::ProcessMessage(const char* pMsgBuf, const int nMsgLen)
|
|||||||
// Output : true on success, false otherwise
|
// Output : true on success, false otherwise
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CNetCon::Serialize(vector<char>& vecBuf, const char* szReqBuf,
|
bool CNetCon::Serialize(vector<char>& vecBuf, const char* szReqBuf,
|
||||||
const char* szReqVal, const cl_rcon::request_t requestType) const
|
const char* szReqVal, const netcon::request_e requestType) const
|
||||||
{
|
{
|
||||||
return CL_NetConSerialize(this, vecBuf, szReqBuf, szReqVal, requestType);
|
return CL_NetConSerialize(this, vecBuf, szReqBuf, szReqVal, requestType, m_bEncryptFrames, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
//===========================================================================//
|
//===========================================================================//
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "tier1/cmd.h"
|
#include "tier1/cmd.h"
|
||||||
#include "protoc/cl_rcon.pb.h"
|
#include "protoc/netcon.pb.h"
|
||||||
#include "protoc/sv_rcon.pb.h"
|
|
||||||
#include "engine/shared/base_rcon.h"
|
#include "engine/shared/base_rcon.h"
|
||||||
|
|
||||||
constexpr const char* NETCON_VERSION = "2.0.0.1";
|
constexpr const char* NETCON_VERSION = "2.0.0.1";
|
||||||
@ -37,7 +36,7 @@ public:
|
|||||||
virtual bool ProcessMessage(const char* pMsgBuf, const int nMsgLen) override;
|
virtual bool ProcessMessage(const char* pMsgBuf, const int nMsgLen) override;
|
||||||
|
|
||||||
bool Serialize(vector<char>& vecBuf, const char* szReqBuf,
|
bool Serialize(vector<char>& vecBuf, const char* szReqBuf,
|
||||||
const char* szReqVal, const cl_rcon::request_t requestType) const;
|
const char* szReqVal, const netcon::request_e requestType) const;
|
||||||
|
|
||||||
SocketHandle_t GetSocket(void);
|
SocketHandle_t GetSocket(void);
|
||||||
bool IsInitialized(void) const;
|
bool IsInitialized(void) const;
|
||||||
@ -47,6 +46,7 @@ private:
|
|||||||
bool m_bInitialized;
|
bool m_bInitialized;
|
||||||
bool m_bQuitting;
|
bool m_bQuitting;
|
||||||
bool m_bPromptConnect;
|
bool m_bPromptConnect;
|
||||||
|
bool m_bEncryptFrames;
|
||||||
float m_flTickInterval;
|
float m_flTickInterval;
|
||||||
|
|
||||||
characterset_t m_CharacterSet;
|
characterset_t m_CharacterSet;
|
||||||
|
@ -23,8 +23,7 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE
|
|||||||
"libspdlog"
|
"libspdlog"
|
||||||
|
|
||||||
"SigCache_Pb"
|
"SigCache_Pb"
|
||||||
"SV_RCon_Pb"
|
"NetCon_Pb"
|
||||||
"CL_RCon_Pb"
|
|
||||||
"Rpcrt4.lib"
|
"Rpcrt4.lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,25 +23,13 @@ add_sources( SOURCE_GROUP "Runtime"
|
|||||||
end_sources()
|
end_sources()
|
||||||
thirdparty_suppress_warnings()
|
thirdparty_suppress_warnings()
|
||||||
|
|
||||||
add_module( "lib" "SV_RCon_Pb" "vpc" ${FOLDER_CONTEXT} FALSE TRUE )
|
add_module( "lib" "NetCon_Pb" "vpc" ${FOLDER_CONTEXT} FALSE TRUE )
|
||||||
|
|
||||||
start_sources()
|
start_sources()
|
||||||
|
|
||||||
add_sources( SOURCE_GROUP "Runtime"
|
add_sources( SOURCE_GROUP "Runtime"
|
||||||
"sv_rcon.pb.cc"
|
"netcon.pb.cc"
|
||||||
"sv_rcon.pb.h"
|
"netcon.pb.h"
|
||||||
)
|
|
||||||
|
|
||||||
end_sources()
|
|
||||||
thirdparty_suppress_warnings()
|
|
||||||
|
|
||||||
add_module( "lib" "CL_RCon_Pb" "vpc" ${FOLDER_CONTEXT} FALSE TRUE )
|
|
||||||
|
|
||||||
start_sources()
|
|
||||||
|
|
||||||
add_sources( SOURCE_GROUP "Runtime"
|
|
||||||
"cl_rcon.pb.cc"
|
|
||||||
"cl_rcon.pb.h"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
end_sources()
|
end_sources()
|
||||||
|
@ -1,489 +0,0 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
// source: cl_rcon.proto
|
|
||||||
|
|
||||||
#include "cl_rcon.pb.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include <thirdparty/protobuf/io/coded_stream.h>
|
|
||||||
#include <thirdparty/protobuf/extension_set.h>
|
|
||||||
#include <thirdparty/protobuf/wire_format_lite.h>
|
|
||||||
#include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h>
|
|
||||||
// @@protoc_insertion_point(includes)
|
|
||||||
#include <thirdparty/protobuf/port_def.inc>
|
|
||||||
|
|
||||||
PROTOBUF_PRAGMA_INIT_SEG
|
|
||||||
|
|
||||||
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
|
|
||||||
namespace _pbi = _pb::internal;
|
|
||||||
|
|
||||||
namespace cl_rcon {
|
|
||||||
PROTOBUF_CONSTEXPR request::request(
|
|
||||||
::_pbi::ConstantInitialized): _impl_{
|
|
||||||
/*decltype(_impl_._has_bits_)*/{}
|
|
||||||
, /*decltype(_impl_._cached_size_)*/{}
|
|
||||||
, /*decltype(_impl_.requestmsg_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
|
||||||
, /*decltype(_impl_.requestval_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
|
||||||
, /*decltype(_impl_.messageid_)*/0
|
|
||||||
, /*decltype(_impl_.messagetype_)*/0
|
|
||||||
, /*decltype(_impl_.requesttype_)*/0} {}
|
|
||||||
struct requestDefaultTypeInternal {
|
|
||||||
PROTOBUF_CONSTEXPR requestDefaultTypeInternal()
|
|
||||||
: _instance(::_pbi::ConstantInitialized{}) {}
|
|
||||||
~requestDefaultTypeInternal() {}
|
|
||||||
union {
|
|
||||||
request _instance;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 requestDefaultTypeInternal _request_default_instance_;
|
|
||||||
} // namespace cl_rcon
|
|
||||||
namespace cl_rcon {
|
|
||||||
bool request_t_IsValid(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> request_t_strings[3] = {};
|
|
||||||
|
|
||||||
static const char request_t_names[] =
|
|
||||||
"SERVERDATA_REQUEST_AUTH"
|
|
||||||
"SERVERDATA_REQUEST_EXECCOMMAND"
|
|
||||||
"SERVERDATA_REQUEST_SEND_CONSOLE_LOG";
|
|
||||||
|
|
||||||
static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry request_t_entries[] = {
|
|
||||||
{ {request_t_names + 0, 23}, 1 },
|
|
||||||
{ {request_t_names + 23, 30}, 0 },
|
|
||||||
{ {request_t_names + 53, 35}, 2 },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int request_t_entries_by_number[] = {
|
|
||||||
1, // 0 -> SERVERDATA_REQUEST_EXECCOMMAND
|
|
||||||
0, // 1 -> SERVERDATA_REQUEST_AUTH
|
|
||||||
2, // 2 -> SERVERDATA_REQUEST_SEND_CONSOLE_LOG
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::string& request_t_Name(
|
|
||||||
request_t value) {
|
|
||||||
static const bool dummy =
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
|
|
||||||
request_t_entries,
|
|
||||||
request_t_entries_by_number,
|
|
||||||
3, request_t_strings);
|
|
||||||
(void) dummy;
|
|
||||||
int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
|
|
||||||
request_t_entries,
|
|
||||||
request_t_entries_by_number,
|
|
||||||
3, value);
|
|
||||||
return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
|
|
||||||
request_t_strings[idx].get();
|
|
||||||
}
|
|
||||||
bool request_t_Parse(
|
|
||||||
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, request_t* value) {
|
|
||||||
int int_value;
|
|
||||||
bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
|
|
||||||
request_t_entries, 3, name, &int_value);
|
|
||||||
if (success) {
|
|
||||||
*value = static_cast<request_t>(int_value);
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
class request::_Internal {
|
|
||||||
public:
|
|
||||||
using HasBits = decltype(std::declval<request>()._impl_._has_bits_);
|
|
||||||
static void set_has_messageid(HasBits* has_bits) {
|
|
||||||
(*has_bits)[0] |= 4u;
|
|
||||||
}
|
|
||||||
static void set_has_messagetype(HasBits* has_bits) {
|
|
||||||
(*has_bits)[0] |= 8u;
|
|
||||||
}
|
|
||||||
static void set_has_requesttype(HasBits* has_bits) {
|
|
||||||
(*has_bits)[0] |= 16u;
|
|
||||||
}
|
|
||||||
static void set_has_requestmsg(HasBits* has_bits) {
|
|
||||||
(*has_bits)[0] |= 1u;
|
|
||||||
}
|
|
||||||
static void set_has_requestval(HasBits* has_bits) {
|
|
||||||
(*has_bits)[0] |= 2u;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
request::request(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
|
||||||
bool is_message_owned)
|
|
||||||
: ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
|
|
||||||
SharedCtor(arena, is_message_owned);
|
|
||||||
// @@protoc_insertion_point(arena_constructor:cl_rcon.request)
|
|
||||||
}
|
|
||||||
request::request(const request& from)
|
|
||||||
: ::PROTOBUF_NAMESPACE_ID::MessageLite() {
|
|
||||||
request* const _this = this; (void)_this;
|
|
||||||
new (&_impl_) Impl_{
|
|
||||||
decltype(_impl_._has_bits_){from._impl_._has_bits_}
|
|
||||||
, /*decltype(_impl_._cached_size_)*/{}
|
|
||||||
, decltype(_impl_.requestmsg_){}
|
|
||||||
, decltype(_impl_.requestval_){}
|
|
||||||
, decltype(_impl_.messageid_){}
|
|
||||||
, decltype(_impl_.messagetype_){}
|
|
||||||
, decltype(_impl_.requesttype_){}};
|
|
||||||
|
|
||||||
_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
|
|
||||||
_impl_.requestmsg_.InitDefault();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
_impl_.requestmsg_.Set("", GetArenaForAllocation());
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (from._internal_has_requestmsg()) {
|
|
||||||
_this->_impl_.requestmsg_.Set(from._internal_requestmsg(),
|
|
||||||
_this->GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
_impl_.requestval_.InitDefault();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
_impl_.requestval_.Set("", GetArenaForAllocation());
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (from._internal_has_requestval()) {
|
|
||||||
_this->_impl_.requestval_.Set(from._internal_requestval(),
|
|
||||||
_this->GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
::memcpy(&_impl_.messageid_, &from._impl_.messageid_,
|
|
||||||
static_cast<size_t>(reinterpret_cast<char*>(&_impl_.requesttype_) -
|
|
||||||
reinterpret_cast<char*>(&_impl_.messageid_)) + sizeof(_impl_.requesttype_));
|
|
||||||
// @@protoc_insertion_point(copy_constructor:cl_rcon.request)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void request::SharedCtor(
|
|
||||||
::_pb::Arena* arena, bool is_message_owned) {
|
|
||||||
(void)arena;
|
|
||||||
(void)is_message_owned;
|
|
||||||
new (&_impl_) Impl_{
|
|
||||||
decltype(_impl_._has_bits_){}
|
|
||||||
, /*decltype(_impl_._cached_size_)*/{}
|
|
||||||
, decltype(_impl_.requestmsg_){}
|
|
||||||
, decltype(_impl_.requestval_){}
|
|
||||||
, decltype(_impl_.messageid_){0}
|
|
||||||
, decltype(_impl_.messagetype_){0}
|
|
||||||
, decltype(_impl_.requesttype_){0}
|
|
||||||
};
|
|
||||||
_impl_.requestmsg_.InitDefault();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
_impl_.requestmsg_.Set("", GetArenaForAllocation());
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
_impl_.requestval_.InitDefault();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
_impl_.requestval_.Set("", GetArenaForAllocation());
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
}
|
|
||||||
|
|
||||||
request::~request() {
|
|
||||||
// @@protoc_insertion_point(destructor:cl_rcon.request)
|
|
||||||
if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) {
|
|
||||||
(void)arena;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SharedDtor();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void request::SharedDtor() {
|
|
||||||
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
|
|
||||||
_impl_.requestmsg_.Destroy();
|
|
||||||
_impl_.requestval_.Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
void request::SetCachedSize(int size) const {
|
|
||||||
_impl_._cached_size_.Set(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void request::Clear() {
|
|
||||||
// @@protoc_insertion_point(message_clear_start:cl_rcon.request)
|
|
||||||
uint32_t cached_has_bits = 0;
|
|
||||||
// Prevent compiler warnings about cached_has_bits being unused
|
|
||||||
(void) cached_has_bits;
|
|
||||||
|
|
||||||
cached_has_bits = _impl_._has_bits_[0];
|
|
||||||
if (cached_has_bits & 0x00000003u) {
|
|
||||||
if (cached_has_bits & 0x00000001u) {
|
|
||||||
_impl_.requestmsg_.ClearNonDefaultToEmpty();
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x00000002u) {
|
|
||||||
_impl_.requestval_.ClearNonDefaultToEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x0000001cu) {
|
|
||||||
::memset(&_impl_.messageid_, 0, static_cast<size_t>(
|
|
||||||
reinterpret_cast<char*>(&_impl_.requesttype_) -
|
|
||||||
reinterpret_cast<char*>(&_impl_.messageid_)) + sizeof(_impl_.requesttype_));
|
|
||||||
}
|
|
||||||
_impl_._has_bits_.Clear();
|
|
||||||
_internal_metadata_.Clear<std::string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* request::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
|
|
||||||
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
|
|
||||||
_Internal::HasBits has_bits{};
|
|
||||||
while (!ctx->Done(&ptr)) {
|
|
||||||
uint32_t tag;
|
|
||||||
ptr = ::_pbi::ReadTag(ptr, &tag);
|
|
||||||
switch (tag >> 3) {
|
|
||||||
// optional int32 messageID = 1;
|
|
||||||
case 1:
|
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
|
|
||||||
_Internal::set_has_messageid(&has_bits);
|
|
||||||
_impl_.messageid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
|
|
||||||
CHK_(ptr);
|
|
||||||
} else
|
|
||||||
goto handle_unusual;
|
|
||||||
continue;
|
|
||||||
// optional int32 messageType = 2;
|
|
||||||
case 2:
|
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
|
|
||||||
_Internal::set_has_messagetype(&has_bits);
|
|
||||||
_impl_.messagetype_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
|
|
||||||
CHK_(ptr);
|
|
||||||
} else
|
|
||||||
goto handle_unusual;
|
|
||||||
continue;
|
|
||||||
// optional .cl_rcon.request_t requestType = 3;
|
|
||||||
case 3:
|
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
|
|
||||||
uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
|
|
||||||
CHK_(ptr);
|
|
||||||
_internal_set_requesttype(static_cast<::cl_rcon::request_t>(val));
|
|
||||||
} else
|
|
||||||
goto handle_unusual;
|
|
||||||
continue;
|
|
||||||
// optional string requestMsg = 4;
|
|
||||||
case 4:
|
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
|
|
||||||
auto str = _internal_mutable_requestmsg();
|
|
||||||
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
|
|
||||||
CHK_(ptr);
|
|
||||||
CHK_(::_pbi::VerifyUTF8(str, nullptr));
|
|
||||||
} else
|
|
||||||
goto handle_unusual;
|
|
||||||
continue;
|
|
||||||
// optional string requestVal = 5;
|
|
||||||
case 5:
|
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
|
|
||||||
auto str = _internal_mutable_requestval();
|
|
||||||
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
|
|
||||||
CHK_(ptr);
|
|
||||||
CHK_(::_pbi::VerifyUTF8(str, nullptr));
|
|
||||||
} else
|
|
||||||
goto handle_unusual;
|
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
goto handle_unusual;
|
|
||||||
} // switch
|
|
||||||
handle_unusual:
|
|
||||||
if ((tag == 0) || ((tag & 7) == 4)) {
|
|
||||||
CHK_(ptr);
|
|
||||||
ctx->SetLastTag(tag);
|
|
||||||
goto message_done;
|
|
||||||
}
|
|
||||||
ptr = UnknownFieldParse(
|
|
||||||
tag,
|
|
||||||
_internal_metadata_.mutable_unknown_fields<std::string>(),
|
|
||||||
ptr, ctx);
|
|
||||||
CHK_(ptr != nullptr);
|
|
||||||
} // while
|
|
||||||
message_done:
|
|
||||||
_impl_._has_bits_.Or(has_bits);
|
|
||||||
return ptr;
|
|
||||||
failure:
|
|
||||||
ptr = nullptr;
|
|
||||||
goto message_done;
|
|
||||||
#undef CHK_
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* request::_InternalSerialize(
|
|
||||||
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
|
|
||||||
// @@protoc_insertion_point(serialize_to_array_start:cl_rcon.request)
|
|
||||||
uint32_t cached_has_bits = 0;
|
|
||||||
(void) cached_has_bits;
|
|
||||||
|
|
||||||
// optional int32 messageID = 1;
|
|
||||||
if (_internal_has_messageid()) {
|
|
||||||
target = stream->EnsureSpace(target);
|
|
||||||
target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_messageid(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 messageType = 2;
|
|
||||||
if (_internal_has_messagetype()) {
|
|
||||||
target = stream->EnsureSpace(target);
|
|
||||||
target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_messagetype(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional .cl_rcon.request_t requestType = 3;
|
|
||||||
if (_internal_has_requesttype()) {
|
|
||||||
target = stream->EnsureSpace(target);
|
|
||||||
target = ::_pbi::WireFormatLite::WriteEnumToArray(
|
|
||||||
3, this->_internal_requesttype(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional string requestMsg = 4;
|
|
||||||
if (_internal_has_requestmsg()) {
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->_internal_requestmsg().data(), static_cast<int>(this->_internal_requestmsg().length()),
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"cl_rcon.request.requestMsg");
|
|
||||||
target = stream->WriteStringMaybeAliased(
|
|
||||||
4, this->_internal_requestmsg(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional string requestVal = 5;
|
|
||||||
if (_internal_has_requestval()) {
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->_internal_requestval().data(), static_cast<int>(this->_internal_requestval().length()),
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"cl_rcon.request.requestVal");
|
|
||||||
target = stream->WriteStringMaybeAliased(
|
|
||||||
5, this->_internal_requestval(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
|
||||||
target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
|
|
||||||
static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
|
|
||||||
}
|
|
||||||
// @@protoc_insertion_point(serialize_to_array_end:cl_rcon.request)
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t request::ByteSizeLong() const {
|
|
||||||
// @@protoc_insertion_point(message_byte_size_start:cl_rcon.request)
|
|
||||||
size_t total_size = 0;
|
|
||||||
|
|
||||||
uint32_t cached_has_bits = 0;
|
|
||||||
// Prevent compiler warnings about cached_has_bits being unused
|
|
||||||
(void) cached_has_bits;
|
|
||||||
|
|
||||||
cached_has_bits = _impl_._has_bits_[0];
|
|
||||||
if (cached_has_bits & 0x0000001fu) {
|
|
||||||
// optional string requestMsg = 4;
|
|
||||||
if (cached_has_bits & 0x00000001u) {
|
|
||||||
total_size += 1 +
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
|
|
||||||
this->_internal_requestmsg());
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional string requestVal = 5;
|
|
||||||
if (cached_has_bits & 0x00000002u) {
|
|
||||||
total_size += 1 +
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
|
|
||||||
this->_internal_requestval());
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 messageID = 1;
|
|
||||||
if (cached_has_bits & 0x00000004u) {
|
|
||||||
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_messageid());
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 messageType = 2;
|
|
||||||
if (cached_has_bits & 0x00000008u) {
|
|
||||||
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_messagetype());
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional .cl_rcon.request_t requestType = 3;
|
|
||||||
if (cached_has_bits & 0x00000010u) {
|
|
||||||
total_size += 1 +
|
|
||||||
::_pbi::WireFormatLite::EnumSize(this->_internal_requesttype());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
|
||||||
total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
|
|
||||||
}
|
|
||||||
int cached_size = ::_pbi::ToCachedSize(total_size);
|
|
||||||
SetCachedSize(cached_size);
|
|
||||||
return total_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void request::CheckTypeAndMergeFrom(
|
|
||||||
const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
|
|
||||||
MergeFrom(*::_pbi::DownCast<const request*>(
|
|
||||||
&from));
|
|
||||||
}
|
|
||||||
|
|
||||||
void request::MergeFrom(const request& from) {
|
|
||||||
request* const _this = this;
|
|
||||||
// @@protoc_insertion_point(class_specific_merge_from_start:cl_rcon.request)
|
|
||||||
GOOGLE_DCHECK_NE(&from, _this);
|
|
||||||
uint32_t cached_has_bits = 0;
|
|
||||||
(void) cached_has_bits;
|
|
||||||
|
|
||||||
cached_has_bits = from._impl_._has_bits_[0];
|
|
||||||
if (cached_has_bits & 0x0000001fu) {
|
|
||||||
if (cached_has_bits & 0x00000001u) {
|
|
||||||
_this->_internal_set_requestmsg(from._internal_requestmsg());
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x00000002u) {
|
|
||||||
_this->_internal_set_requestval(from._internal_requestval());
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x00000004u) {
|
|
||||||
_this->_impl_.messageid_ = from._impl_.messageid_;
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x00000008u) {
|
|
||||||
_this->_impl_.messagetype_ = from._impl_.messagetype_;
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x00000010u) {
|
|
||||||
_this->_impl_.requesttype_ = from._impl_.requesttype_;
|
|
||||||
}
|
|
||||||
_this->_impl_._has_bits_[0] |= cached_has_bits;
|
|
||||||
}
|
|
||||||
_this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void request::CopyFrom(const request& from) {
|
|
||||||
// @@protoc_insertion_point(class_specific_copy_from_start:cl_rcon.request)
|
|
||||||
if (&from == this) return;
|
|
||||||
Clear();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool request::IsInitialized() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void request::InternalSwap(request* other) {
|
|
||||||
using std::swap;
|
|
||||||
auto* lhs_arena = GetArenaForAllocation();
|
|
||||||
auto* rhs_arena = other->GetArenaForAllocation();
|
|
||||||
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
|
|
||||||
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
|
|
||||||
&_impl_.requestmsg_, lhs_arena,
|
|
||||||
&other->_impl_.requestmsg_, rhs_arena
|
|
||||||
);
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
|
|
||||||
&_impl_.requestval_, lhs_arena,
|
|
||||||
&other->_impl_.requestval_, rhs_arena
|
|
||||||
);
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::memswap<
|
|
||||||
PROTOBUF_FIELD_OFFSET(request, _impl_.requesttype_)
|
|
||||||
+ sizeof(request::_impl_.requesttype_)
|
|
||||||
- PROTOBUF_FIELD_OFFSET(request, _impl_.messageid_)>(
|
|
||||||
reinterpret_cast<char*>(&_impl_.messageid_),
|
|
||||||
reinterpret_cast<char*>(&other->_impl_.messageid_));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string request::GetTypeName() const {
|
|
||||||
return "cl_rcon.request";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
|
||||||
} // namespace cl_rcon
|
|
||||||
PROTOBUF_NAMESPACE_OPEN
|
|
||||||
template<> PROTOBUF_NOINLINE ::cl_rcon::request*
|
|
||||||
Arena::CreateMaybeMessage< ::cl_rcon::request >(Arena* arena) {
|
|
||||||
return Arena::CreateMessageInternal< ::cl_rcon::request >(arena);
|
|
||||||
}
|
|
||||||
PROTOBUF_NAMESPACE_CLOSE
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope)
|
|
||||||
#include <thirdparty/protobuf/port_undef.inc>
|
|
@ -1,530 +0,0 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
// source: cl_rcon.proto
|
|
||||||
|
|
||||||
#ifndef GOOGLE_PROTOBUF_INCLUDED_cl_5frcon_2eproto
|
|
||||||
#define GOOGLE_PROTOBUF_INCLUDED_cl_5frcon_2eproto
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <thirdparty/protobuf/port_def.inc>
|
|
||||||
#if PROTOBUF_VERSION < 3021000
|
|
||||||
#error This file was generated by a newer version of protoc which is
|
|
||||||
#error incompatible with your Protocol Buffer headers. Please update
|
|
||||||
#error your headers.
|
|
||||||
#endif
|
|
||||||
#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION
|
|
||||||
#error This file was generated by an older version of protoc which is
|
|
||||||
#error incompatible with your Protocol Buffer headers. Please
|
|
||||||
#error regenerate this file with a newer version of protoc.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <thirdparty/protobuf/port_undef.inc>
|
|
||||||
#include <thirdparty/protobuf/io/coded_stream.h>
|
|
||||||
#include <thirdparty/protobuf/arena.h>
|
|
||||||
#include <thirdparty/protobuf/arenastring.h>
|
|
||||||
#include <thirdparty/protobuf/generated_message_util.h>
|
|
||||||
#include <thirdparty/protobuf/metadata_lite.h>
|
|
||||||
#include <thirdparty/protobuf/message_lite.h>
|
|
||||||
#include <thirdparty/protobuf/repeated_field.h> // IWYU pragma: export
|
|
||||||
#include <thirdparty/protobuf/extension_set.h> // IWYU pragma: export
|
|
||||||
#include <thirdparty/protobuf/generated_enum_util.h>
|
|
||||||
// @@protoc_insertion_point(includes)
|
|
||||||
#include <thirdparty/protobuf/port_def.inc>
|
|
||||||
#define PROTOBUF_INTERNAL_EXPORT_cl_5frcon_2eproto
|
|
||||||
PROTOBUF_NAMESPACE_OPEN
|
|
||||||
namespace internal {
|
|
||||||
class AnyMetadata;
|
|
||||||
} // namespace internal
|
|
||||||
PROTOBUF_NAMESPACE_CLOSE
|
|
||||||
|
|
||||||
// Internal implementation detail -- do not use these members.
|
|
||||||
struct TableStruct_cl_5frcon_2eproto {
|
|
||||||
static const uint32_t offsets[];
|
|
||||||
};
|
|
||||||
namespace cl_rcon {
|
|
||||||
class request;
|
|
||||||
struct requestDefaultTypeInternal;
|
|
||||||
extern requestDefaultTypeInternal _request_default_instance_;
|
|
||||||
} // namespace cl_rcon
|
|
||||||
PROTOBUF_NAMESPACE_OPEN
|
|
||||||
template<> ::cl_rcon::request* Arena::CreateMaybeMessage<::cl_rcon::request>(Arena*);
|
|
||||||
PROTOBUF_NAMESPACE_CLOSE
|
|
||||||
namespace cl_rcon {
|
|
||||||
|
|
||||||
enum request_t : int {
|
|
||||||
SERVERDATA_REQUEST_EXECCOMMAND = 0,
|
|
||||||
SERVERDATA_REQUEST_AUTH = 1,
|
|
||||||
SERVERDATA_REQUEST_SEND_CONSOLE_LOG = 2,
|
|
||||||
request_t_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::min(),
|
|
||||||
request_t_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::max()
|
|
||||||
};
|
|
||||||
bool request_t_IsValid(int value);
|
|
||||||
constexpr request_t request_t_MIN = SERVERDATA_REQUEST_EXECCOMMAND;
|
|
||||||
constexpr request_t request_t_MAX = SERVERDATA_REQUEST_SEND_CONSOLE_LOG;
|
|
||||||
constexpr int request_t_ARRAYSIZE = request_t_MAX + 1;
|
|
||||||
|
|
||||||
const std::string& request_t_Name(request_t value);
|
|
||||||
template<typename T>
|
|
||||||
inline const std::string& request_t_Name(T enum_t_value) {
|
|
||||||
static_assert(::std::is_same<T, request_t>::value ||
|
|
||||||
::std::is_integral<T>::value,
|
|
||||||
"Incorrect type passed to function request_t_Name.");
|
|
||||||
return request_t_Name(static_cast<request_t>(enum_t_value));
|
|
||||||
}
|
|
||||||
bool request_t_Parse(
|
|
||||||
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, request_t* value);
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
class request final :
|
|
||||||
public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:cl_rcon.request) */ {
|
|
||||||
public:
|
|
||||||
inline request() : request(nullptr) {}
|
|
||||||
~request() override;
|
|
||||||
explicit PROTOBUF_CONSTEXPR request(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
|
|
||||||
|
|
||||||
request(const request& from);
|
|
||||||
request(request&& from) noexcept
|
|
||||||
: request() {
|
|
||||||
*this = ::std::move(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline request& operator=(const request& from) {
|
|
||||||
CopyFrom(from);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
inline request& operator=(request&& from) noexcept {
|
|
||||||
if (this == &from) return *this;
|
|
||||||
if (GetOwningArena() == from.GetOwningArena()
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
|
|
||||||
&& GetOwningArena() != nullptr
|
|
||||||
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
|
|
||||||
) {
|
|
||||||
InternalSwap(&from);
|
|
||||||
} else {
|
|
||||||
CopyFrom(from);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const request& default_instance() {
|
|
||||||
return *internal_default_instance();
|
|
||||||
}
|
|
||||||
static inline const request* internal_default_instance() {
|
|
||||||
return reinterpret_cast<const request*>(
|
|
||||||
&_request_default_instance_);
|
|
||||||
}
|
|
||||||
static constexpr int kIndexInFileMessages =
|
|
||||||
0;
|
|
||||||
|
|
||||||
friend void swap(request& a, request& b) {
|
|
||||||
a.Swap(&b);
|
|
||||||
}
|
|
||||||
inline void Swap(request* other) {
|
|
||||||
if (other == this) return;
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
|
|
||||||
if (GetOwningArena() != nullptr &&
|
|
||||||
GetOwningArena() == other->GetOwningArena()) {
|
|
||||||
#else // PROTOBUF_FORCE_COPY_IN_SWAP
|
|
||||||
if (GetOwningArena() == other->GetOwningArena()) {
|
|
||||||
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
|
|
||||||
InternalSwap(other);
|
|
||||||
} else {
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void UnsafeArenaSwap(request* other) {
|
|
||||||
if (other == this) return;
|
|
||||||
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
|
|
||||||
InternalSwap(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
|
||||||
|
|
||||||
request* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
|
|
||||||
return CreateMaybeMessage<request>(arena);
|
|
||||||
}
|
|
||||||
void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final;
|
|
||||||
void CopyFrom(const request& from);
|
|
||||||
void MergeFrom(const request& from);
|
|
||||||
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
|
|
||||||
bool IsInitialized() const final;
|
|
||||||
|
|
||||||
size_t ByteSizeLong() const final;
|
|
||||||
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
|
|
||||||
uint8_t* _InternalSerialize(
|
|
||||||
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
|
|
||||||
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
|
|
||||||
void SharedDtor();
|
|
||||||
void SetCachedSize(int size) const;
|
|
||||||
void InternalSwap(request* other);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
|
|
||||||
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
|
|
||||||
return "cl_rcon.request";
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
explicit request(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
|
||||||
bool is_message_owned = false);
|
|
||||||
public:
|
|
||||||
|
|
||||||
std::string GetTypeName() const final;
|
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
|
||||||
|
|
||||||
enum : int {
|
|
||||||
kRequestMsgFieldNumber = 4,
|
|
||||||
kRequestValFieldNumber = 5,
|
|
||||||
kMessageIDFieldNumber = 1,
|
|
||||||
kMessageTypeFieldNumber = 2,
|
|
||||||
kRequestTypeFieldNumber = 3,
|
|
||||||
};
|
|
||||||
// optional string requestMsg = 4;
|
|
||||||
bool has_requestmsg() const;
|
|
||||||
private:
|
|
||||||
bool _internal_has_requestmsg() const;
|
|
||||||
public:
|
|
||||||
void clear_requestmsg();
|
|
||||||
const std::string& requestmsg() const;
|
|
||||||
template <typename ArgT0 = const std::string&, typename... ArgT>
|
|
||||||
void set_requestmsg(ArgT0&& arg0, ArgT... args);
|
|
||||||
std::string* mutable_requestmsg();
|
|
||||||
PROTOBUF_NODISCARD std::string* release_requestmsg();
|
|
||||||
void set_allocated_requestmsg(std::string* requestmsg);
|
|
||||||
private:
|
|
||||||
const std::string& _internal_requestmsg() const;
|
|
||||||
inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestmsg(const std::string& value);
|
|
||||||
std::string* _internal_mutable_requestmsg();
|
|
||||||
public:
|
|
||||||
|
|
||||||
// optional string requestVal = 5;
|
|
||||||
bool has_requestval() const;
|
|
||||||
private:
|
|
||||||
bool _internal_has_requestval() const;
|
|
||||||
public:
|
|
||||||
void clear_requestval();
|
|
||||||
const std::string& requestval() const;
|
|
||||||
template <typename ArgT0 = const std::string&, typename... ArgT>
|
|
||||||
void set_requestval(ArgT0&& arg0, ArgT... args);
|
|
||||||
std::string* mutable_requestval();
|
|
||||||
PROTOBUF_NODISCARD std::string* release_requestval();
|
|
||||||
void set_allocated_requestval(std::string* requestval);
|
|
||||||
private:
|
|
||||||
const std::string& _internal_requestval() const;
|
|
||||||
inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestval(const std::string& value);
|
|
||||||
std::string* _internal_mutable_requestval();
|
|
||||||
public:
|
|
||||||
|
|
||||||
// optional int32 messageID = 1;
|
|
||||||
bool has_messageid() const;
|
|
||||||
private:
|
|
||||||
bool _internal_has_messageid() const;
|
|
||||||
public:
|
|
||||||
void clear_messageid();
|
|
||||||
int32_t messageid() const;
|
|
||||||
void set_messageid(int32_t value);
|
|
||||||
private:
|
|
||||||
int32_t _internal_messageid() const;
|
|
||||||
void _internal_set_messageid(int32_t value);
|
|
||||||
public:
|
|
||||||
|
|
||||||
// optional int32 messageType = 2;
|
|
||||||
bool has_messagetype() const;
|
|
||||||
private:
|
|
||||||
bool _internal_has_messagetype() const;
|
|
||||||
public:
|
|
||||||
void clear_messagetype();
|
|
||||||
int32_t messagetype() const;
|
|
||||||
void set_messagetype(int32_t value);
|
|
||||||
private:
|
|
||||||
int32_t _internal_messagetype() const;
|
|
||||||
void _internal_set_messagetype(int32_t value);
|
|
||||||
public:
|
|
||||||
|
|
||||||
// optional .cl_rcon.request_t requestType = 3;
|
|
||||||
bool has_requesttype() const;
|
|
||||||
private:
|
|
||||||
bool _internal_has_requesttype() const;
|
|
||||||
public:
|
|
||||||
void clear_requesttype();
|
|
||||||
::cl_rcon::request_t requesttype() const;
|
|
||||||
void set_requesttype(::cl_rcon::request_t value);
|
|
||||||
private:
|
|
||||||
::cl_rcon::request_t _internal_requesttype() const;
|
|
||||||
void _internal_set_requesttype(::cl_rcon::request_t value);
|
|
||||||
public:
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(class_scope:cl_rcon.request)
|
|
||||||
private:
|
|
||||||
class _Internal;
|
|
||||||
|
|
||||||
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
|
|
||||||
typedef void InternalArenaConstructable_;
|
|
||||||
typedef void DestructorSkippable_;
|
|
||||||
struct Impl_ {
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
|
|
||||||
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr requestmsg_;
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr requestval_;
|
|
||||||
int32_t messageid_;
|
|
||||||
int32_t messagetype_;
|
|
||||||
int requesttype_;
|
|
||||||
};
|
|
||||||
union { Impl_ _impl_; };
|
|
||||||
friend struct ::TableStruct_cl_5frcon_2eproto;
|
|
||||||
};
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
|
||||||
#endif // __GNUC__
|
|
||||||
// request
|
|
||||||
|
|
||||||
// optional int32 messageID = 1;
|
|
||||||
inline bool request::_internal_has_messageid() const {
|
|
||||||
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline bool request::has_messageid() const {
|
|
||||||
return _internal_has_messageid();
|
|
||||||
}
|
|
||||||
inline void request::clear_messageid() {
|
|
||||||
_impl_.messageid_ = 0;
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000004u;
|
|
||||||
}
|
|
||||||
inline int32_t request::_internal_messageid() const {
|
|
||||||
return _impl_.messageid_;
|
|
||||||
}
|
|
||||||
inline int32_t request::messageid() const {
|
|
||||||
// @@protoc_insertion_point(field_get:cl_rcon.request.messageID)
|
|
||||||
return _internal_messageid();
|
|
||||||
}
|
|
||||||
inline void request::_internal_set_messageid(int32_t value) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000004u;
|
|
||||||
_impl_.messageid_ = value;
|
|
||||||
}
|
|
||||||
inline void request::set_messageid(int32_t value) {
|
|
||||||
_internal_set_messageid(value);
|
|
||||||
// @@protoc_insertion_point(field_set:cl_rcon.request.messageID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 messageType = 2;
|
|
||||||
inline bool request::_internal_has_messagetype() const {
|
|
||||||
bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline bool request::has_messagetype() const {
|
|
||||||
return _internal_has_messagetype();
|
|
||||||
}
|
|
||||||
inline void request::clear_messagetype() {
|
|
||||||
_impl_.messagetype_ = 0;
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000008u;
|
|
||||||
}
|
|
||||||
inline int32_t request::_internal_messagetype() const {
|
|
||||||
return _impl_.messagetype_;
|
|
||||||
}
|
|
||||||
inline int32_t request::messagetype() const {
|
|
||||||
// @@protoc_insertion_point(field_get:cl_rcon.request.messageType)
|
|
||||||
return _internal_messagetype();
|
|
||||||
}
|
|
||||||
inline void request::_internal_set_messagetype(int32_t value) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000008u;
|
|
||||||
_impl_.messagetype_ = value;
|
|
||||||
}
|
|
||||||
inline void request::set_messagetype(int32_t value) {
|
|
||||||
_internal_set_messagetype(value);
|
|
||||||
// @@protoc_insertion_point(field_set:cl_rcon.request.messageType)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional .cl_rcon.request_t requestType = 3;
|
|
||||||
inline bool request::_internal_has_requesttype() const {
|
|
||||||
bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline bool request::has_requesttype() const {
|
|
||||||
return _internal_has_requesttype();
|
|
||||||
}
|
|
||||||
inline void request::clear_requesttype() {
|
|
||||||
_impl_.requesttype_ = 0;
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000010u;
|
|
||||||
}
|
|
||||||
inline ::cl_rcon::request_t request::_internal_requesttype() const {
|
|
||||||
return static_cast< ::cl_rcon::request_t >(_impl_.requesttype_);
|
|
||||||
}
|
|
||||||
inline ::cl_rcon::request_t request::requesttype() const {
|
|
||||||
// @@protoc_insertion_point(field_get:cl_rcon.request.requestType)
|
|
||||||
return _internal_requesttype();
|
|
||||||
}
|
|
||||||
inline void request::_internal_set_requesttype(::cl_rcon::request_t value) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000010u;
|
|
||||||
_impl_.requesttype_ = value;
|
|
||||||
}
|
|
||||||
inline void request::set_requesttype(::cl_rcon::request_t value) {
|
|
||||||
_internal_set_requesttype(value);
|
|
||||||
// @@protoc_insertion_point(field_set:cl_rcon.request.requestType)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional string requestMsg = 4;
|
|
||||||
inline bool request::_internal_has_requestmsg() const {
|
|
||||||
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline bool request::has_requestmsg() const {
|
|
||||||
return _internal_has_requestmsg();
|
|
||||||
}
|
|
||||||
inline void request::clear_requestmsg() {
|
|
||||||
_impl_.requestmsg_.ClearToEmpty();
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000001u;
|
|
||||||
}
|
|
||||||
inline const std::string& request::requestmsg() const {
|
|
||||||
// @@protoc_insertion_point(field_get:cl_rcon.request.requestMsg)
|
|
||||||
return _internal_requestmsg();
|
|
||||||
}
|
|
||||||
template <typename ArgT0, typename... ArgT>
|
|
||||||
inline PROTOBUF_ALWAYS_INLINE
|
|
||||||
void request::set_requestmsg(ArgT0&& arg0, ArgT... args) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000001u;
|
|
||||||
_impl_.requestmsg_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
|
||||||
// @@protoc_insertion_point(field_set:cl_rcon.request.requestMsg)
|
|
||||||
}
|
|
||||||
inline std::string* request::mutable_requestmsg() {
|
|
||||||
std::string* _s = _internal_mutable_requestmsg();
|
|
||||||
// @@protoc_insertion_point(field_mutable:cl_rcon.request.requestMsg)
|
|
||||||
return _s;
|
|
||||||
}
|
|
||||||
inline const std::string& request::_internal_requestmsg() const {
|
|
||||||
return _impl_.requestmsg_.Get();
|
|
||||||
}
|
|
||||||
inline void request::_internal_set_requestmsg(const std::string& value) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000001u;
|
|
||||||
_impl_.requestmsg_.Set(value, GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
inline std::string* request::_internal_mutable_requestmsg() {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000001u;
|
|
||||||
return _impl_.requestmsg_.Mutable(GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
inline std::string* request::release_requestmsg() {
|
|
||||||
// @@protoc_insertion_point(field_release:cl_rcon.request.requestMsg)
|
|
||||||
if (!_internal_has_requestmsg()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000001u;
|
|
||||||
auto* p = _impl_.requestmsg_.Release();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (_impl_.requestmsg_.IsDefault()) {
|
|
||||||
_impl_.requestmsg_.Set("", GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
inline void request::set_allocated_requestmsg(std::string* requestmsg) {
|
|
||||||
if (requestmsg != nullptr) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000001u;
|
|
||||||
} else {
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000001u;
|
|
||||||
}
|
|
||||||
_impl_.requestmsg_.SetAllocated(requestmsg, GetArenaForAllocation());
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (_impl_.requestmsg_.IsDefault()) {
|
|
||||||
_impl_.requestmsg_.Set("", GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:cl_rcon.request.requestMsg)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional string requestVal = 5;
|
|
||||||
inline bool request::_internal_has_requestval() const {
|
|
||||||
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline bool request::has_requestval() const {
|
|
||||||
return _internal_has_requestval();
|
|
||||||
}
|
|
||||||
inline void request::clear_requestval() {
|
|
||||||
_impl_.requestval_.ClearToEmpty();
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000002u;
|
|
||||||
}
|
|
||||||
inline const std::string& request::requestval() const {
|
|
||||||
// @@protoc_insertion_point(field_get:cl_rcon.request.requestVal)
|
|
||||||
return _internal_requestval();
|
|
||||||
}
|
|
||||||
template <typename ArgT0, typename... ArgT>
|
|
||||||
inline PROTOBUF_ALWAYS_INLINE
|
|
||||||
void request::set_requestval(ArgT0&& arg0, ArgT... args) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000002u;
|
|
||||||
_impl_.requestval_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
|
||||||
// @@protoc_insertion_point(field_set:cl_rcon.request.requestVal)
|
|
||||||
}
|
|
||||||
inline std::string* request::mutable_requestval() {
|
|
||||||
std::string* _s = _internal_mutable_requestval();
|
|
||||||
// @@protoc_insertion_point(field_mutable:cl_rcon.request.requestVal)
|
|
||||||
return _s;
|
|
||||||
}
|
|
||||||
inline const std::string& request::_internal_requestval() const {
|
|
||||||
return _impl_.requestval_.Get();
|
|
||||||
}
|
|
||||||
inline void request::_internal_set_requestval(const std::string& value) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000002u;
|
|
||||||
_impl_.requestval_.Set(value, GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
inline std::string* request::_internal_mutable_requestval() {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000002u;
|
|
||||||
return _impl_.requestval_.Mutable(GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
inline std::string* request::release_requestval() {
|
|
||||||
// @@protoc_insertion_point(field_release:cl_rcon.request.requestVal)
|
|
||||||
if (!_internal_has_requestval()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000002u;
|
|
||||||
auto* p = _impl_.requestval_.Release();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (_impl_.requestval_.IsDefault()) {
|
|
||||||
_impl_.requestval_.Set("", GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
inline void request::set_allocated_requestval(std::string* requestval) {
|
|
||||||
if (requestval != nullptr) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000002u;
|
|
||||||
} else {
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000002u;
|
|
||||||
}
|
|
||||||
_impl_.requestval_.SetAllocated(requestval, GetArenaForAllocation());
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (_impl_.requestval_.IsDefault()) {
|
|
||||||
_impl_.requestval_.Set("", GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:cl_rcon.request.requestVal)
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif // __GNUC__
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
|
||||||
|
|
||||||
} // namespace cl_rcon
|
|
||||||
|
|
||||||
PROTOBUF_NAMESPACE_OPEN
|
|
||||||
|
|
||||||
template <> struct is_proto_enum< ::cl_rcon::request_t> : ::std::true_type {};
|
|
||||||
|
|
||||||
PROTOBUF_NAMESPACE_CLOSE
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope)
|
|
||||||
|
|
||||||
#include <thirdparty/protobuf/port_undef.inc>
|
|
||||||
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_cl_5frcon_2eproto
|
|
1235
src/protoc/netcon.pb.cc
Normal file
1235
src/protoc/netcon.pb.cc
Normal file
File diff suppressed because it is too large
Load Diff
1279
src/protoc/netcon.pb.h
Normal file
1279
src/protoc/netcon.pb.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,485 +0,0 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
// source: sv_rcon.proto
|
|
||||||
|
|
||||||
#include "sv_rcon.pb.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include <thirdparty/protobuf/io/coded_stream.h>
|
|
||||||
#include <thirdparty/protobuf/extension_set.h>
|
|
||||||
#include <thirdparty/protobuf/wire_format_lite.h>
|
|
||||||
#include <thirdparty/protobuf/io/zero_copy_stream_impl_lite.h>
|
|
||||||
// @@protoc_insertion_point(includes)
|
|
||||||
#include <thirdparty/protobuf/port_def.inc>
|
|
||||||
|
|
||||||
PROTOBUF_PRAGMA_INIT_SEG
|
|
||||||
|
|
||||||
namespace _pb = ::PROTOBUF_NAMESPACE_ID;
|
|
||||||
namespace _pbi = _pb::internal;
|
|
||||||
|
|
||||||
namespace sv_rcon {
|
|
||||||
PROTOBUF_CONSTEXPR response::response(
|
|
||||||
::_pbi::ConstantInitialized): _impl_{
|
|
||||||
/*decltype(_impl_._has_bits_)*/{}
|
|
||||||
, /*decltype(_impl_._cached_size_)*/{}
|
|
||||||
, /*decltype(_impl_.responsemsg_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
|
||||||
, /*decltype(_impl_.responseval_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
|
||||||
, /*decltype(_impl_.messageid_)*/0
|
|
||||||
, /*decltype(_impl_.messagetype_)*/0
|
|
||||||
, /*decltype(_impl_.responsetype_)*/0} {}
|
|
||||||
struct responseDefaultTypeInternal {
|
|
||||||
PROTOBUF_CONSTEXPR responseDefaultTypeInternal()
|
|
||||||
: _instance(::_pbi::ConstantInitialized{}) {}
|
|
||||||
~responseDefaultTypeInternal() {}
|
|
||||||
union {
|
|
||||||
response _instance;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 responseDefaultTypeInternal _response_default_instance_;
|
|
||||||
} // namespace sv_rcon
|
|
||||||
namespace sv_rcon {
|
|
||||||
bool response_t_IsValid(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> response_t_strings[2] = {};
|
|
||||||
|
|
||||||
static const char response_t_names[] =
|
|
||||||
"SERVERDATA_RESPONSE_AUTH"
|
|
||||||
"SERVERDATA_RESPONSE_CONSOLE_LOG";
|
|
||||||
|
|
||||||
static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry response_t_entries[] = {
|
|
||||||
{ {response_t_names + 0, 24}, 0 },
|
|
||||||
{ {response_t_names + 24, 31}, 1 },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int response_t_entries_by_number[] = {
|
|
||||||
0, // 0 -> SERVERDATA_RESPONSE_AUTH
|
|
||||||
1, // 1 -> SERVERDATA_RESPONSE_CONSOLE_LOG
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::string& response_t_Name(
|
|
||||||
response_t value) {
|
|
||||||
static const bool dummy =
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
|
|
||||||
response_t_entries,
|
|
||||||
response_t_entries_by_number,
|
|
||||||
2, response_t_strings);
|
|
||||||
(void) dummy;
|
|
||||||
int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
|
|
||||||
response_t_entries,
|
|
||||||
response_t_entries_by_number,
|
|
||||||
2, value);
|
|
||||||
return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
|
|
||||||
response_t_strings[idx].get();
|
|
||||||
}
|
|
||||||
bool response_t_Parse(
|
|
||||||
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, response_t* value) {
|
|
||||||
int int_value;
|
|
||||||
bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
|
|
||||||
response_t_entries, 2, name, &int_value);
|
|
||||||
if (success) {
|
|
||||||
*value = static_cast<response_t>(int_value);
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
class response::_Internal {
|
|
||||||
public:
|
|
||||||
using HasBits = decltype(std::declval<response>()._impl_._has_bits_);
|
|
||||||
static void set_has_messageid(HasBits* has_bits) {
|
|
||||||
(*has_bits)[0] |= 4u;
|
|
||||||
}
|
|
||||||
static void set_has_messagetype(HasBits* has_bits) {
|
|
||||||
(*has_bits)[0] |= 8u;
|
|
||||||
}
|
|
||||||
static void set_has_responsetype(HasBits* has_bits) {
|
|
||||||
(*has_bits)[0] |= 16u;
|
|
||||||
}
|
|
||||||
static void set_has_responsemsg(HasBits* has_bits) {
|
|
||||||
(*has_bits)[0] |= 1u;
|
|
||||||
}
|
|
||||||
static void set_has_responseval(HasBits* has_bits) {
|
|
||||||
(*has_bits)[0] |= 2u;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
response::response(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
|
||||||
bool is_message_owned)
|
|
||||||
: ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
|
|
||||||
SharedCtor(arena, is_message_owned);
|
|
||||||
// @@protoc_insertion_point(arena_constructor:sv_rcon.response)
|
|
||||||
}
|
|
||||||
response::response(const response& from)
|
|
||||||
: ::PROTOBUF_NAMESPACE_ID::MessageLite() {
|
|
||||||
response* const _this = this; (void)_this;
|
|
||||||
new (&_impl_) Impl_{
|
|
||||||
decltype(_impl_._has_bits_){from._impl_._has_bits_}
|
|
||||||
, /*decltype(_impl_._cached_size_)*/{}
|
|
||||||
, decltype(_impl_.responsemsg_){}
|
|
||||||
, decltype(_impl_.responseval_){}
|
|
||||||
, decltype(_impl_.messageid_){}
|
|
||||||
, decltype(_impl_.messagetype_){}
|
|
||||||
, decltype(_impl_.responsetype_){}};
|
|
||||||
|
|
||||||
_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
|
|
||||||
_impl_.responsemsg_.InitDefault();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
_impl_.responsemsg_.Set("", GetArenaForAllocation());
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (from._internal_has_responsemsg()) {
|
|
||||||
_this->_impl_.responsemsg_.Set(from._internal_responsemsg(),
|
|
||||||
_this->GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
_impl_.responseval_.InitDefault();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
_impl_.responseval_.Set("", GetArenaForAllocation());
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (from._internal_has_responseval()) {
|
|
||||||
_this->_impl_.responseval_.Set(from._internal_responseval(),
|
|
||||||
_this->GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
::memcpy(&_impl_.messageid_, &from._impl_.messageid_,
|
|
||||||
static_cast<size_t>(reinterpret_cast<char*>(&_impl_.responsetype_) -
|
|
||||||
reinterpret_cast<char*>(&_impl_.messageid_)) + sizeof(_impl_.responsetype_));
|
|
||||||
// @@protoc_insertion_point(copy_constructor:sv_rcon.response)
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void response::SharedCtor(
|
|
||||||
::_pb::Arena* arena, bool is_message_owned) {
|
|
||||||
(void)arena;
|
|
||||||
(void)is_message_owned;
|
|
||||||
new (&_impl_) Impl_{
|
|
||||||
decltype(_impl_._has_bits_){}
|
|
||||||
, /*decltype(_impl_._cached_size_)*/{}
|
|
||||||
, decltype(_impl_.responsemsg_){}
|
|
||||||
, decltype(_impl_.responseval_){}
|
|
||||||
, decltype(_impl_.messageid_){0}
|
|
||||||
, decltype(_impl_.messagetype_){0}
|
|
||||||
, decltype(_impl_.responsetype_){0}
|
|
||||||
};
|
|
||||||
_impl_.responsemsg_.InitDefault();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
_impl_.responsemsg_.Set("", GetArenaForAllocation());
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
_impl_.responseval_.InitDefault();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
_impl_.responseval_.Set("", GetArenaForAllocation());
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
}
|
|
||||||
|
|
||||||
response::~response() {
|
|
||||||
// @@protoc_insertion_point(destructor:sv_rcon.response)
|
|
||||||
if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) {
|
|
||||||
(void)arena;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SharedDtor();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void response::SharedDtor() {
|
|
||||||
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
|
|
||||||
_impl_.responsemsg_.Destroy();
|
|
||||||
_impl_.responseval_.Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
void response::SetCachedSize(int size) const {
|
|
||||||
_impl_._cached_size_.Set(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void response::Clear() {
|
|
||||||
// @@protoc_insertion_point(message_clear_start:sv_rcon.response)
|
|
||||||
uint32_t cached_has_bits = 0;
|
|
||||||
// Prevent compiler warnings about cached_has_bits being unused
|
|
||||||
(void) cached_has_bits;
|
|
||||||
|
|
||||||
cached_has_bits = _impl_._has_bits_[0];
|
|
||||||
if (cached_has_bits & 0x00000003u) {
|
|
||||||
if (cached_has_bits & 0x00000001u) {
|
|
||||||
_impl_.responsemsg_.ClearNonDefaultToEmpty();
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x00000002u) {
|
|
||||||
_impl_.responseval_.ClearNonDefaultToEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x0000001cu) {
|
|
||||||
::memset(&_impl_.messageid_, 0, static_cast<size_t>(
|
|
||||||
reinterpret_cast<char*>(&_impl_.responsetype_) -
|
|
||||||
reinterpret_cast<char*>(&_impl_.messageid_)) + sizeof(_impl_.responsetype_));
|
|
||||||
}
|
|
||||||
_impl_._has_bits_.Clear();
|
|
||||||
_internal_metadata_.Clear<std::string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* response::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
|
|
||||||
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
|
|
||||||
_Internal::HasBits has_bits{};
|
|
||||||
while (!ctx->Done(&ptr)) {
|
|
||||||
uint32_t tag;
|
|
||||||
ptr = ::_pbi::ReadTag(ptr, &tag);
|
|
||||||
switch (tag >> 3) {
|
|
||||||
// optional int32 messageID = 1;
|
|
||||||
case 1:
|
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
|
|
||||||
_Internal::set_has_messageid(&has_bits);
|
|
||||||
_impl_.messageid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
|
|
||||||
CHK_(ptr);
|
|
||||||
} else
|
|
||||||
goto handle_unusual;
|
|
||||||
continue;
|
|
||||||
// optional int32 messageType = 2;
|
|
||||||
case 2:
|
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
|
|
||||||
_Internal::set_has_messagetype(&has_bits);
|
|
||||||
_impl_.messagetype_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
|
|
||||||
CHK_(ptr);
|
|
||||||
} else
|
|
||||||
goto handle_unusual;
|
|
||||||
continue;
|
|
||||||
// optional .sv_rcon.response_t responseType = 3;
|
|
||||||
case 3:
|
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) {
|
|
||||||
uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
|
|
||||||
CHK_(ptr);
|
|
||||||
_internal_set_responsetype(static_cast<::sv_rcon::response_t>(val));
|
|
||||||
} else
|
|
||||||
goto handle_unusual;
|
|
||||||
continue;
|
|
||||||
// optional string responseMsg = 4;
|
|
||||||
case 4:
|
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
|
|
||||||
auto str = _internal_mutable_responsemsg();
|
|
||||||
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
|
|
||||||
CHK_(ptr);
|
|
||||||
CHK_(::_pbi::VerifyUTF8(str, nullptr));
|
|
||||||
} else
|
|
||||||
goto handle_unusual;
|
|
||||||
continue;
|
|
||||||
// optional string responseVal = 5;
|
|
||||||
case 5:
|
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
|
|
||||||
auto str = _internal_mutable_responseval();
|
|
||||||
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
|
|
||||||
CHK_(ptr);
|
|
||||||
CHK_(::_pbi::VerifyUTF8(str, nullptr));
|
|
||||||
} else
|
|
||||||
goto handle_unusual;
|
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
goto handle_unusual;
|
|
||||||
} // switch
|
|
||||||
handle_unusual:
|
|
||||||
if ((tag == 0) || ((tag & 7) == 4)) {
|
|
||||||
CHK_(ptr);
|
|
||||||
ctx->SetLastTag(tag);
|
|
||||||
goto message_done;
|
|
||||||
}
|
|
||||||
ptr = UnknownFieldParse(
|
|
||||||
tag,
|
|
||||||
_internal_metadata_.mutable_unknown_fields<std::string>(),
|
|
||||||
ptr, ctx);
|
|
||||||
CHK_(ptr != nullptr);
|
|
||||||
} // while
|
|
||||||
message_done:
|
|
||||||
_impl_._has_bits_.Or(has_bits);
|
|
||||||
return ptr;
|
|
||||||
failure:
|
|
||||||
ptr = nullptr;
|
|
||||||
goto message_done;
|
|
||||||
#undef CHK_
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* response::_InternalSerialize(
|
|
||||||
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
|
|
||||||
// @@protoc_insertion_point(serialize_to_array_start:sv_rcon.response)
|
|
||||||
uint32_t cached_has_bits = 0;
|
|
||||||
(void) cached_has_bits;
|
|
||||||
|
|
||||||
// optional int32 messageID = 1;
|
|
||||||
if (_internal_has_messageid()) {
|
|
||||||
target = stream->EnsureSpace(target);
|
|
||||||
target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_messageid(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 messageType = 2;
|
|
||||||
if (_internal_has_messagetype()) {
|
|
||||||
target = stream->EnsureSpace(target);
|
|
||||||
target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_messagetype(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional .sv_rcon.response_t responseType = 3;
|
|
||||||
if (_internal_has_responsetype()) {
|
|
||||||
target = stream->EnsureSpace(target);
|
|
||||||
target = ::_pbi::WireFormatLite::WriteEnumToArray(
|
|
||||||
3, this->_internal_responsetype(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional string responseMsg = 4;
|
|
||||||
if (_internal_has_responsemsg()) {
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->_internal_responsemsg().data(), static_cast<int>(this->_internal_responsemsg().length()),
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"sv_rcon.response.responseMsg");
|
|
||||||
target = stream->WriteStringMaybeAliased(
|
|
||||||
4, this->_internal_responsemsg(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional string responseVal = 5;
|
|
||||||
if (_internal_has_responseval()) {
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
|
|
||||||
this->_internal_responseval().data(), static_cast<int>(this->_internal_responseval().length()),
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
|
|
||||||
"sv_rcon.response.responseVal");
|
|
||||||
target = stream->WriteStringMaybeAliased(
|
|
||||||
5, this->_internal_responseval(), target);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
|
||||||
target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
|
|
||||||
static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
|
|
||||||
}
|
|
||||||
// @@protoc_insertion_point(serialize_to_array_end:sv_rcon.response)
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t response::ByteSizeLong() const {
|
|
||||||
// @@protoc_insertion_point(message_byte_size_start:sv_rcon.response)
|
|
||||||
size_t total_size = 0;
|
|
||||||
|
|
||||||
uint32_t cached_has_bits = 0;
|
|
||||||
// Prevent compiler warnings about cached_has_bits being unused
|
|
||||||
(void) cached_has_bits;
|
|
||||||
|
|
||||||
cached_has_bits = _impl_._has_bits_[0];
|
|
||||||
if (cached_has_bits & 0x0000001fu) {
|
|
||||||
// optional string responseMsg = 4;
|
|
||||||
if (cached_has_bits & 0x00000001u) {
|
|
||||||
total_size += 1 +
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
|
|
||||||
this->_internal_responsemsg());
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional string responseVal = 5;
|
|
||||||
if (cached_has_bits & 0x00000002u) {
|
|
||||||
total_size += 1 +
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
|
|
||||||
this->_internal_responseval());
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 messageID = 1;
|
|
||||||
if (cached_has_bits & 0x00000004u) {
|
|
||||||
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_messageid());
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 messageType = 2;
|
|
||||||
if (cached_has_bits & 0x00000008u) {
|
|
||||||
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_messagetype());
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional .sv_rcon.response_t responseType = 3;
|
|
||||||
if (cached_has_bits & 0x00000010u) {
|
|
||||||
total_size += 1 +
|
|
||||||
::_pbi::WireFormatLite::EnumSize(this->_internal_responsetype());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
|
||||||
total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
|
|
||||||
}
|
|
||||||
int cached_size = ::_pbi::ToCachedSize(total_size);
|
|
||||||
SetCachedSize(cached_size);
|
|
||||||
return total_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void response::CheckTypeAndMergeFrom(
|
|
||||||
const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
|
|
||||||
MergeFrom(*::_pbi::DownCast<const response*>(
|
|
||||||
&from));
|
|
||||||
}
|
|
||||||
|
|
||||||
void response::MergeFrom(const response& from) {
|
|
||||||
response* const _this = this;
|
|
||||||
// @@protoc_insertion_point(class_specific_merge_from_start:sv_rcon.response)
|
|
||||||
GOOGLE_DCHECK_NE(&from, _this);
|
|
||||||
uint32_t cached_has_bits = 0;
|
|
||||||
(void) cached_has_bits;
|
|
||||||
|
|
||||||
cached_has_bits = from._impl_._has_bits_[0];
|
|
||||||
if (cached_has_bits & 0x0000001fu) {
|
|
||||||
if (cached_has_bits & 0x00000001u) {
|
|
||||||
_this->_internal_set_responsemsg(from._internal_responsemsg());
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x00000002u) {
|
|
||||||
_this->_internal_set_responseval(from._internal_responseval());
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x00000004u) {
|
|
||||||
_this->_impl_.messageid_ = from._impl_.messageid_;
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x00000008u) {
|
|
||||||
_this->_impl_.messagetype_ = from._impl_.messagetype_;
|
|
||||||
}
|
|
||||||
if (cached_has_bits & 0x00000010u) {
|
|
||||||
_this->_impl_.responsetype_ = from._impl_.responsetype_;
|
|
||||||
}
|
|
||||||
_this->_impl_._has_bits_[0] |= cached_has_bits;
|
|
||||||
}
|
|
||||||
_this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void response::CopyFrom(const response& from) {
|
|
||||||
// @@protoc_insertion_point(class_specific_copy_from_start:sv_rcon.response)
|
|
||||||
if (&from == this) return;
|
|
||||||
Clear();
|
|
||||||
MergeFrom(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool response::IsInitialized() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void response::InternalSwap(response* other) {
|
|
||||||
using std::swap;
|
|
||||||
auto* lhs_arena = GetArenaForAllocation();
|
|
||||||
auto* rhs_arena = other->GetArenaForAllocation();
|
|
||||||
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
|
|
||||||
swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
|
|
||||||
&_impl_.responsemsg_, lhs_arena,
|
|
||||||
&other->_impl_.responsemsg_, rhs_arena
|
|
||||||
);
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
|
|
||||||
&_impl_.responseval_, lhs_arena,
|
|
||||||
&other->_impl_.responseval_, rhs_arena
|
|
||||||
);
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::memswap<
|
|
||||||
PROTOBUF_FIELD_OFFSET(response, _impl_.responsetype_)
|
|
||||||
+ sizeof(response::_impl_.responsetype_)
|
|
||||||
- PROTOBUF_FIELD_OFFSET(response, _impl_.messageid_)>(
|
|
||||||
reinterpret_cast<char*>(&_impl_.messageid_),
|
|
||||||
reinterpret_cast<char*>(&other->_impl_.messageid_));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string response::GetTypeName() const {
|
|
||||||
return "sv_rcon.response";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
|
||||||
} // namespace sv_rcon
|
|
||||||
PROTOBUF_NAMESPACE_OPEN
|
|
||||||
template<> PROTOBUF_NOINLINE ::sv_rcon::response*
|
|
||||||
Arena::CreateMaybeMessage< ::sv_rcon::response >(Arena* arena) {
|
|
||||||
return Arena::CreateMessageInternal< ::sv_rcon::response >(arena);
|
|
||||||
}
|
|
||||||
PROTOBUF_NAMESPACE_CLOSE
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope)
|
|
||||||
#include <thirdparty/protobuf/port_undef.inc>
|
|
@ -1,529 +0,0 @@
|
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
// source: sv_rcon.proto
|
|
||||||
|
|
||||||
#ifndef GOOGLE_PROTOBUF_INCLUDED_sv_5frcon_2eproto
|
|
||||||
#define GOOGLE_PROTOBUF_INCLUDED_sv_5frcon_2eproto
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <thirdparty/protobuf/port_def.inc>
|
|
||||||
#if PROTOBUF_VERSION < 3021000
|
|
||||||
#error This file was generated by a newer version of protoc which is
|
|
||||||
#error incompatible with your Protocol Buffer headers. Please update
|
|
||||||
#error your headers.
|
|
||||||
#endif
|
|
||||||
#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION
|
|
||||||
#error This file was generated by an older version of protoc which is
|
|
||||||
#error incompatible with your Protocol Buffer headers. Please
|
|
||||||
#error regenerate this file with a newer version of protoc.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <thirdparty/protobuf/port_undef.inc>
|
|
||||||
#include <thirdparty/protobuf/io/coded_stream.h>
|
|
||||||
#include <thirdparty/protobuf/arena.h>
|
|
||||||
#include <thirdparty/protobuf/arenastring.h>
|
|
||||||
#include <thirdparty/protobuf/generated_message_util.h>
|
|
||||||
#include <thirdparty/protobuf/metadata_lite.h>
|
|
||||||
#include <thirdparty/protobuf/message_lite.h>
|
|
||||||
#include <thirdparty/protobuf/repeated_field.h> // IWYU pragma: export
|
|
||||||
#include <thirdparty/protobuf/extension_set.h> // IWYU pragma: export
|
|
||||||
#include <thirdparty/protobuf/generated_enum_util.h>
|
|
||||||
// @@protoc_insertion_point(includes)
|
|
||||||
#include <thirdparty/protobuf/port_def.inc>
|
|
||||||
#define PROTOBUF_INTERNAL_EXPORT_sv_5frcon_2eproto
|
|
||||||
PROTOBUF_NAMESPACE_OPEN
|
|
||||||
namespace internal {
|
|
||||||
class AnyMetadata;
|
|
||||||
} // namespace internal
|
|
||||||
PROTOBUF_NAMESPACE_CLOSE
|
|
||||||
|
|
||||||
// Internal implementation detail -- do not use these members.
|
|
||||||
struct TableStruct_sv_5frcon_2eproto {
|
|
||||||
static const uint32_t offsets[];
|
|
||||||
};
|
|
||||||
namespace sv_rcon {
|
|
||||||
class response;
|
|
||||||
struct responseDefaultTypeInternal;
|
|
||||||
extern responseDefaultTypeInternal _response_default_instance_;
|
|
||||||
} // namespace sv_rcon
|
|
||||||
PROTOBUF_NAMESPACE_OPEN
|
|
||||||
template<> ::sv_rcon::response* Arena::CreateMaybeMessage<::sv_rcon::response>(Arena*);
|
|
||||||
PROTOBUF_NAMESPACE_CLOSE
|
|
||||||
namespace sv_rcon {
|
|
||||||
|
|
||||||
enum response_t : int {
|
|
||||||
SERVERDATA_RESPONSE_AUTH = 0,
|
|
||||||
SERVERDATA_RESPONSE_CONSOLE_LOG = 1,
|
|
||||||
response_t_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::min(),
|
|
||||||
response_t_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::max()
|
|
||||||
};
|
|
||||||
bool response_t_IsValid(int value);
|
|
||||||
constexpr response_t response_t_MIN = SERVERDATA_RESPONSE_AUTH;
|
|
||||||
constexpr response_t response_t_MAX = SERVERDATA_RESPONSE_CONSOLE_LOG;
|
|
||||||
constexpr int response_t_ARRAYSIZE = response_t_MAX + 1;
|
|
||||||
|
|
||||||
const std::string& response_t_Name(response_t value);
|
|
||||||
template<typename T>
|
|
||||||
inline const std::string& response_t_Name(T enum_t_value) {
|
|
||||||
static_assert(::std::is_same<T, response_t>::value ||
|
|
||||||
::std::is_integral<T>::value,
|
|
||||||
"Incorrect type passed to function response_t_Name.");
|
|
||||||
return response_t_Name(static_cast<response_t>(enum_t_value));
|
|
||||||
}
|
|
||||||
bool response_t_Parse(
|
|
||||||
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, response_t* value);
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
class response final :
|
|
||||||
public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:sv_rcon.response) */ {
|
|
||||||
public:
|
|
||||||
inline response() : response(nullptr) {}
|
|
||||||
~response() override;
|
|
||||||
explicit PROTOBUF_CONSTEXPR response(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
|
|
||||||
|
|
||||||
response(const response& from);
|
|
||||||
response(response&& from) noexcept
|
|
||||||
: response() {
|
|
||||||
*this = ::std::move(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline response& operator=(const response& from) {
|
|
||||||
CopyFrom(from);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
inline response& operator=(response&& from) noexcept {
|
|
||||||
if (this == &from) return *this;
|
|
||||||
if (GetOwningArena() == from.GetOwningArena()
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
|
|
||||||
&& GetOwningArena() != nullptr
|
|
||||||
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
|
|
||||||
) {
|
|
||||||
InternalSwap(&from);
|
|
||||||
} else {
|
|
||||||
CopyFrom(from);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const response& default_instance() {
|
|
||||||
return *internal_default_instance();
|
|
||||||
}
|
|
||||||
static inline const response* internal_default_instance() {
|
|
||||||
return reinterpret_cast<const response*>(
|
|
||||||
&_response_default_instance_);
|
|
||||||
}
|
|
||||||
static constexpr int kIndexInFileMessages =
|
|
||||||
0;
|
|
||||||
|
|
||||||
friend void swap(response& a, response& b) {
|
|
||||||
a.Swap(&b);
|
|
||||||
}
|
|
||||||
inline void Swap(response* other) {
|
|
||||||
if (other == this) return;
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
|
|
||||||
if (GetOwningArena() != nullptr &&
|
|
||||||
GetOwningArena() == other->GetOwningArena()) {
|
|
||||||
#else // PROTOBUF_FORCE_COPY_IN_SWAP
|
|
||||||
if (GetOwningArena() == other->GetOwningArena()) {
|
|
||||||
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
|
|
||||||
InternalSwap(other);
|
|
||||||
} else {
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void UnsafeArenaSwap(response* other) {
|
|
||||||
if (other == this) return;
|
|
||||||
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
|
|
||||||
InternalSwap(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
// implements Message ----------------------------------------------
|
|
||||||
|
|
||||||
response* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
|
|
||||||
return CreateMaybeMessage<response>(arena);
|
|
||||||
}
|
|
||||||
void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final;
|
|
||||||
void CopyFrom(const response& from);
|
|
||||||
void MergeFrom(const response& from);
|
|
||||||
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
|
|
||||||
bool IsInitialized() const final;
|
|
||||||
|
|
||||||
size_t ByteSizeLong() const final;
|
|
||||||
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
|
|
||||||
uint8_t* _InternalSerialize(
|
|
||||||
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
|
|
||||||
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
|
|
||||||
void SharedDtor();
|
|
||||||
void SetCachedSize(int size) const;
|
|
||||||
void InternalSwap(response* other);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
|
|
||||||
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
|
|
||||||
return "sv_rcon.response";
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
explicit response(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
|
||||||
bool is_message_owned = false);
|
|
||||||
public:
|
|
||||||
|
|
||||||
std::string GetTypeName() const final;
|
|
||||||
|
|
||||||
// nested types ----------------------------------------------------
|
|
||||||
|
|
||||||
// accessors -------------------------------------------------------
|
|
||||||
|
|
||||||
enum : int {
|
|
||||||
kResponseMsgFieldNumber = 4,
|
|
||||||
kResponseValFieldNumber = 5,
|
|
||||||
kMessageIDFieldNumber = 1,
|
|
||||||
kMessageTypeFieldNumber = 2,
|
|
||||||
kResponseTypeFieldNumber = 3,
|
|
||||||
};
|
|
||||||
// optional string responseMsg = 4;
|
|
||||||
bool has_responsemsg() const;
|
|
||||||
private:
|
|
||||||
bool _internal_has_responsemsg() const;
|
|
||||||
public:
|
|
||||||
void clear_responsemsg();
|
|
||||||
const std::string& responsemsg() const;
|
|
||||||
template <typename ArgT0 = const std::string&, typename... ArgT>
|
|
||||||
void set_responsemsg(ArgT0&& arg0, ArgT... args);
|
|
||||||
std::string* mutable_responsemsg();
|
|
||||||
PROTOBUF_NODISCARD std::string* release_responsemsg();
|
|
||||||
void set_allocated_responsemsg(std::string* responsemsg);
|
|
||||||
private:
|
|
||||||
const std::string& _internal_responsemsg() const;
|
|
||||||
inline PROTOBUF_ALWAYS_INLINE void _internal_set_responsemsg(const std::string& value);
|
|
||||||
std::string* _internal_mutable_responsemsg();
|
|
||||||
public:
|
|
||||||
|
|
||||||
// optional string responseVal = 5;
|
|
||||||
bool has_responseval() const;
|
|
||||||
private:
|
|
||||||
bool _internal_has_responseval() const;
|
|
||||||
public:
|
|
||||||
void clear_responseval();
|
|
||||||
const std::string& responseval() const;
|
|
||||||
template <typename ArgT0 = const std::string&, typename... ArgT>
|
|
||||||
void set_responseval(ArgT0&& arg0, ArgT... args);
|
|
||||||
std::string* mutable_responseval();
|
|
||||||
PROTOBUF_NODISCARD std::string* release_responseval();
|
|
||||||
void set_allocated_responseval(std::string* responseval);
|
|
||||||
private:
|
|
||||||
const std::string& _internal_responseval() const;
|
|
||||||
inline PROTOBUF_ALWAYS_INLINE void _internal_set_responseval(const std::string& value);
|
|
||||||
std::string* _internal_mutable_responseval();
|
|
||||||
public:
|
|
||||||
|
|
||||||
// optional int32 messageID = 1;
|
|
||||||
bool has_messageid() const;
|
|
||||||
private:
|
|
||||||
bool _internal_has_messageid() const;
|
|
||||||
public:
|
|
||||||
void clear_messageid();
|
|
||||||
int32_t messageid() const;
|
|
||||||
void set_messageid(int32_t value);
|
|
||||||
private:
|
|
||||||
int32_t _internal_messageid() const;
|
|
||||||
void _internal_set_messageid(int32_t value);
|
|
||||||
public:
|
|
||||||
|
|
||||||
// optional int32 messageType = 2;
|
|
||||||
bool has_messagetype() const;
|
|
||||||
private:
|
|
||||||
bool _internal_has_messagetype() const;
|
|
||||||
public:
|
|
||||||
void clear_messagetype();
|
|
||||||
int32_t messagetype() const;
|
|
||||||
void set_messagetype(int32_t value);
|
|
||||||
private:
|
|
||||||
int32_t _internal_messagetype() const;
|
|
||||||
void _internal_set_messagetype(int32_t value);
|
|
||||||
public:
|
|
||||||
|
|
||||||
// optional .sv_rcon.response_t responseType = 3;
|
|
||||||
bool has_responsetype() const;
|
|
||||||
private:
|
|
||||||
bool _internal_has_responsetype() const;
|
|
||||||
public:
|
|
||||||
void clear_responsetype();
|
|
||||||
::sv_rcon::response_t responsetype() const;
|
|
||||||
void set_responsetype(::sv_rcon::response_t value);
|
|
||||||
private:
|
|
||||||
::sv_rcon::response_t _internal_responsetype() const;
|
|
||||||
void _internal_set_responsetype(::sv_rcon::response_t value);
|
|
||||||
public:
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(class_scope:sv_rcon.response)
|
|
||||||
private:
|
|
||||||
class _Internal;
|
|
||||||
|
|
||||||
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
|
|
||||||
typedef void InternalArenaConstructable_;
|
|
||||||
typedef void DestructorSkippable_;
|
|
||||||
struct Impl_ {
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
|
|
||||||
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr responsemsg_;
|
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr responseval_;
|
|
||||||
int32_t messageid_;
|
|
||||||
int32_t messagetype_;
|
|
||||||
int responsetype_;
|
|
||||||
};
|
|
||||||
union { Impl_ _impl_; };
|
|
||||||
friend struct ::TableStruct_sv_5frcon_2eproto;
|
|
||||||
};
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
|
||||||
#endif // __GNUC__
|
|
||||||
// response
|
|
||||||
|
|
||||||
// optional int32 messageID = 1;
|
|
||||||
inline bool response::_internal_has_messageid() const {
|
|
||||||
bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline bool response::has_messageid() const {
|
|
||||||
return _internal_has_messageid();
|
|
||||||
}
|
|
||||||
inline void response::clear_messageid() {
|
|
||||||
_impl_.messageid_ = 0;
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000004u;
|
|
||||||
}
|
|
||||||
inline int32_t response::_internal_messageid() const {
|
|
||||||
return _impl_.messageid_;
|
|
||||||
}
|
|
||||||
inline int32_t response::messageid() const {
|
|
||||||
// @@protoc_insertion_point(field_get:sv_rcon.response.messageID)
|
|
||||||
return _internal_messageid();
|
|
||||||
}
|
|
||||||
inline void response::_internal_set_messageid(int32_t value) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000004u;
|
|
||||||
_impl_.messageid_ = value;
|
|
||||||
}
|
|
||||||
inline void response::set_messageid(int32_t value) {
|
|
||||||
_internal_set_messageid(value);
|
|
||||||
// @@protoc_insertion_point(field_set:sv_rcon.response.messageID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional int32 messageType = 2;
|
|
||||||
inline bool response::_internal_has_messagetype() const {
|
|
||||||
bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline bool response::has_messagetype() const {
|
|
||||||
return _internal_has_messagetype();
|
|
||||||
}
|
|
||||||
inline void response::clear_messagetype() {
|
|
||||||
_impl_.messagetype_ = 0;
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000008u;
|
|
||||||
}
|
|
||||||
inline int32_t response::_internal_messagetype() const {
|
|
||||||
return _impl_.messagetype_;
|
|
||||||
}
|
|
||||||
inline int32_t response::messagetype() const {
|
|
||||||
// @@protoc_insertion_point(field_get:sv_rcon.response.messageType)
|
|
||||||
return _internal_messagetype();
|
|
||||||
}
|
|
||||||
inline void response::_internal_set_messagetype(int32_t value) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000008u;
|
|
||||||
_impl_.messagetype_ = value;
|
|
||||||
}
|
|
||||||
inline void response::set_messagetype(int32_t value) {
|
|
||||||
_internal_set_messagetype(value);
|
|
||||||
// @@protoc_insertion_point(field_set:sv_rcon.response.messageType)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional .sv_rcon.response_t responseType = 3;
|
|
||||||
inline bool response::_internal_has_responsetype() const {
|
|
||||||
bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline bool response::has_responsetype() const {
|
|
||||||
return _internal_has_responsetype();
|
|
||||||
}
|
|
||||||
inline void response::clear_responsetype() {
|
|
||||||
_impl_.responsetype_ = 0;
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000010u;
|
|
||||||
}
|
|
||||||
inline ::sv_rcon::response_t response::_internal_responsetype() const {
|
|
||||||
return static_cast< ::sv_rcon::response_t >(_impl_.responsetype_);
|
|
||||||
}
|
|
||||||
inline ::sv_rcon::response_t response::responsetype() const {
|
|
||||||
// @@protoc_insertion_point(field_get:sv_rcon.response.responseType)
|
|
||||||
return _internal_responsetype();
|
|
||||||
}
|
|
||||||
inline void response::_internal_set_responsetype(::sv_rcon::response_t value) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000010u;
|
|
||||||
_impl_.responsetype_ = value;
|
|
||||||
}
|
|
||||||
inline void response::set_responsetype(::sv_rcon::response_t value) {
|
|
||||||
_internal_set_responsetype(value);
|
|
||||||
// @@protoc_insertion_point(field_set:sv_rcon.response.responseType)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional string responseMsg = 4;
|
|
||||||
inline bool response::_internal_has_responsemsg() const {
|
|
||||||
bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline bool response::has_responsemsg() const {
|
|
||||||
return _internal_has_responsemsg();
|
|
||||||
}
|
|
||||||
inline void response::clear_responsemsg() {
|
|
||||||
_impl_.responsemsg_.ClearToEmpty();
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000001u;
|
|
||||||
}
|
|
||||||
inline const std::string& response::responsemsg() const {
|
|
||||||
// @@protoc_insertion_point(field_get:sv_rcon.response.responseMsg)
|
|
||||||
return _internal_responsemsg();
|
|
||||||
}
|
|
||||||
template <typename ArgT0, typename... ArgT>
|
|
||||||
inline PROTOBUF_ALWAYS_INLINE
|
|
||||||
void response::set_responsemsg(ArgT0&& arg0, ArgT... args) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000001u;
|
|
||||||
_impl_.responsemsg_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
|
||||||
// @@protoc_insertion_point(field_set:sv_rcon.response.responseMsg)
|
|
||||||
}
|
|
||||||
inline std::string* response::mutable_responsemsg() {
|
|
||||||
std::string* _s = _internal_mutable_responsemsg();
|
|
||||||
// @@protoc_insertion_point(field_mutable:sv_rcon.response.responseMsg)
|
|
||||||
return _s;
|
|
||||||
}
|
|
||||||
inline const std::string& response::_internal_responsemsg() const {
|
|
||||||
return _impl_.responsemsg_.Get();
|
|
||||||
}
|
|
||||||
inline void response::_internal_set_responsemsg(const std::string& value) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000001u;
|
|
||||||
_impl_.responsemsg_.Set(value, GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
inline std::string* response::_internal_mutable_responsemsg() {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000001u;
|
|
||||||
return _impl_.responsemsg_.Mutable(GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
inline std::string* response::release_responsemsg() {
|
|
||||||
// @@protoc_insertion_point(field_release:sv_rcon.response.responseMsg)
|
|
||||||
if (!_internal_has_responsemsg()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000001u;
|
|
||||||
auto* p = _impl_.responsemsg_.Release();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (_impl_.responsemsg_.IsDefault()) {
|
|
||||||
_impl_.responsemsg_.Set("", GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
inline void response::set_allocated_responsemsg(std::string* responsemsg) {
|
|
||||||
if (responsemsg != nullptr) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000001u;
|
|
||||||
} else {
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000001u;
|
|
||||||
}
|
|
||||||
_impl_.responsemsg_.SetAllocated(responsemsg, GetArenaForAllocation());
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (_impl_.responsemsg_.IsDefault()) {
|
|
||||||
_impl_.responsemsg_.Set("", GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:sv_rcon.response.responseMsg)
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional string responseVal = 5;
|
|
||||||
inline bool response::_internal_has_responseval() const {
|
|
||||||
bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline bool response::has_responseval() const {
|
|
||||||
return _internal_has_responseval();
|
|
||||||
}
|
|
||||||
inline void response::clear_responseval() {
|
|
||||||
_impl_.responseval_.ClearToEmpty();
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000002u;
|
|
||||||
}
|
|
||||||
inline const std::string& response::responseval() const {
|
|
||||||
// @@protoc_insertion_point(field_get:sv_rcon.response.responseVal)
|
|
||||||
return _internal_responseval();
|
|
||||||
}
|
|
||||||
template <typename ArgT0, typename... ArgT>
|
|
||||||
inline PROTOBUF_ALWAYS_INLINE
|
|
||||||
void response::set_responseval(ArgT0&& arg0, ArgT... args) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000002u;
|
|
||||||
_impl_.responseval_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
|
||||||
// @@protoc_insertion_point(field_set:sv_rcon.response.responseVal)
|
|
||||||
}
|
|
||||||
inline std::string* response::mutable_responseval() {
|
|
||||||
std::string* _s = _internal_mutable_responseval();
|
|
||||||
// @@protoc_insertion_point(field_mutable:sv_rcon.response.responseVal)
|
|
||||||
return _s;
|
|
||||||
}
|
|
||||||
inline const std::string& response::_internal_responseval() const {
|
|
||||||
return _impl_.responseval_.Get();
|
|
||||||
}
|
|
||||||
inline void response::_internal_set_responseval(const std::string& value) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000002u;
|
|
||||||
_impl_.responseval_.Set(value, GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
inline std::string* response::_internal_mutable_responseval() {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000002u;
|
|
||||||
return _impl_.responseval_.Mutable(GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
inline std::string* response::release_responseval() {
|
|
||||||
// @@protoc_insertion_point(field_release:sv_rcon.response.responseVal)
|
|
||||||
if (!_internal_has_responseval()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000002u;
|
|
||||||
auto* p = _impl_.responseval_.Release();
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (_impl_.responseval_.IsDefault()) {
|
|
||||||
_impl_.responseval_.Set("", GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
inline void response::set_allocated_responseval(std::string* responseval) {
|
|
||||||
if (responseval != nullptr) {
|
|
||||||
_impl_._has_bits_[0] |= 0x00000002u;
|
|
||||||
} else {
|
|
||||||
_impl_._has_bits_[0] &= ~0x00000002u;
|
|
||||||
}
|
|
||||||
_impl_.responseval_.SetAllocated(responseval, GetArenaForAllocation());
|
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
if (_impl_.responseval_.IsDefault()) {
|
|
||||||
_impl_.responseval_.Set("", GetArenaForAllocation());
|
|
||||||
}
|
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
|
||||||
// @@protoc_insertion_point(field_set_allocated:sv_rcon.response.responseVal)
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif // __GNUC__
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(namespace_scope)
|
|
||||||
|
|
||||||
} // namespace sv_rcon
|
|
||||||
|
|
||||||
PROTOBUF_NAMESPACE_OPEN
|
|
||||||
|
|
||||||
template <> struct is_proto_enum< ::sv_rcon::response_t> : ::std::true_type {};
|
|
||||||
|
|
||||||
PROTOBUF_NAMESPACE_CLOSE
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope)
|
|
||||||
|
|
||||||
#include <thirdparty/protobuf/port_undef.inc>
|
|
||||||
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_sv_5frcon_2eproto
|
|
@ -8,6 +8,7 @@ int CreateDirHierarchy(const char* filePath);
|
|||||||
bool IsDirectory(const char* path);
|
bool IsDirectory(const char* path);
|
||||||
bool FileEmpty(ifstream& pFile);
|
bool FileEmpty(ifstream& pFile);
|
||||||
MODULEINFO GetModuleInfo(const char* szModule);
|
MODULEINFO GetModuleInfo(const char* szModule);
|
||||||
|
bool CryptoGenRandom(unsigned char* pData, const uint32_t nDataLen, const char*& outMsg);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Debug
|
// Debug
|
||||||
|
26
src/public/tier2/cryptutils.h
Normal file
26
src/public/tier2/cryptutils.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef TIER2_CRYPTUTILS_H
|
||||||
|
#define TIER2_CRYPTUTILS_H
|
||||||
|
|
||||||
|
typedef unsigned char CryptoIV_t[16];
|
||||||
|
typedef unsigned char CryptoKey_t[16];
|
||||||
|
|
||||||
|
struct CryptoContext_s
|
||||||
|
{
|
||||||
|
CryptoContext_s(const int setKeyBits = 128)
|
||||||
|
: keyBits(setKeyBits)
|
||||||
|
{
|
||||||
|
Assert(setKeyBits == 128 || setKeyBits == 192 || setKeyBits == 256);
|
||||||
|
memset(ivData, 0, sizeof(ivData));
|
||||||
|
}
|
||||||
|
|
||||||
|
CryptoIV_t ivData;
|
||||||
|
int keyBits;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool Crypto_GenerateIV(CryptoContext_s& ctx, const unsigned char* const data, const size_t size);
|
||||||
|
bool Crypto_CTREncrypt(CryptoContext_s& ctx, const unsigned char* const inBuf, unsigned char* const outBuf,
|
||||||
|
const unsigned char* const key, const size_t size);
|
||||||
|
bool Crypto_CTRDecrypt(CryptoContext_s& ctx, const unsigned char* const inBuf, unsigned char* const outBuf,
|
||||||
|
const unsigned char* const key, const size_t size);
|
||||||
|
|
||||||
|
#endif // TIER2_CRYPTUTILS_H
|
@ -1,19 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package cl_rcon;
|
|
||||||
option optimize_for = LITE_RUNTIME;
|
|
||||||
|
|
||||||
enum request_t
|
|
||||||
{
|
|
||||||
SERVERDATA_REQUEST_EXECCOMMAND = 0;
|
|
||||||
SERVERDATA_REQUEST_AUTH = 1;
|
|
||||||
SERVERDATA_REQUEST_SEND_CONSOLE_LOG = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message request
|
|
||||||
{
|
|
||||||
optional int32 messageID = 1;
|
|
||||||
optional int32 messageType = 2;
|
|
||||||
optional request_t requestType = 3;
|
|
||||||
optional string requestMsg = 4;
|
|
||||||
optional string requestVal = 5;
|
|
||||||
}
|
|
@ -1,4 +1,3 @@
|
|||||||
protoc64 --cpp_out=. sig_map.proto
|
protoc64 --cpp_out=. sig_map.proto
|
||||||
protoc64 --cpp_out=. sv_rcon.proto
|
protoc64 --cpp_out=. netcon.proto
|
||||||
protoc64 --cpp_out=. cl_rcon.proto
|
|
||||||
protoc64 --cpp_out=. events.proto
|
protoc64 --cpp_out=. events.proto
|
||||||
|
56
src/resource/protobuf/netcon.proto
Normal file
56
src/resource/protobuf/netcon.proto
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// R5Sdk netconsole protocol
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
syntax = "proto3";
|
||||||
|
package netcon;
|
||||||
|
option optimize_for = LITE_RUNTIME;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Request from netconsole
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
enum request_e
|
||||||
|
{
|
||||||
|
SERVERDATA_REQUEST_EXECCOMMAND = 0;
|
||||||
|
SERVERDATA_REQUEST_AUTH = 1;
|
||||||
|
SERVERDATA_REQUEST_SEND_CONSOLE_LOG = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message request
|
||||||
|
{
|
||||||
|
optional int32 messageId = 1;
|
||||||
|
optional int32 messageType = 2;
|
||||||
|
optional request_e requestType = 3;
|
||||||
|
optional string requestMsg = 4;
|
||||||
|
optional string requestVal = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Response to netconsole
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
enum response_e
|
||||||
|
{
|
||||||
|
SERVERDATA_RESPONSE_AUTH = 0;
|
||||||
|
SERVERDATA_RESPONSE_CONSOLE_LOG = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message response
|
||||||
|
{
|
||||||
|
optional int32 messageId = 1;
|
||||||
|
optional int32 messageType = 2;
|
||||||
|
optional response_e responseType = 3;
|
||||||
|
optional string responseMsg = 4;
|
||||||
|
optional string responseVal = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Message envelope
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
message envelope
|
||||||
|
{
|
||||||
|
bool encrypted = 1;
|
||||||
|
bytes nonce = 2;
|
||||||
|
bytes data = 3;
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package sv_rcon;
|
|
||||||
option optimize_for = LITE_RUNTIME;
|
|
||||||
|
|
||||||
enum response_t
|
|
||||||
{
|
|
||||||
SERVERDATA_RESPONSE_AUTH = 0;
|
|
||||||
SERVERDATA_RESPONSE_CONSOLE_LOG = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message response
|
|
||||||
{
|
|
||||||
optional int32 messageID = 1;
|
|
||||||
optional int32 messageType = 2;
|
|
||||||
optional response_t responseType = 3;
|
|
||||||
optional string responseMsg = 4;
|
|
||||||
optional string responseVal = 5;
|
|
||||||
}
|
|
@ -121,6 +121,26 @@ MODULEINFO GetModuleInfo(const char* szModule)
|
|||||||
return modinfo;
|
return modinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// For generating random data.
|
||||||
|
static BCRYPT_ALG_HANDLE s_bcryptAlgorithmProvider;
|
||||||
|
bool CryptoGenRandom(unsigned char* pData, const uint32_t nDataLen, const char*& outMsg)
|
||||||
|
{
|
||||||
|
if (!s_bcryptAlgorithmProvider && (BCryptOpenAlgorithmProvider(&s_bcryptAlgorithmProvider, L"RNG", 0, 0) < 0))
|
||||||
|
{
|
||||||
|
outMsg = "Failed to open rng algorithm";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BCryptGenRandom(s_bcryptAlgorithmProvider, pData, nDataLen, 0) < 0)
|
||||||
|
{
|
||||||
|
outMsg = "Failed to generate random data";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// For printing output to the debugger.
|
// For printing output to the debugger.
|
||||||
void DbgPrint(LPCSTR sFormat, ...)
|
void DbgPrint(LPCSTR sFormat, ...)
|
||||||
|
@ -4,6 +4,7 @@ add_module( "lib" "tier2" "vpc" ${FOLDER_CONTEXT} TRUE TRUE )
|
|||||||
start_sources()
|
start_sources()
|
||||||
|
|
||||||
add_sources( SOURCE_GROUP "Utility"
|
add_sources( SOURCE_GROUP "Utility"
|
||||||
|
"cryptutils.cpp"
|
||||||
"curlutils.cpp"
|
"curlutils.cpp"
|
||||||
"fileutils.cpp"
|
"fileutils.cpp"
|
||||||
"meshutils.cpp"
|
"meshutils.cpp"
|
||||||
@ -22,11 +23,12 @@ add_sources( SOURCE_GROUP "Public"
|
|||||||
end_sources()
|
end_sources()
|
||||||
|
|
||||||
target_include_directories( ${PROJECT_NAME} PRIVATE
|
target_include_directories( ${PROJECT_NAME} PRIVATE
|
||||||
"${ENGINE_SOURCE_DIR}/tier0/"
|
"${ENGINE_SOURCE_DIR}/tier0/"
|
||||||
"${ENGINE_SOURCE_DIR}/tier1/"
|
"${ENGINE_SOURCE_DIR}/tier1/"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories( ${PROJECT_NAME} PRIVATE
|
target_include_directories( ${PROJECT_NAME} PRIVATE
|
||||||
|
"${THIRDPARTY_SOURCE_DIR}/mbedtls/include"
|
||||||
"${THIRDPARTY_SOURCE_DIR}/dirtysdk/include/"
|
"${THIRDPARTY_SOURCE_DIR}/dirtysdk/include/"
|
||||||
"${THIRDPARTY_SOURCE_DIR}/ea/"
|
"${THIRDPARTY_SOURCE_DIR}/ea/"
|
||||||
)
|
)
|
||||||
|
70
src/tier2/cryptutils.cpp
Normal file
70
src/tier2/cryptutils.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
//===========================================================================//
|
||||||
|
//
|
||||||
|
// Purpose: A set of utilities to perform encryption/decryption
|
||||||
|
//
|
||||||
|
//===========================================================================//
|
||||||
|
#include "mbedtls/aes.h"
|
||||||
|
#include "mbedtls/entropy.h"
|
||||||
|
#include "mbedtls/ctr_drbg.h"
|
||||||
|
#include "mbedtls/error.h"
|
||||||
|
#include "mbedtls/gcm.h"
|
||||||
|
|
||||||
|
#include "tier2/cryptutils.h"
|
||||||
|
|
||||||
|
bool Crypto_GenerateIV(CryptoContext_s& ctx, const unsigned char* const data, const size_t size)
|
||||||
|
{
|
||||||
|
mbedtls_entropy_context entropy;
|
||||||
|
mbedtls_entropy_init(&entropy);
|
||||||
|
|
||||||
|
mbedtls_ctr_drbg_context drbg;
|
||||||
|
mbedtls_ctr_drbg_init(&drbg);
|
||||||
|
|
||||||
|
const int seedRet = mbedtls_ctr_drbg_seed(&drbg, mbedtls_entropy_func, &entropy, data, size);
|
||||||
|
int randRet = MBEDTLS_ERR_ERROR_GENERIC_ERROR;
|
||||||
|
|
||||||
|
if (seedRet == 0)
|
||||||
|
{
|
||||||
|
randRet = mbedtls_ctr_drbg_random(&drbg, ctx.ivData, sizeof(ctx.ivData));
|
||||||
|
}
|
||||||
|
|
||||||
|
mbedtls_ctr_drbg_free(&drbg);
|
||||||
|
mbedtls_entropy_free(&entropy);
|
||||||
|
|
||||||
|
return randRet == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool Crypto_CTRCrypt(CryptoContext_s& ctx, const unsigned char* const inBuf,
|
||||||
|
unsigned char* const outBuf, const unsigned char* const key, const size_t size)
|
||||||
|
{
|
||||||
|
mbedtls_aes_context aes;
|
||||||
|
mbedtls_aes_init(&aes);
|
||||||
|
|
||||||
|
int cryptRet = MBEDTLS_ERR_ERROR_GENERIC_ERROR;
|
||||||
|
const int setRet = mbedtls_aes_setkey_enc(&aes, key, ctx.keyBits);
|
||||||
|
|
||||||
|
if (setRet == 0)
|
||||||
|
{
|
||||||
|
unsigned char nonceCounter[16];
|
||||||
|
unsigned char streamBlock[16];
|
||||||
|
|
||||||
|
size_t offset = 0;
|
||||||
|
memcpy(nonceCounter, ctx.ivData, sizeof(nonceCounter));
|
||||||
|
|
||||||
|
cryptRet = mbedtls_aes_crypt_ctr(&aes, size, &offset, nonceCounter, streamBlock, inBuf, outBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
mbedtls_aes_free(&aes);
|
||||||
|
return cryptRet == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Crypto_CTREncrypt(CryptoContext_s& ctx, const unsigned char* const inBuf, unsigned char* const outBuf,
|
||||||
|
const unsigned char* const key, const size_t size)
|
||||||
|
{
|
||||||
|
return Crypto_CTRCrypt(ctx, inBuf, outBuf, key, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Crypto_CTRDecrypt(CryptoContext_s& ctx, const unsigned char* const inBuf, unsigned char* const outBuf,
|
||||||
|
const unsigned char* const key, const size_t size)
|
||||||
|
{
|
||||||
|
return Crypto_CTRCrypt(ctx, inBuf, outBuf, key, size);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user