From 125266d6a3fad806c3cf54e3ad1fd7af727d4c0c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 13 May 2022 21:55:41 +0200 Subject: Optimize RCON Don't run CheckForBan each iteration if no failed attempts are made --- NorthstarDedicatedTest/sv_rcon.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'NorthstarDedicatedTest/sv_rcon.cpp') diff --git a/NorthstarDedicatedTest/sv_rcon.cpp b/NorthstarDedicatedTest/sv_rcon.cpp index ec2abfca..1dcfff32 100644 --- a/NorthstarDedicatedTest/sv_rcon.cpp +++ b/NorthstarDedicatedTest/sv_rcon.cpp @@ -263,6 +263,7 @@ void CRConServer::Authenticate(const cl_rcon::request& cl_request, CConnectedNet ::send(pData->m_hSocket, svWrongPass.c_str(), static_cast(svWrongPass.size()), MSG_NOSIGNAL); pData->m_bAuthorized = false; + pData->m_bValidated = false; pData->m_nFailedAttempts++; } } @@ -340,6 +341,7 @@ void CRConServer::ProcessMessage(const cl_rcon::request& cl_request) std::string svMessage = this->Serialize(s_pszNoAuthMessage, "", sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH); ::send(pData->m_hSocket, svMessage.c_str(), static_cast(svMessage.size()), MSG_NOSIGNAL); + pData->m_bValidated = false; pData->m_nIgnoredMessage++; return; } @@ -399,6 +401,12 @@ void CRConServer::Execute(const cl_rcon::request& cl_request) const //----------------------------------------------------------------------------- bool CRConServer::CheckForBan(CConnectedNetConsoleData* pData) { + if (pData->m_bValidated) + { + return false; + } + + pData->m_bValidated = true; CNetAdr2 netAdr2 = m_pSocket->GetAcceptedSocketAddress(m_nConnIndex); // Check if IP is in the ban vector. -- cgit v1.2.3