aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-05-13 21:55:41 +0200
committerKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-05-13 21:55:41 +0200
commit125266d6a3fad806c3cf54e3ad1fd7af727d4c0c (patch)
treec3d6b09ea7bb7357e6789a0be51a3803c13524c3
parent76ed31a29822e40d157792fcbccc604587c3d790 (diff)
downloadNorthstarLauncher-125266d6a3fad806c3cf54e3ad1fd7af727d4c0c.tar.gz
NorthstarLauncher-125266d6a3fad806c3cf54e3ad1fd7af727d4c0c.zip
Optimize RCON
Don't run CheckForBan each iteration if no failed attempts are made
-rw-r--r--NorthstarDedicatedTest/igameserverdata.h1
-rw-r--r--NorthstarDedicatedTest/sv_rcon.cpp8
2 files changed, 9 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/igameserverdata.h b/NorthstarDedicatedTest/igameserverdata.h
index 678d1e90..9cc6c759 100644
--- a/NorthstarDedicatedTest/igameserverdata.h
+++ b/NorthstarDedicatedTest/igameserverdata.h
@@ -33,6 +33,7 @@ class CConnectedNetConsoleData
SocketHandle_t m_hSocket {};
int m_nCharsInCommandBuffer {};
char m_pszInputCommandBuffer[MAX_NETCONSOLE_INPUT_LEN] {};
+ bool m_bValidated {}; // Revalidates netconsole if false.
bool m_bAuthorized {}; // Set to true after netconsole successfully authed.
bool m_bInputOnly {}; // If set, don't send spew to this net console.
int m_nFailedAttempts {}; // Num failed authentication attempts.
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<int>(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<int>(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.