diff --git a/r5dev/engine/cl_rcon.cpp b/r5dev/engine/cl_rcon.cpp index fdc75d3b..1c191750 100644 --- a/r5dev/engine/cl_rcon.cpp +++ b/r5dev/engine/cl_rcon.cpp @@ -25,7 +25,6 @@ void CRConClient::Init(void) { DevMsg(eDLL_T::CLIENT, "Remote server access requires a password of at least 8 characters\n"); } - m_bInitialized = false; } m_bInitialized = true; } @@ -281,7 +280,7 @@ sv_rcon::response CRConClient::Deserialize(const std::string& svBuf) const //----------------------------------------------------------------------------- bool CRConClient::IsInitialized(void) const { - return this->m_bInitialized; + return m_bInitialized; } //----------------------------------------------------------------------------- @@ -290,7 +289,7 @@ bool CRConClient::IsInitialized(void) const //----------------------------------------------------------------------------- bool CRConClient::IsConnected(void) const { - return this->m_bConnEstablished; + return m_bConnEstablished; } CRConClient* g_pRConClient = new CRConClient(); \ No newline at end of file diff --git a/r5dev/tier0/IConVar.cpp b/r5dev/tier0/IConVar.cpp index c55b8f15..9b9f24cb 100644 --- a/r5dev/tier0/IConVar.cpp +++ b/r5dev/tier0/IConVar.cpp @@ -66,9 +66,9 @@ void ConVar::Init(void) sv_rcon_debug = new ConVar("sv_rcon_debug", "0", FCVAR_RELEASE, "Show rcon debug information ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); sv_rcon_banpenalty = new ConVar("sv_rcon_banpenalty", "10", FCVAR_RELEASE, "Number of minutes to ban users who fail rcon authentication.", false, 0.f, false, 0.f, nullptr, nullptr); sv_rcon_maxfailures = new ConVar("sv_rcon_maxfailures", "10", FCVAR_RELEASE, "Max number of times a user can fail rcon authentication before being banned.", false, 0.f, false, 0.f, nullptr, nullptr); - sv_rcon_maxignores = new ConVar("sv_rcon_maxignores", "10", FCVAR_RELEASE, "Max number of times a user can ignore the no-auth message before being banned.", false, 0.f, false, 0.f, nullptr, nullptr); + sv_rcon_maxignores = new ConVar("sv_rcon_maxignores", "15", FCVAR_RELEASE, "Max number of times a user can ignore the no-auth message before being banned.", false, 0.f, false, 0.f, nullptr, nullptr); sv_rcon_maxsockets = new ConVar("sv_rcon_maxsockets", "32", FCVAR_RELEASE, "Max number of accepted sockets before the server starts closing redundant sockets.", false, 0.f, false, 0.f, nullptr, nullptr); - sv_rcon_whitelist_address = new ConVar("sv_rcon_whitelist_address", "", FCVAR_RELEASE, "When set, rcon failed authentications will never ban this address, e.g. '127.0.0.1'.", false, 0.f, false, 0.f, nullptr, nullptr); + sv_rcon_whitelist_address = new ConVar("sv_rcon_whitelist_address", "", FCVAR_RELEASE, "This address is not considered a 'redundant' socket and will never be banned for failed authentications. Example: '::ffff:127.0.0.1'.", false, 0.f, false, 0.f, nullptr, nullptr); #endif // DEDICATED //------------------------------------------------------------------------- // CLIENT | diff --git a/r5dev/tier0/completion.cpp b/r5dev/tier0/completion.cpp index b55919c5..3bfaa29c 100644 --- a/r5dev/tier0/completion.cpp +++ b/r5dev/tier0/completion.cpp @@ -718,6 +718,7 @@ _RCON_CmdQuery_f_CompletionFunc void _RCON_CmdQuery_f_CompletionFunc(CCommand* cmd) { std::int32_t argSize = *(std::int32_t*)((std::uintptr_t)cmd + 0x4); + CCommand& args = *cmd; // Get reference. switch (argSize) { @@ -736,45 +737,54 @@ void _RCON_CmdQuery_f_CompletionFunc(CCommand* cmd) { if (!g_pRConClient->IsInitialized()) { - DevMsg(eDLL_T::CLIENT, "Failed to issue command to RCON server: uninitialized.\n"); + DevMsg(eDLL_T::CLIENT, "Failed to issue command to RCON server: uninitialized\n"); break; } - - CCommand& args = *cmd; // Get reference. - if (!g_pRConClient->IsConnected()) + else if (g_pRConClient->IsConnected()) { - DevMsg(eDLL_T::CLIENT, "Failed to issue command to RCON server: unconnected.\n"); + if (strcmp(args[1], "PASS") == 0) // Auth with RCON server using rcon_password ConVar value. + { + std::string svCmdQuery = g_pRConClient->Serialize(args[1], rcon_password->GetString(), cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND); + g_pRConClient->Send(svCmdQuery); + break; + } + else if (strcmp(args[1], "disconnect") == 0) // Disconnect from RCON server. + { + g_pRConClient->Disconnect(); + break; + } + + std::string svCmdQuery = g_pRConClient->Serialize(args[1], "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND); + g_pRConClient->Send(svCmdQuery); + break; + } + else + { + DevMsg(eDLL_T::CLIENT, "Failed to issue command to RCON server: unconnected\n"); break; } - - std::string svCmdQuery = g_pRConClient->Serialize(args[1], "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND); - g_pRConClient->Send(svCmdQuery); break; } case 3: { - if (!g_pRConClient->IsInitialized()) + if (g_pRConClient->IsConnected()) { - DevMsg(eDLL_T::CLIENT, "Failed to issue command to RCON server: uninitialized.\n"); - break; - } + if (strcmp(args[1], "PASS") == 0) // Auth with RCON server. + { + std::string svCmdQuery = g_pRConClient->Serialize(args[1], args[2], cl_rcon::request_t::SERVERDATA_REQUEST_AUTH); + g_pRConClient->Send(svCmdQuery); + break; + } - CCommand& args = *cmd; // Get reference. - if (!g_pRConClient->IsConnected()) - { - DevMsg(eDLL_T::CLIENT, "Failed to issue command to RCON server: unconnected.\n"); - break; - } - - if (strcmp(args[1], "PASS") == 0) - { - std::string svCmdQuery = g_pRConClient->Serialize(args[1], args[2], cl_rcon::request_t::SERVERDATA_REQUEST_AUTH); + std::string svCmdQuery = g_pRConClient->Serialize(args[1], args[2], cl_rcon::request_t::SERVERDATA_REQUEST_SETVALUE); g_pRConClient->Send(svCmdQuery); break; } - - std::string svCmdQuery = g_pRConClient->Serialize(args[1], args[2], cl_rcon::request_t::SERVERDATA_REQUEST_SETVALUE); - g_pRConClient->Send(svCmdQuery); + else + { + DevMsg(eDLL_T::CLIENT, "Failed to issue command to RCON server: unconnected\n"); + break; + } break; } }