diff --git a/src/common/callback.cpp b/src/common/callback.cpp index 8ea1e366..e47ddbe0 100644 --- a/src/common/callback.cpp +++ b/src/common/callback.cpp @@ -10,6 +10,7 @@ #include "tier0/fasttimer.h" #include "tier1/cvar.h" #include "tier1/fmtstr.h" +#include "engine/shared/shared_rcon.h" #ifndef CLIENT_DLL #include "engine/server/sv_rcon.h" #endif // !CLIENT_DLL @@ -248,7 +249,7 @@ void NET_UseSocketsForLoopbackChanged_f(IConVar* pConVar, const char* pOldString { Msg(eDLL_T::SERVER, "Rebooting RCON server...\n"); RCONServer()->Shutdown(); - RCONServer()->Init(); + RCONServer()->Init(rcon_password.GetString(), RCONServer()->GetKey()); } #endif // !CLIENT_DLL } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d8f575bf..088125d1 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -59,8 +59,7 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE "SigCache_Pb" "LiveAPI_Pb" - "SV_RCon_Pb" - "CL_RCon_Pb" + "NetCon_Pb" "rson" "rtech_game" @@ -81,6 +80,10 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE "EAThread" "DirtySDK" + "libmbedcrypto" + "libmbedtls" + "libmbedx509" + "networksystem" "pluginsystem" "filesystem" @@ -115,9 +118,6 @@ endif() if( NOT ${PROJECT_NAME} STREQUAL "client" ) target_link_libraries( ${PROJECT_NAME} PRIVATE - "libmbedcrypto" - "libmbedtls" - "libmbedx509" "libjwt" ) endif() diff --git a/src/core/logger.cpp b/src/core/logger.cpp index ebc1ba08..867f774b 100644 --- a/src/core/logger.cpp +++ b/src/core/logger.cpp @@ -284,9 +284,9 @@ void EngineLoggerSink(LogType_t logType, LogLevel_t logLevel, eDLL_T context, if (bToConsole) { #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)); } #endif // !CLIENT_DLL diff --git a/src/engine/client/cl_rcon.cpp b/src/engine/client/cl_rcon.cpp index 5ff53e41..9daf067b 100644 --- a/src/engine/client/cl_rcon.cpp +++ b/src/engine/client/cl_rcon.cpp @@ -7,8 +7,7 @@ #include "core/stdafx.h" #include "tier1/cmd.h" #include "tier1/cvar.h" -#include "protoc/sv_rcon.pb.h" -#include "protoc/cl_rcon.pb.h" +#include "protoc/netcon.pb.h" #include "engine/client/cl_rcon.h" #include "engine/shared/shared_rcon.h" #include "engine/net.h" @@ -19,16 +18,18 @@ //----------------------------------------------------------------------------- // 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 //----------------------------------------------------------------------------- -static void RCON_Disconnect_f(); 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 \"\""); -static ConCommand rcon_disconnect("rcon_disconnect", RCON_Disconnect_f, "Disconnect from RCON server", FCVAR_CLIENTDLL | FCVAR_RELEASE); //----------------------------------------------------------------------------- // Purpose: @@ -51,8 +52,9 @@ CRConClient::~CRConClient(void) //----------------------------------------------------------------------------- // Purpose: NETCON systems init //----------------------------------------------------------------------------- -void CRConClient::Init(void) +void CRConClient::Init(const char* pNetKey) { + SetKey(pNetKey); m_bInitialized = true; } @@ -105,18 +107,17 @@ void CRConClient::Disconnect(const char* szReason) //----------------------------------------------------------------------------- bool CRConClient::ProcessMessage(const char* pMsgBuf, const int nMsgLen) { - sv_rcon::response response; - bool bSuccess = Decode(&response, pMsgBuf, nMsgLen); + netcon::response response; - 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; } switch (response.responsetype()) { - case sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH: + case netcon::response_e::SERVERDATA_RESPONSE_AUTH: { 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()); break; } - case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG: + case netcon::response_e::SERVERDATA_RESPONSE_CONSOLE_LOG: { NetMsg(static_cast(response.messagetype()), static_cast(response.messageid()), @@ -165,7 +166,7 @@ void CRConClient::RequestConsoleLog(const bool bWantLog) const SocketHandle_t hSocket = GetSocket(); vector 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()))) { @@ -181,9 +182,10 @@ void CRConClient::RequestConsoleLog(const bool bWantLog) // Output : serialized results as string //----------------------------------------------------------------------------- bool CRConClient::Serialize(vector& 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); } -//----------------------------------------------------------------------------- -// 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 //----------------------------------------------------------------------------- @@ -254,6 +245,49 @@ CRConClient* RCONClient() // Singleton RCON Client. 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 @@ -268,7 +302,7 @@ static void RCON_CmdQuery_f(const CCommand& args) if (argCount < 2) { - const char* pszAddress = rcon_address.GetString(); + const char* pszAddress = cl_rcon_address.GetString(); if (RCONClient()->IsInitialized() && !RCONClient()->IsConnected() @@ -290,16 +324,23 @@ static void RCON_CmdQuery_f(const CCommand& args) bool bSuccess = false; 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) { - 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"); - return; + const char* storedPassword = rcon_password.GetString(); + + 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) @@ -311,11 +352,11 @@ static void RCON_CmdQuery_f(const CCommand& args) } else if (strcmp(args.Arg(1), "disconnect") == 0) // Disconnect from RCON server. { - RCONClient()->Disconnect("issued by user"); + RCONClient()->Disconnect("ordered by user"); 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) { 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"); - } -} diff --git a/src/engine/client/cl_rcon.h b/src/engine/client/cl_rcon.h index 72f8a769..0dd4ed4a 100644 --- a/src/engine/client/cl_rcon.h +++ b/src/engine/client/cl_rcon.h @@ -1,8 +1,7 @@ #pragma once #include "tier1/NetAdr.h" #include "tier2/socketcreator.h" -#include "protoc/sv_rcon.pb.h" -#include "protoc/cl_rcon.pb.h" +#include "protoc/netcon.pb.h" #include "engine/shared/base_rcon.h" class CRConClient : public CNetConBase @@ -11,7 +10,7 @@ public: CRConClient(void); ~CRConClient(void); - void Init(void); + void Init(const char* pNetKey = nullptr); void Shutdown(void); void RunFrame(void); @@ -19,7 +18,7 @@ public: virtual bool ProcessMessage(const char* pMsgBuf, const int nMsgLen) override; bool Serialize(vector& 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); bool ShouldReceive(void); diff --git a/src/engine/host_state.cpp b/src/engine/host_state.cpp index 09213da5..6704a7ff 100644 --- a/src/engine/host_state.cpp +++ b/src/engine/host_state.cpp @@ -299,13 +299,6 @@ void CHostState::Setup(void) #endif // !CLIENT_DLL ConVar_PurgeHostNames(); -#ifndef CLIENT_DLL - RCONServer()->Init(); -#endif // !CLIENT_DLL -#ifndef DEDICATED - RCONClient()->Init(); -#endif // !DEDICATED - #ifndef CLIENT_DLL LiveAPISystem()->Init(); #endif // !CLIENT_DLL diff --git a/src/engine/net.h b/src/engine/net.h index 70e60aab..55eec1b9 100644 --- a/src/engine/net.h +++ b/src/engine/net.h @@ -1,5 +1,9 @@ #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 #include "engine/net_chan.h" #include "tier1/lzss.h" @@ -14,10 +18,6 @@ #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 -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 ======================================================================================================================================================== */ inline void*(*v_NET_Init)(bool bDeveloper); inline void(*v_NET_SetKey)(netkey_t* pKey, const char* szHash); diff --git a/src/engine/server/sv_rcon.cpp b/src/engine/server/sv_rcon.cpp index b1acbf3d..0fc7b21a 100644 --- a/src/engine/server/sv_rcon.cpp +++ b/src/engine/server/sv_rcon.cpp @@ -11,10 +11,13 @@ #include "engine/cmd.h" #include "engine/net.h" #include "engine/server/sv_rcon.h" -#include "protoc/sv_rcon.pb.h" -#include "protoc/cl_rcon.pb.h" +#include "protoc/netcon.pb.h" #include "common/igameserverdata.h" #include "mbedtls/include/mbedtls/sha512.h" +#include +#include +#include +#include //----------------------------------------------------------------------------- // 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_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_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); @@ -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_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'"); //----------------------------------------------------------------------------- @@ -54,6 +52,7 @@ CRConServer::CRConServer(void) , m_nAuthConnections(0) , m_bInitialized(false) { + memset(m_PasswordHash, 0, sizeof(m_PasswordHash)); } //----------------------------------------------------------------------------- @@ -62,18 +61,20 @@ CRConServer::CRConServer(void) CRConServer::~CRConServer(void) { // 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 } //----------------------------------------------------------------------------- // Purpose: NETCON systems init //----------------------------------------------------------------------------- -void CRConServer::Init(void) +void CRConServer::Init(const char* pPassword, const char* pNetKey) { if (!m_bInitialized) { - if (!SetPassword(rcon_password.GetString())) + SetKey(pNetKey); + + if (!SetPassword(pPassword)) { return; } @@ -89,7 +90,9 @@ void CRConServer::Init(void) m_Address.SetFromString(Format("[%s]:%i", pszAddress, hostport->GetInt()).c_str(), true); 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; } @@ -232,14 +235,14 @@ void CRConServer::RunFrame(void) if (CheckForBan(data)) { - SendEncode(data.m_hSocket, s_BannedMessage, "", - sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH, int(eDLL_T::NETCON)); + SendEncoded(data.m_hSocket, s_BannedMessage, "", + netcon::response_e::SERVERDATA_RESPONSE_AUTH, int(eDLL_T::NETCON)); Disconnect("banned"); 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 - // Output: true on success, false otherwise //----------------------------------------------------------------------------- -bool CRConServer::SendEncode(const char* pResponseMsg, const char* pResponseVal, - const sv_rcon::response_t responseType, const int nMessageId, const int nMessageType) const +bool CRConServer::SendEncoded(const char* pResponseMsg, const char* pResponseVal, + const netcon::response_e responseType, const int nMessageId, const int nMessageType) const { vector vecMsg; if (!Serialize(vecMsg, pResponseMsg, pResponseVal, @@ -320,8 +323,8 @@ bool CRConServer::SendEncode(const char* pResponseMsg, const char* pResponseVal, // nMessageType - // Output: true on success, false otherwise //----------------------------------------------------------------------------- -bool CRConServer::SendEncode(const SocketHandle_t hSocket, const char* pResponseMsg, const char* pResponseVal, - const sv_rcon::response_t responseType, const int nMessageId, const int nMessageType) const +bool CRConServer::SendEncoded(const SocketHandle_t hSocket, const char* pResponseMsg, const char* pResponseVal, + const netcon::response_e responseType, const int nMessageId, const int nMessageType) const { vector vecMsg; if (!Serialize(vecMsg, pResponseMsg, pResponseVal, @@ -349,26 +352,10 @@ bool CRConServer::SendEncode(const SocketHandle_t hSocket, const char* pResponse // Output : serialized results as string //----------------------------------------------------------------------------- bool CRConServer::Serialize(vector& 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; - - 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; + return SV_NetConSerialize(this, vecBuf, pResponseMsg, pResponseVal, responseType, nMessageId, nMessageType, + rcon_encryptframes.GetBool(), rcon_debug.GetBool()); } //----------------------------------------------------------------------------- @@ -376,7 +363,7 @@ bool CRConServer::Serialize(vector& vecBuf, const char* pResponseMsg, cons // Input : &request - // &data - //----------------------------------------------------------------------------- -void CRConServer::Authenticate(const cl_rcon::request& request, CConnectedNetConsoleData& data) +void CRConServer::Authenticate(const netcon::request& request, CConnectedNetConsoleData& data) { 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"; - SendEncode(data.m_hSocket, s_AuthMessage, pSendLogs, - sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH, static_cast(eDLL_T::NETCON)); + SendEncoded(data.m_hSocket, s_AuthMessage, pSendLogs, + netcon::response_e::SERVERDATA_RESPONSE_AUTH, static_cast(eDLL_T::NETCON)); } else // Bad password. { 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()); } - SendEncode(data.m_hSocket, s_WrongPwMessage, "", - sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH, static_cast(eDLL_T::NETCON)); + SendEncoded(data.m_hSocket, s_WrongPwMessage, "", + netcon::response_e::SERVERDATA_RESPONSE_AUTH, static_cast(eDLL_T::NETCON)); data.m_bAuthorized = 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) { - CConnectedNetConsoleData& data = m_Socket.GetAcceptedSocketData(m_nConnIndex); + netcon::request request; - cl_rcon::request request; - if (!Decode(&request, pMsgBuf, nMsgLen)) + if (!SH_NetConUnpackEnvelope(this, pMsgBuf, nMsgLen, &request, rcon_debug.GetBool())) { - Error(eDLL_T::SERVER, NO_ERROR, "Failed to decode RCON buffer\n"); + Disconnect("received invalid message"); return false; } + CConnectedNetConsoleData& data = m_Socket.GetAcceptedSocketData(m_nConnIndex); + 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. - SendEncode(data.m_hSocket, s_NoAuthMessage, "", - sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH, static_cast(eDLL_T::NETCON)); + SendEncoded(data.m_hSocket, s_NoAuthMessage, "", + netcon::response_e::SERVERDATA_RESPONSE_AUTH, static_cast(eDLL_T::NETCON)); data.m_bValidated = false; data.m_nIgnoredMessage++; @@ -464,12 +452,12 @@ bool CRConServer::ProcessMessage(const char* pMsgBuf, const int nMsgLen) } switch (request.requesttype()) { - case cl_rcon::request_t::SERVERDATA_REQUEST_AUTH: + case netcon::request_e::SERVERDATA_REQUEST_AUTH: { Authenticate(request, data); 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. { @@ -477,7 +465,7 @@ bool CRConServer::ProcessMessage(const char* pMsgBuf, const int nMsgLen) } break; } - case cl_rcon::request_t::SERVERDATA_REQUEST_SEND_CONSOLE_LOG: + case netcon::request_e::SERVERDATA_REQUEST_SEND_CONSOLE_LOG: { 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) // 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 char* const pCommandString = commandString.c_str(); @@ -590,7 +578,7 @@ bool CRConServer::CheckForBan(CConnectedNetConsoleData& data) // Only allow whitelisted at this point. 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); } @@ -680,7 +668,7 @@ void CRConServer::CloseNonAuthConnection(void) // Input : responseType - // 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()) { @@ -688,7 +676,7 @@ bool CRConServer::ShouldSend(const sv_rcon::response_t responseType) const 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()) { @@ -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; CRConServer* RCONServer() // Singleton RCON Server. diff --git a/src/engine/server/sv_rcon.h b/src/engine/server/sv_rcon.h index a557181c..71770910 100644 --- a/src/engine/server/sv_rcon.h +++ b/src/engine/server/sv_rcon.h @@ -1,8 +1,7 @@ #pragma once #include "tier1/NetAdr.h" #include "tier2/socketcreator.h" -#include "protoc/sv_rcon.pb.h" -#include "protoc/cl_rcon.pb.h" +#include "protoc/netcon.pb.h" #include "engine/shared/base_rcon.h" #define RCON_MIN_PASSWORD_LEN 8 @@ -15,7 +14,7 @@ public: CRConServer(void); ~CRConServer(void); - void Init(void); + void Init(const char* pPassword, const char* pNetKey = nullptr); void Shutdown(void); bool SetPassword(const char* pszPassword); @@ -24,36 +23,37 @@ public: void Think(void); void RunFrame(void); - bool SendEncode(const char* pResponseMsg, const char* pResponseVal, - const sv_rcon::response_t responseType, + bool SendEncoded(const char* pResponseMsg, const char* pResponseVal, + const netcon::response_e responseType, const int nMessageId = static_cast(eDLL_T::NETCON), const int nMessageType = static_cast(LogType_t::LOG_NET)) const; - bool SendEncode(const SocketHandle_t hSocket, const char* pResponseMsg, - const char* pResponseVal, const sv_rcon::response_t responseType, + bool SendEncoded(const SocketHandle_t hSocket, const char* pResponseMsg, + const char* pResponseVal, const netcon::response_e responseType, const int nMessageId = static_cast(eDLL_T::NETCON), const int nMessageType = static_cast(LogType_t::LOG_NET)) const; bool SendToAll(const char* pMsgBuf, const int nMsgLen) const; - bool Serialize(vector& vecBuf, const char* pResponseMsg, const char* pResponseVal, const sv_rcon::response_t responseType, + bool Serialize(vector& vecBuf, const char* pResponseMsg, const char* pResponseVal, const netcon::response_e responseType, const int nMessageId = static_cast(eDLL_T::NETCON), const int nMessageType = static_cast(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; 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); virtual void Disconnect(const char* szReason = nullptr) override; void Disconnect(const int nIndex, const char* szReason = nullptr); void CloseNonAuthConnection(void); - bool ShouldSend(const sv_rcon::response_t responseType) const; + bool ShouldSend(const netcon::response_e responseType) const; bool IsInitialized(void) const; int GetAuthenticatedCount(void) const; + void CloseAllSockets() { m_Socket.CloseAllAcceptedSockets(); } private: int m_nConnIndex; diff --git a/src/engine/shared/base_rcon.cpp b/src/engine/shared/base_rcon.cpp index f7e2fb21..bf24f5fb 100644 --- a/src/engine/shared/base_rcon.cpp +++ b/src/engine/shared/base_rcon.cpp @@ -4,9 +4,126 @@ // //===========================================================================// #include "core/stdafx.h" +#include "tier2/cryptutils.h" #include "base_rcon.h" #include "engine/net.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(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(&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(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 @@ -56,7 +173,7 @@ bool CNetConBase::ProcessBuffer(CConnectedNetConsoleData& data, 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; @@ -95,6 +212,39 @@ bool CNetConBase::ProcessBuffer(CConnectedNetConsoleData& data, 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(pInBuf), nDataLen)) + return Crypto_CTREncrypt(ctx, reinterpret_cast(pInBuf), + reinterpret_cast(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(pInBuf), + reinterpret_cast(pOutBuf), m_NetKey, nDataLen); +} + //----------------------------------------------------------------------------- // Purpose: encode message to buffer // Input : *pMsg - diff --git a/src/engine/shared/base_rcon.h b/src/engine/shared/base_rcon.h index 5ce54733..8bbf2ec4 100644 --- a/src/engine/shared/base_rcon.h +++ b/src/engine/shared/base_rcon.h @@ -2,14 +2,23 @@ #define BASE_RCON_H #include "tier1/NetAdr.h" +#include "tier2/cryptutils.h" #include "tier2/socketcreator.h" #include "protobuf/message_lite.h" +// Max size of the payload in the envelope frame +#define RCON_MAX_PAYLOAD_SIZE 1024*1024 + class CNetConBase { public: 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 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 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 Decode(google::protobuf::MessageLite* pMsg, const char* pMsgBuf, const size_t nMsgLen) const; @@ -29,6 +41,8 @@ public: protected: CSocketCreator m_Socket; netadr_t m_Address; + CryptoKey_t m_NetKey; + CUtlString m_Base64NetKey; }; #endif // BASE_RCON_H diff --git a/src/engine/shared/shared_rcon.cpp b/src/engine/shared/shared_rcon.cpp index 1ead017f..bda8b88c 100644 --- a/src/engine/shared/shared_rcon.cpp +++ b/src/engine/shared/shared_rcon.cpp @@ -6,6 +6,39 @@ #include "core/stdafx.h" #include "base_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& 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 @@ -14,24 +47,22 @@ // *szReqBuf - // *szReqVal - // *requestType - +// bEncrypt - +// bDebug - // Output : true on success, false otherwise //----------------------------------------------------------------------------- bool CL_NetConSerialize(const CNetConBase* pBase, vector& 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_requesttype(requestType); request.set_requestmsg(szReqBuf); request.set_requestval(szReqVal); - const size_t msgLen = request.ByteSizeLong(); - vecBuf.resize(msgLen); - - if (!pBase->Encode(&request, &vecBuf[0], msgLen)) + if (!SH_NetConPackEnvelope(pBase, vecBuf, request.ByteSizeLong(), &request, bEncrypt, bDebug)) { - Error(eDLL_T::CLIENT, NO_ERROR, "Failed to encode RCON buffer\n"); return false; } @@ -83,6 +114,165 @@ bool CL_NetConConnect(CNetConBase* pBase, const char* pHostAdr, const int nHostP 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& outMsgBuf, const size_t nMsgLen, + google::protobuf::MessageLite* inMsg, const bool bEncrypt, const bool bDebug) +{ + char* encodeBuf = new char[nMsgLen]; + std::unique_ptr 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 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 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 // Input : *pBase - @@ -119,3 +309,116 @@ SocketHandle_t SH_GetNetConSocketHandle(CNetConBase* pBase, const int iSocket) 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 diff --git a/src/engine/shared/shared_rcon.h b/src/engine/shared/shared_rcon.h index 394a8f9d..c8eb8852 100644 --- a/src/engine/shared/shared_rcon.h +++ b/src/engine/shared/shared_rcon.h @@ -1,13 +1,29 @@ #ifndef SHARED_RCON_H #define SHARED_RCON_H #include "base_rcon.h" -#include "protoc/sv_rcon.pb.h" -#include "protoc/cl_rcon.pb.h" +#include "protoc/netcon.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& 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& 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 SH_NetConPackEnvelope(const CNetConBase* pBase, vector& 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); SocketHandle_t SH_GetNetConSocketHandle(CNetConBase* pBase, const int iSocket); diff --git a/src/netconsole/CMakeLists.txt b/src/netconsole/CMakeLists.txt index c18e4c43..7b6727ea 100644 --- a/src/netconsole/CMakeLists.txt +++ b/src/netconsole/CMakeLists.txt @@ -48,8 +48,15 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE "tier2" "libprotobuf" "libspdlog" - "SV_RCon_Pb" - "CL_RCon_Pb" + "libmbedcrypto" + "libmbedtls" + "libmbedx509" + "NetCon_Pb" "Rpcrt4.lib" "ws2_32.lib" + "bcrypt.lib" + "crypt32.lib" +) +target_include_directories( ${PROJECT_NAME} PRIVATE + "${THIRDPARTY_SOURCE_DIR}/mbedtls/include" ) diff --git a/src/netconsole/netconsole.cpp b/src/netconsole/netconsole.cpp index fa46697c..0543388a 100644 --- a/src/netconsole/netconsole.cpp +++ b/src/netconsole/netconsole.cpp @@ -12,8 +12,7 @@ #include "tier1/NetAdr.h" #include "tier2/socketcreator.h" #include "windows/console.h" -#include "protoc/sv_rcon.pb.h" -#include "protoc/cl_rcon.pb.h" +#include "protoc/netcon.pb.h" #include "engine/net.h" #include "engine/shared/shared_rcon.h" #include "netconsole/netconsole.h" @@ -25,6 +24,7 @@ CNetCon::CNetCon(void) : m_bInitialized(false) , m_bQuitting(false) , m_bPromptConnect(true) + , m_bEncryptFrames(true) , m_flTickInterval(0.05f) { // 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. { bSend = Serialize(vecMsg, cmd.Arg(1), "", - cl_rcon::request_t::SERVERDATA_REQUEST_AUTH); + netcon::request_e::SERVERDATA_REQUEST_AUTH); } else // Execute command query. { 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. { - 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. @@ -244,25 +244,47 @@ void CNetCon::RunInput(const string& lineInput) if (cmd.ArgC() > 1) { - const char* inAddr = cmd.Arg(0); - const char* inPort = cmd.Arg(1); + const char* inAdr = cmd.Arg(0); + 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); 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); 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); return; @@ -287,7 +309,7 @@ bool CNetCon::RunFrame(void) } else if (GetPrompting()) { - Msg(eDLL_T::NONE, "Enter []: or : "); + Msg(eDLL_T::NONE, "Enter [
]: and : "); SetPrompting(false); } } @@ -360,18 +382,17 @@ void CNetCon::Disconnect(const char* szReason) //----------------------------------------------------------------------------- bool CNetCon::ProcessMessage(const char* pMsgBuf, const int nMsgLen) { - sv_rcon::response response; - bool bSuccess = Decode(&response, pMsgBuf, nMsgLen); + netcon::response response; - 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; } switch (response.responsetype()) { - case sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH: + case netcon::response_e::SERVERDATA_RESPONSE_AUTH: { 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. { vector 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()))) { @@ -391,7 +412,7 @@ bool CNetCon::ProcessMessage(const char* pMsgBuf, const int nMsgLen) Msg(eDLL_T::NETCON, "%s", response.responsemsg().c_str()); break; } - case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG: + case netcon::response_e::SERVERDATA_RESPONSE_CONSOLE_LOG: { NetMsg(static_cast(response.messagetype()), static_cast(response.messageid()), @@ -416,9 +437,9 @@ bool CNetCon::ProcessMessage(const char* pMsgBuf, const int nMsgLen) // Output : true on success, false otherwise //----------------------------------------------------------------------------- bool CNetCon::Serialize(vector& 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); } //----------------------------------------------------------------------------- diff --git a/src/netconsole/netconsole.h b/src/netconsole/netconsole.h index 0d77ab48..6a9f8b73 100644 --- a/src/netconsole/netconsole.h +++ b/src/netconsole/netconsole.h @@ -5,8 +5,7 @@ //===========================================================================// #pragma once #include "tier1/cmd.h" -#include "protoc/cl_rcon.pb.h" -#include "protoc/sv_rcon.pb.h" +#include "protoc/netcon.pb.h" #include "engine/shared/base_rcon.h" constexpr const char* NETCON_VERSION = "2.0.0.1"; @@ -37,7 +36,7 @@ public: virtual bool ProcessMessage(const char* pMsgBuf, const int nMsgLen) override; bool Serialize(vector& 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); bool IsInitialized(void) const; @@ -47,6 +46,7 @@ private: bool m_bInitialized; bool m_bQuitting; bool m_bPromptConnect; + bool m_bEncryptFrames; float m_flTickInterval; characterset_t m_CharacterSet; diff --git a/src/pluginsdk/CMakeLists.txt b/src/pluginsdk/CMakeLists.txt index 47e85e8e..fc0482d5 100644 --- a/src/pluginsdk/CMakeLists.txt +++ b/src/pluginsdk/CMakeLists.txt @@ -23,8 +23,7 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE "libspdlog" "SigCache_Pb" - "SV_RCon_Pb" - "CL_RCon_Pb" + "NetCon_Pb" "Rpcrt4.lib" ) diff --git a/src/protoc/CMakeLists.txt b/src/protoc/CMakeLists.txt index 8e78d772..c4fce5b3 100644 --- a/src/protoc/CMakeLists.txt +++ b/src/protoc/CMakeLists.txt @@ -23,25 +23,13 @@ add_sources( SOURCE_GROUP "Runtime" end_sources() 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() add_sources( SOURCE_GROUP "Runtime" - "sv_rcon.pb.cc" - "sv_rcon.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" + "netcon.pb.cc" + "netcon.pb.h" ) end_sources() diff --git a/src/protoc/cl_rcon.pb.cc b/src/protoc/cl_rcon.pb.cc deleted file mode 100644 index c577a653..00000000 --- a/src/protoc/cl_rcon.pb.cc +++ /dev/null @@ -1,489 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: cl_rcon.proto - -#include "cl_rcon.pb.h" - -#include - -#include -#include -#include -#include -// @@protoc_insertion_point(includes) -#include - -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 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(int_value); - } - return success; -} - -// =================================================================== - -class request::_Internal { - public: - using HasBits = decltype(std::declval()._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(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(reinterpret_cast(&_impl_.requesttype_) - - reinterpret_cast(&_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()) { - (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( - reinterpret_cast(&_impl_.requesttype_) - - reinterpret_cast(&_impl_.messageid_)) + sizeof(_impl_.requesttype_)); - } - _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); -} - -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(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(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(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(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(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(), - 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(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(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(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::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(::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( - &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(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(&_impl_.messageid_), - reinterpret_cast(&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 diff --git a/src/protoc/cl_rcon.pb.h b/src/protoc/cl_rcon.pb.h deleted file mode 100644 index 55fd5689..00000000 --- a/src/protoc/cl_rcon.pb.h +++ /dev/null @@ -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 -#include - -#include -#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 -#include -#include -#include -#include -#include -#include -#include // IWYU pragma: export -#include // IWYU pragma: export -#include -// @@protoc_insertion_point(includes) -#include -#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::min(), - request_t_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits::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 -inline const std::string& request_t_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function request_t_Name."); - return request_t_Name(static_cast(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( - &_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(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 - 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 - 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 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 -inline PROTOBUF_ALWAYS_INLINE -void request::set_requestmsg(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.requestmsg_.Set(static_cast(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 -inline PROTOBUF_ALWAYS_INLINE -void request::set_requestval(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.requestval_.Set(static_cast(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 -#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_cl_5frcon_2eproto diff --git a/src/protoc/netcon.pb.cc b/src/protoc/netcon.pb.cc new file mode 100644 index 00000000..cc7ea65f --- /dev/null +++ b/src/protoc/netcon.pb.cc @@ -0,0 +1,1235 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: netcon.proto + +#include "netcon.pb.h" + +#include + +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include + +PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + +namespace netcon { +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_; +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_; +PROTOBUF_CONSTEXPR envelope::envelope( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.nonce_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.data_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.encrypted_)*/false + , /*decltype(_impl_._cached_size_)*/{}} {} +struct envelopeDefaultTypeInternal { + PROTOBUF_CONSTEXPR envelopeDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~envelopeDefaultTypeInternal() {} + union { + envelope _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 envelopeDefaultTypeInternal _envelope_default_instance_; +} // namespace netcon +namespace netcon { +bool request_e_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + return true; + default: + return false; + } +} + +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed request_e_strings[3] = {}; + +static const char request_e_names[] = + "SERVERDATA_REQUEST_AUTH" + "SERVERDATA_REQUEST_EXECCOMMAND" + "SERVERDATA_REQUEST_SEND_CONSOLE_LOG"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry request_e_entries[] = { + { {request_e_names + 0, 23}, 1 }, + { {request_e_names + 23, 30}, 0 }, + { {request_e_names + 53, 35}, 2 }, +}; + +static const int request_e_entries_by_number[] = { + 1, // 0 -> SERVERDATA_REQUEST_EXECCOMMAND + 0, // 1 -> SERVERDATA_REQUEST_AUTH + 2, // 2 -> SERVERDATA_REQUEST_SEND_CONSOLE_LOG +}; + +const std::string& request_e_Name( + request_e value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + request_e_entries, + request_e_entries_by_number, + 3, request_e_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + request_e_entries, + request_e_entries_by_number, + 3, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + request_e_strings[idx].get(); +} +bool request_e_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, request_e* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + request_e_entries, 3, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} +bool response_e_IsValid(int value) { + switch (value) { + case 0: + case 1: + return true; + default: + return false; + } +} + +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed response_e_strings[2] = {}; + +static const char response_e_names[] = + "SERVERDATA_RESPONSE_AUTH" + "SERVERDATA_RESPONSE_CONSOLE_LOG"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry response_e_entries[] = { + { {response_e_names + 0, 24}, 0 }, + { {response_e_names + 24, 31}, 1 }, +}; + +static const int response_e_entries_by_number[] = { + 0, // 0 -> SERVERDATA_RESPONSE_AUTH + 1, // 1 -> SERVERDATA_RESPONSE_CONSOLE_LOG +}; + +const std::string& response_e_Name( + response_e value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + response_e_entries, + response_e_entries_by_number, + 2, response_e_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + response_e_entries, + response_e_entries_by_number, + 2, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + response_e_strings[idx].get(); +} +bool response_e_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, response_e* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + response_e_entries, 2, name, &int_value); + if (success) { + *value = static_cast(int_value); + } + return success; +} + +// =================================================================== + +class request::_Internal { + public: + using HasBits = decltype(std::declval()._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:netcon.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(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(reinterpret_cast(&_impl_.requesttype_) - + reinterpret_cast(&_impl_.messageid_)) + sizeof(_impl_.requesttype_)); + // @@protoc_insertion_point(copy_constructor:netcon.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:netcon.request) + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + (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:netcon.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( + reinterpret_cast(&_impl_.requesttype_) - + reinterpret_cast(&_impl_.messageid_)) + sizeof(_impl_.requesttype_)); + } + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +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(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(tag) == 16)) { + _Internal::set_has_messagetype(&has_bits); + _impl_.messagetype_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .netcon.request_e requestType = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + _internal_set_requesttype(static_cast<::netcon::request_e>(val)); + } else + goto handle_unusual; + continue; + // optional string requestMsg = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(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(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(), + 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:netcon.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 .netcon.request_e 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(this->_internal_requestmsg().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "netcon.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(this->_internal_requestval().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "netcon.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(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:netcon.request) + return target; +} + +size_t request::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:netcon.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 .netcon.request_e 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(::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( + &from)); +} + +void request::MergeFrom(const request& from) { + request* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:netcon.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(from._internal_metadata_); +} + +void request::CopyFrom(const request& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:netcon.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(&_impl_.messageid_), + reinterpret_cast(&other->_impl_.messageid_)); +} + +std::string request::GetTypeName() const { + return "netcon.request"; +} + + +// =================================================================== + +class response::_Internal { + public: + using HasBits = decltype(std::declval()._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:netcon.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(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(reinterpret_cast(&_impl_.responsetype_) - + reinterpret_cast(&_impl_.messageid_)) + sizeof(_impl_.responsetype_)); + // @@protoc_insertion_point(copy_constructor:netcon.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:netcon.response) + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + (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:netcon.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( + reinterpret_cast(&_impl_.responsetype_) - + reinterpret_cast(&_impl_.messageid_)) + sizeof(_impl_.responsetype_)); + } + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +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(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(tag) == 16)) { + _Internal::set_has_messagetype(&has_bits); + _impl_.messagetype_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .netcon.response_e responseType = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + _internal_set_responsetype(static_cast<::netcon::response_e>(val)); + } else + goto handle_unusual; + continue; + // optional string responseMsg = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(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(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(), + 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:netcon.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 .netcon.response_e 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(this->_internal_responsemsg().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "netcon.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(this->_internal_responseval().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "netcon.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(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:netcon.response) + return target; +} + +size_t response::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:netcon.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 .netcon.response_e 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(::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( + &from)); +} + +void response::MergeFrom(const response& from) { + response* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:netcon.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(from._internal_metadata_); +} + +void response::CopyFrom(const response& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:netcon.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(&_impl_.messageid_), + reinterpret_cast(&other->_impl_.messageid_)); +} + +std::string response::GetTypeName() const { + return "netcon.response"; +} + + +// =================================================================== + +class envelope::_Internal { + public: +}; + +envelope::envelope(::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:netcon.envelope) +} +envelope::envelope(const envelope& from) + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + envelope* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.nonce_){} + , decltype(_impl_.data_){} + , decltype(_impl_.encrypted_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom(from._internal_metadata_); + _impl_.nonce_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.nonce_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_nonce().empty()) { + _this->_impl_.nonce_.Set(from._internal_nonce(), + _this->GetArenaForAllocation()); + } + _impl_.data_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.data_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_data().empty()) { + _this->_impl_.data_.Set(from._internal_data(), + _this->GetArenaForAllocation()); + } + _this->_impl_.encrypted_ = from._impl_.encrypted_; + // @@protoc_insertion_point(copy_constructor:netcon.envelope) +} + +inline void envelope::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.nonce_){} + , decltype(_impl_.data_){} + , decltype(_impl_.encrypted_){false} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.nonce_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.nonce_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.data_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.data_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +envelope::~envelope() { + // @@protoc_insertion_point(destructor:netcon.envelope) + if (auto *arena = _internal_metadata_.DeleteReturnArena()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void envelope::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.nonce_.Destroy(); + _impl_.data_.Destroy(); +} + +void envelope::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void envelope::Clear() { +// @@protoc_insertion_point(message_clear_start:netcon.envelope) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.nonce_.ClearToEmpty(); + _impl_.data_.ClearToEmpty(); + _impl_.encrypted_ = false; + _internal_metadata_.Clear(); +} + +const char* envelope::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // bool encrypted = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _impl_.encrypted_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // bytes nonce = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { + auto str = _internal_mutable_nonce(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // bytes data = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_data(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } 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(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* envelope::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:netcon.envelope) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // bool encrypted = 1; + if (this->_internal_encrypted() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(1, this->_internal_encrypted(), target); + } + + // bytes nonce = 2; + if (!this->_internal_nonce().empty()) { + target = stream->WriteBytesMaybeAliased( + 2, this->_internal_nonce(), target); + } + + // bytes data = 3; + if (!this->_internal_data().empty()) { + target = stream->WriteBytesMaybeAliased( + 3, this->_internal_data(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast(_internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:netcon.envelope) + return target; +} + +size_t envelope::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:netcon.envelope) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // bytes nonce = 2; + if (!this->_internal_nonce().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_nonce()); + } + + // bytes data = 3; + if (!this->_internal_data().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_data()); + } + + // bool encrypted = 1; + if (this->_internal_encrypted() != 0) { + total_size += 1 + 1; + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void envelope::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast( + &from)); +} + +void envelope::MergeFrom(const envelope& from) { + envelope* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:netcon.envelope) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_nonce().empty()) { + _this->_internal_set_nonce(from._internal_nonce()); + } + if (!from._internal_data().empty()) { + _this->_internal_set_data(from._internal_data()); + } + if (from._internal_encrypted() != 0) { + _this->_internal_set_encrypted(from._internal_encrypted()); + } + _this->_internal_metadata_.MergeFrom(from._internal_metadata_); +} + +void envelope::CopyFrom(const envelope& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:netcon.envelope) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool envelope::IsInitialized() const { + return true; +} + +void envelope::InternalSwap(envelope* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.nonce_, lhs_arena, + &other->_impl_.nonce_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.data_, lhs_arena, + &other->_impl_.data_, rhs_arena + ); + swap(_impl_.encrypted_, other->_impl_.encrypted_); +} + +std::string envelope::GetTypeName() const { + return "netcon.envelope"; +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace netcon +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::netcon::request* +Arena::CreateMaybeMessage< ::netcon::request >(Arena* arena) { + return Arena::CreateMessageInternal< ::netcon::request >(arena); +} +template<> PROTOBUF_NOINLINE ::netcon::response* +Arena::CreateMaybeMessage< ::netcon::response >(Arena* arena) { + return Arena::CreateMessageInternal< ::netcon::response >(arena); +} +template<> PROTOBUF_NOINLINE ::netcon::envelope* +Arena::CreateMaybeMessage< ::netcon::envelope >(Arena* arena) { + return Arena::CreateMessageInternal< ::netcon::envelope >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/src/protoc/netcon.pb.h b/src/protoc/netcon.pb.h new file mode 100644 index 00000000..cbddcc16 --- /dev/null +++ b/src/protoc/netcon.pb.h @@ -0,0 +1,1279 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: netcon.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_netcon_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_netcon_2eproto + +#include +#include + +#include +#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 +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_netcon_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_netcon_2eproto { + static const uint32_t offsets[]; +}; +namespace netcon { +class envelope; +struct envelopeDefaultTypeInternal; +extern envelopeDefaultTypeInternal _envelope_default_instance_; +class request; +struct requestDefaultTypeInternal; +extern requestDefaultTypeInternal _request_default_instance_; +class response; +struct responseDefaultTypeInternal; +extern responseDefaultTypeInternal _response_default_instance_; +} // namespace netcon +PROTOBUF_NAMESPACE_OPEN +template<> ::netcon::envelope* Arena::CreateMaybeMessage<::netcon::envelope>(Arena*); +template<> ::netcon::request* Arena::CreateMaybeMessage<::netcon::request>(Arena*); +template<> ::netcon::response* Arena::CreateMaybeMessage<::netcon::response>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace netcon { + +enum request_e : int { + SERVERDATA_REQUEST_EXECCOMMAND = 0, + SERVERDATA_REQUEST_AUTH = 1, + SERVERDATA_REQUEST_SEND_CONSOLE_LOG = 2, + request_e_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits::min(), + request_e_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits::max() +}; +bool request_e_IsValid(int value); +constexpr request_e request_e_MIN = SERVERDATA_REQUEST_EXECCOMMAND; +constexpr request_e request_e_MAX = SERVERDATA_REQUEST_SEND_CONSOLE_LOG; +constexpr int request_e_ARRAYSIZE = request_e_MAX + 1; + +const std::string& request_e_Name(request_e value); +template +inline const std::string& request_e_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function request_e_Name."); + return request_e_Name(static_cast(enum_t_value)); +} +bool request_e_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, request_e* value); +enum response_e : int { + SERVERDATA_RESPONSE_AUTH = 0, + SERVERDATA_RESPONSE_CONSOLE_LOG = 1, + response_e_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits::min(), + response_e_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits::max() +}; +bool response_e_IsValid(int value); +constexpr response_e response_e_MIN = SERVERDATA_RESPONSE_AUTH; +constexpr response_e response_e_MAX = SERVERDATA_RESPONSE_CONSOLE_LOG; +constexpr int response_e_ARRAYSIZE = response_e_MAX + 1; + +const std::string& response_e_Name(response_e value); +template +inline const std::string& response_e_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function response_e_Name."); + return response_e_Name(static_cast(enum_t_value)); +} +bool response_e_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, response_e* value); +// =================================================================== + +class request final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:netcon.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( + &_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(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 "netcon.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 + 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 + 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 .netcon.request_e requestType = 3; + bool has_requesttype() const; + private: + bool _internal_has_requesttype() const; + public: + void clear_requesttype(); + ::netcon::request_e requesttype() const; + void set_requesttype(::netcon::request_e value); + private: + ::netcon::request_e _internal_requesttype() const; + void _internal_set_requesttype(::netcon::request_e value); + public: + + // @@protoc_insertion_point(class_scope:netcon.request) + private: + class _Internal; + + template 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_netcon_2eproto; +}; +// ------------------------------------------------------------------- + +class response final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:netcon.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( + &_response_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + 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(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 "netcon.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 + 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 + 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 .netcon.response_e responseType = 3; + bool has_responsetype() const; + private: + bool _internal_has_responsetype() const; + public: + void clear_responsetype(); + ::netcon::response_e responsetype() const; + void set_responsetype(::netcon::response_e value); + private: + ::netcon::response_e _internal_responsetype() const; + void _internal_set_responsetype(::netcon::response_e value); + public: + + // @@protoc_insertion_point(class_scope:netcon.response) + private: + class _Internal; + + template 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_netcon_2eproto; +}; +// ------------------------------------------------------------------- + +class envelope final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:netcon.envelope) */ { + public: + inline envelope() : envelope(nullptr) {} + ~envelope() override; + explicit PROTOBUF_CONSTEXPR envelope(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + envelope(const envelope& from); + envelope(envelope&& from) noexcept + : envelope() { + *this = ::std::move(from); + } + + inline envelope& operator=(const envelope& from) { + CopyFrom(from); + return *this; + } + inline envelope& operator=(envelope&& 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 envelope& default_instance() { + return *internal_default_instance(); + } + static inline const envelope* internal_default_instance() { + return reinterpret_cast( + &_envelope_default_instance_); + } + static constexpr int kIndexInFileMessages = + 2; + + friend void swap(envelope& a, envelope& b) { + a.Swap(&b); + } + inline void Swap(envelope* 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(envelope* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + envelope* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const envelope& from); + void MergeFrom(const envelope& 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(envelope* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "netcon.envelope"; + } + protected: + explicit envelope(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + std::string GetTypeName() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kNonceFieldNumber = 2, + kDataFieldNumber = 3, + kEncryptedFieldNumber = 1, + }; + // bytes nonce = 2; + void clear_nonce(); + const std::string& nonce() const; + template + void set_nonce(ArgT0&& arg0, ArgT... args); + std::string* mutable_nonce(); + PROTOBUF_NODISCARD std::string* release_nonce(); + void set_allocated_nonce(std::string* nonce); + private: + const std::string& _internal_nonce() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_nonce(const std::string& value); + std::string* _internal_mutable_nonce(); + public: + + // bytes data = 3; + void clear_data(); + const std::string& data() const; + template + void set_data(ArgT0&& arg0, ArgT... args); + std::string* mutable_data(); + PROTOBUF_NODISCARD std::string* release_data(); + void set_allocated_data(std::string* data); + private: + const std::string& _internal_data() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_data(const std::string& value); + std::string* _internal_mutable_data(); + public: + + // bool encrypted = 1; + void clear_encrypted(); + bool encrypted() const; + void set_encrypted(bool value); + private: + bool _internal_encrypted() const; + void _internal_set_encrypted(bool value); + public: + + // @@protoc_insertion_point(class_scope:netcon.envelope) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr nonce_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr data_; + bool encrypted_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_netcon_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:netcon.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:netcon.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:netcon.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:netcon.request.messageType) +} + +// optional .netcon.request_e 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 ::netcon::request_e request::_internal_requesttype() const { + return static_cast< ::netcon::request_e >(_impl_.requesttype_); +} +inline ::netcon::request_e request::requesttype() const { + // @@protoc_insertion_point(field_get:netcon.request.requestType) + return _internal_requesttype(); +} +inline void request::_internal_set_requesttype(::netcon::request_e value) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.requesttype_ = value; +} +inline void request::set_requesttype(::netcon::request_e value) { + _internal_set_requesttype(value); + // @@protoc_insertion_point(field_set:netcon.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:netcon.request.requestMsg) + return _internal_requestmsg(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void request::set_requestmsg(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.requestmsg_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:netcon.request.requestMsg) +} +inline std::string* request::mutable_requestmsg() { + std::string* _s = _internal_mutable_requestmsg(); + // @@protoc_insertion_point(field_mutable:netcon.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:netcon.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:netcon.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:netcon.request.requestVal) + return _internal_requestval(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void request::set_requestval(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.requestval_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:netcon.request.requestVal) +} +inline std::string* request::mutable_requestval() { + std::string* _s = _internal_mutable_requestval(); + // @@protoc_insertion_point(field_mutable:netcon.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:netcon.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:netcon.request.requestVal) +} + +// ------------------------------------------------------------------- + +// 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:netcon.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:netcon.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:netcon.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:netcon.response.messageType) +} + +// optional .netcon.response_e 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 ::netcon::response_e response::_internal_responsetype() const { + return static_cast< ::netcon::response_e >(_impl_.responsetype_); +} +inline ::netcon::response_e response::responsetype() const { + // @@protoc_insertion_point(field_get:netcon.response.responseType) + return _internal_responsetype(); +} +inline void response::_internal_set_responsetype(::netcon::response_e value) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.responsetype_ = value; +} +inline void response::set_responsetype(::netcon::response_e value) { + _internal_set_responsetype(value); + // @@protoc_insertion_point(field_set:netcon.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:netcon.response.responseMsg) + return _internal_responsemsg(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void response::set_responsemsg(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.responsemsg_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:netcon.response.responseMsg) +} +inline std::string* response::mutable_responsemsg() { + std::string* _s = _internal_mutable_responsemsg(); + // @@protoc_insertion_point(field_mutable:netcon.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:netcon.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:netcon.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:netcon.response.responseVal) + return _internal_responseval(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void response::set_responseval(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.responseval_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:netcon.response.responseVal) +} +inline std::string* response::mutable_responseval() { + std::string* _s = _internal_mutable_responseval(); + // @@protoc_insertion_point(field_mutable:netcon.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:netcon.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:netcon.response.responseVal) +} + +// ------------------------------------------------------------------- + +// envelope + +// bool encrypted = 1; +inline void envelope::clear_encrypted() { + _impl_.encrypted_ = false; +} +inline bool envelope::_internal_encrypted() const { + return _impl_.encrypted_; +} +inline bool envelope::encrypted() const { + // @@protoc_insertion_point(field_get:netcon.envelope.encrypted) + return _internal_encrypted(); +} +inline void envelope::_internal_set_encrypted(bool value) { + + _impl_.encrypted_ = value; +} +inline void envelope::set_encrypted(bool value) { + _internal_set_encrypted(value); + // @@protoc_insertion_point(field_set:netcon.envelope.encrypted) +} + +// bytes nonce = 2; +inline void envelope::clear_nonce() { + _impl_.nonce_.ClearToEmpty(); +} +inline const std::string& envelope::nonce() const { + // @@protoc_insertion_point(field_get:netcon.envelope.nonce) + return _internal_nonce(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void envelope::set_nonce(ArgT0&& arg0, ArgT... args) { + + _impl_.nonce_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:netcon.envelope.nonce) +} +inline std::string* envelope::mutable_nonce() { + std::string* _s = _internal_mutable_nonce(); + // @@protoc_insertion_point(field_mutable:netcon.envelope.nonce) + return _s; +} +inline const std::string& envelope::_internal_nonce() const { + return _impl_.nonce_.Get(); +} +inline void envelope::_internal_set_nonce(const std::string& value) { + + _impl_.nonce_.Set(value, GetArenaForAllocation()); +} +inline std::string* envelope::_internal_mutable_nonce() { + + return _impl_.nonce_.Mutable(GetArenaForAllocation()); +} +inline std::string* envelope::release_nonce() { + // @@protoc_insertion_point(field_release:netcon.envelope.nonce) + return _impl_.nonce_.Release(); +} +inline void envelope::set_allocated_nonce(std::string* nonce) { + if (nonce != nullptr) { + + } else { + + } + _impl_.nonce_.SetAllocated(nonce, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.nonce_.IsDefault()) { + _impl_.nonce_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:netcon.envelope.nonce) +} + +// bytes data = 3; +inline void envelope::clear_data() { + _impl_.data_.ClearToEmpty(); +} +inline const std::string& envelope::data() const { + // @@protoc_insertion_point(field_get:netcon.envelope.data) + return _internal_data(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void envelope::set_data(ArgT0&& arg0, ArgT... args) { + + _impl_.data_.SetBytes(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:netcon.envelope.data) +} +inline std::string* envelope::mutable_data() { + std::string* _s = _internal_mutable_data(); + // @@protoc_insertion_point(field_mutable:netcon.envelope.data) + return _s; +} +inline const std::string& envelope::_internal_data() const { + return _impl_.data_.Get(); +} +inline void envelope::_internal_set_data(const std::string& value) { + + _impl_.data_.Set(value, GetArenaForAllocation()); +} +inline std::string* envelope::_internal_mutable_data() { + + return _impl_.data_.Mutable(GetArenaForAllocation()); +} +inline std::string* envelope::release_data() { + // @@protoc_insertion_point(field_release:netcon.envelope.data) + return _impl_.data_.Release(); +} +inline void envelope::set_allocated_data(std::string* data) { + if (data != nullptr) { + + } else { + + } + _impl_.data_.SetAllocated(data, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.data_.IsDefault()) { + _impl_.data_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:netcon.envelope.data) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace netcon + +PROTOBUF_NAMESPACE_OPEN + +template <> struct is_proto_enum< ::netcon::request_e> : ::std::true_type {}; +template <> struct is_proto_enum< ::netcon::response_e> : ::std::true_type {}; + +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_netcon_2eproto diff --git a/src/protoc/sv_rcon.pb.cc b/src/protoc/sv_rcon.pb.cc deleted file mode 100644 index 4ef8824c..00000000 --- a/src/protoc/sv_rcon.pb.cc +++ /dev/null @@ -1,485 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: sv_rcon.proto - -#include "sv_rcon.pb.h" - -#include - -#include -#include -#include -#include -// @@protoc_insertion_point(includes) -#include - -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 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(int_value); - } - return success; -} - -// =================================================================== - -class response::_Internal { - public: - using HasBits = decltype(std::declval()._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(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(reinterpret_cast(&_impl_.responsetype_) - - reinterpret_cast(&_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()) { - (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( - reinterpret_cast(&_impl_.responsetype_) - - reinterpret_cast(&_impl_.messageid_)) + sizeof(_impl_.responsetype_)); - } - _impl_._has_bits_.Clear(); - _internal_metadata_.Clear(); -} - -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(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(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(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(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(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(), - 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(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(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(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), - static_cast(_internal_metadata_.unknown_fields(::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(::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( - &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(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(&_impl_.messageid_), - reinterpret_cast(&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 diff --git a/src/protoc/sv_rcon.pb.h b/src/protoc/sv_rcon.pb.h deleted file mode 100644 index 3d179775..00000000 --- a/src/protoc/sv_rcon.pb.h +++ /dev/null @@ -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 -#include - -#include -#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 -#include -#include -#include -#include -#include -#include -#include // IWYU pragma: export -#include // IWYU pragma: export -#include -// @@protoc_insertion_point(includes) -#include -#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::min(), - response_t_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits::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 -inline const std::string& response_t_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function response_t_Name."); - return response_t_Name(static_cast(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( - &_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(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 - 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 - 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 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 -inline PROTOBUF_ALWAYS_INLINE -void response::set_responsemsg(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000001u; - _impl_.responsemsg_.Set(static_cast(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 -inline PROTOBUF_ALWAYS_INLINE -void response::set_responseval(ArgT0&& arg0, ArgT... args) { - _impl_._has_bits_[0] |= 0x00000002u; - _impl_.responseval_.Set(static_cast(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 -#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_sv_5frcon_2eproto diff --git a/src/public/tier0/utility.h b/src/public/tier0/utility.h index f245e34e..ec7f321d 100644 --- a/src/public/tier0/utility.h +++ b/src/public/tier0/utility.h @@ -8,6 +8,7 @@ int CreateDirHierarchy(const char* filePath); bool IsDirectory(const char* path); bool FileEmpty(ifstream& pFile); MODULEINFO GetModuleInfo(const char* szModule); +bool CryptoGenRandom(unsigned char* pData, const uint32_t nDataLen, const char*& outMsg); ///////////////////////////////////////////////////////////////////////////// // Debug diff --git a/src/public/tier2/cryptutils.h b/src/public/tier2/cryptutils.h new file mode 100644 index 00000000..7bf7e822 --- /dev/null +++ b/src/public/tier2/cryptutils.h @@ -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 diff --git a/src/resource/protobuf/cl_rcon.proto b/src/resource/protobuf/cl_rcon.proto deleted file mode 100644 index c0a0907c..00000000 --- a/src/resource/protobuf/cl_rcon.proto +++ /dev/null @@ -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; -} diff --git a/src/resource/protobuf/generate.bat b/src/resource/protobuf/generate.bat index e179f451..ebc05ef4 100644 --- a/src/resource/protobuf/generate.bat +++ b/src/resource/protobuf/generate.bat @@ -1,4 +1,3 @@ protoc64 --cpp_out=. sig_map.proto -protoc64 --cpp_out=. sv_rcon.proto -protoc64 --cpp_out=. cl_rcon.proto +protoc64 --cpp_out=. netcon.proto protoc64 --cpp_out=. events.proto diff --git a/src/resource/protobuf/netcon.proto b/src/resource/protobuf/netcon.proto new file mode 100644 index 00000000..2b684f90 --- /dev/null +++ b/src/resource/protobuf/netcon.proto @@ -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; +} diff --git a/src/resource/protobuf/sv_rcon.proto b/src/resource/protobuf/sv_rcon.proto deleted file mode 100644 index 3a64cfbc..00000000 --- a/src/resource/protobuf/sv_rcon.proto +++ /dev/null @@ -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; -} diff --git a/src/tier0/utility.cpp b/src/tier0/utility.cpp index 0c55dfd1..42503c1e 100644 --- a/src/tier0/utility.cpp +++ b/src/tier0/utility.cpp @@ -121,6 +121,26 @@ MODULEINFO GetModuleInfo(const char* szModule) 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. void DbgPrint(LPCSTR sFormat, ...) diff --git a/src/tier2/CMakeLists.txt b/src/tier2/CMakeLists.txt index 3cff30a8..8d3b33ed 100644 --- a/src/tier2/CMakeLists.txt +++ b/src/tier2/CMakeLists.txt @@ -4,6 +4,7 @@ add_module( "lib" "tier2" "vpc" ${FOLDER_CONTEXT} TRUE TRUE ) start_sources() add_sources( SOURCE_GROUP "Utility" + "cryptutils.cpp" "curlutils.cpp" "fileutils.cpp" "meshutils.cpp" @@ -22,11 +23,12 @@ add_sources( SOURCE_GROUP "Public" end_sources() target_include_directories( ${PROJECT_NAME} PRIVATE - "${ENGINE_SOURCE_DIR}/tier0/" + "${ENGINE_SOURCE_DIR}/tier0/" "${ENGINE_SOURCE_DIR}/tier1/" ) target_include_directories( ${PROJECT_NAME} PRIVATE + "${THIRDPARTY_SOURCE_DIR}/mbedtls/include" "${THIRDPARTY_SOURCE_DIR}/dirtysdk/include/" "${THIRDPARTY_SOURCE_DIR}/ea/" ) diff --git a/src/tier2/cryptutils.cpp b/src/tier2/cryptutils.cpp new file mode 100644 index 00000000..bc4b1c90 --- /dev/null +++ b/src/tier2/cryptutils.cpp @@ -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); +}