Slight cleanup

This commit is contained in:
Amos 2022-02-15 02:31:41 +01:00
parent 22cfc084af
commit 12c537284f
3 changed files with 39 additions and 30 deletions

View File

@ -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();

View File

@ -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 |

View File

@ -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;
}
}