aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/socketcreator.cpp
diff options
context:
space:
mode:
authorKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-08-03 01:40:26 +0200
committerKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-08-03 01:40:26 +0200
commit566d3dc33b9c8be39efe429f8ca848f3ff7580ea (patch)
tree3a16ebc701310d2f8e950514c56f89ce8179dfa5 /NorthstarDedicatedTest/socketcreator.cpp
parent671de14bdaf2ee0178aaeba6d069afb51072e4ec (diff)
downloadNorthstarLauncher-566d3dc33b9c8be39efe429f8ca848f3ff7580ea.tar.gz
NorthstarLauncher-566d3dc33b9c8be39efe429f8ca848f3ff7580ea.zip
RCON system overhaul
* Implemented robust length-prefix framing logic for non-blocking sockets (previously used character sequences to determine length, but you cannot use character sequences on protocol buffers as its binary data. This logic should fix all problems regarding some commands not getting networked properly to the server and stuff not getting printed on the client). * Increased buffer size to std::vector::max_size when netconsole is authenticated (MAX_NETCONSOLE_INPUT_LEN still remains enforced on accepted but not authenticated connections to prevent attackers from crashing the server). * Process max 1024 bytes each recv buffer iteration. * Additional optimizations and cleanup.
Diffstat (limited to 'NorthstarDedicatedTest/socketcreator.cpp')
-rw-r--r--NorthstarDedicatedTest/socketcreator.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/NorthstarDedicatedTest/socketcreator.cpp b/NorthstarDedicatedTest/socketcreator.cpp
index 03b5b76f..d500eace 100644
--- a/NorthstarDedicatedTest/socketcreator.cpp
+++ b/NorthstarDedicatedTest/socketcreator.cpp
@@ -254,7 +254,7 @@ int CSocketCreator::OnSocketAccepted(SocketHandle_t hSocket, CNetAdr2 netAdr2)
m_hAcceptedSockets.push_back(pNewEntry);
- int nIndex = (int)m_hAcceptedSockets.size() - 1;
+ int nIndex = static_cast<int>(m_hAcceptedSockets.size()) - 1;
return nIndex;
}
@@ -271,6 +271,8 @@ void CSocketCreator::CloseAcceptedSocket(int nIndex)
AcceptedSocket_t& connected = m_hAcceptedSockets[nIndex];
::closesocket(connected.m_hSocket);
+ delete connected.m_pData;
+
m_hAcceptedSockets.erase(m_hAcceptedSockets.begin() + nIndex);
}
@@ -284,12 +286,15 @@ void CSocketCreator::CloseAllAcceptedSockets(void)
{
AcceptedSocket_t& connected = m_hAcceptedSockets[i];
::closesocket(connected.m_hSocket);
+
+ delete connected.m_pData;
}
m_hAcceptedSockets.clear();
}
//-----------------------------------------------------------------------------
// Purpose: returns true if the listening socket is created and listening
+// Output : bool
//-----------------------------------------------------------------------------
bool CSocketCreator::IsListening(void) const
{
@@ -298,6 +303,7 @@ bool CSocketCreator::IsListening(void) const
//-----------------------------------------------------------------------------
// Purpose: returns true if the socket would block because of the last socket command
+// Output : bool
//-----------------------------------------------------------------------------
bool CSocketCreator::IsSocketBlocking(void) const
{
@@ -306,6 +312,7 @@ bool CSocketCreator::IsSocketBlocking(void) const
//-----------------------------------------------------------------------------
// Purpose: returns accepted socket count
+// Output : int
//-----------------------------------------------------------------------------
int CSocketCreator::GetAcceptedSocketCount(void) const
{
@@ -314,6 +321,8 @@ int CSocketCreator::GetAcceptedSocketCount(void) const
//-----------------------------------------------------------------------------
// Purpose: returns accepted socket handle
+// Input : nIndex -
+// Output : SocketHandle_t
//-----------------------------------------------------------------------------
SocketHandle_t CSocketCreator::GetAcceptedSocketHandle(int nIndex) const
{
@@ -322,6 +331,8 @@ SocketHandle_t CSocketCreator::GetAcceptedSocketHandle(int nIndex) const
//-----------------------------------------------------------------------------
// Purpose: returns accepted socket address
+// Input : nIndex -
+// Output : const CNetAdr2&
//-----------------------------------------------------------------------------
const CNetAdr2& CSocketCreator::GetAcceptedSocketAddress(int nIndex) const
{
@@ -330,6 +341,8 @@ const CNetAdr2& CSocketCreator::GetAcceptedSocketAddress(int nIndex) const
//-----------------------------------------------------------------------------
// Purpose: returns accepted socket data
+// Input : nIndex -
+// Output : CConnectedNetConsoleData*
//-----------------------------------------------------------------------------
CConnectedNetConsoleData* CSocketCreator::GetAcceptedSocketData(int nIndex) const
{