mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
prevent that the server uses close messages from clients. Closes #950
This commit is contained in:
parent
635dc7cda1
commit
ea876df455
|
@ -140,6 +140,7 @@ private:
|
||||||
|
|
||||||
int m_Token;
|
int m_Token;
|
||||||
int m_RemoteClosed;
|
int m_RemoteClosed;
|
||||||
|
bool m_BlockCloseMsg;
|
||||||
|
|
||||||
TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> m_Buffer;
|
TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> m_Buffer;
|
||||||
|
|
||||||
|
@ -167,7 +168,7 @@ private:
|
||||||
void Resend();
|
void Resend();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Init(NETSOCKET Socket);
|
void Init(NETSOCKET Socket, bool BlockCloseMsg);
|
||||||
int Connect(NETADDR *pAddr);
|
int Connect(NETADDR *pAddr);
|
||||||
void Disconnect(const char *pReason);
|
void Disconnect(const char *pReason);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ bool CNetClient::Open(NETADDR BindAddr, int Flags)
|
||||||
|
|
||||||
// init
|
// init
|
||||||
m_Socket = Socket;
|
m_Socket = Socket;
|
||||||
m_Connection.Init(m_Socket);
|
m_Connection.Init(m_Socket, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,13 @@ void CNetConnection::SetError(const char *pString)
|
||||||
str_copy(m_ErrorString, pString, sizeof(m_ErrorString));
|
str_copy(m_ErrorString, pString, sizeof(m_ErrorString));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetConnection::Init(NETSOCKET Socket)
|
void CNetConnection::Init(NETSOCKET Socket, bool BlockCloseMsg)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
ResetStats();
|
ResetStats();
|
||||||
|
|
||||||
m_Socket = Socket;
|
m_Socket = Socket;
|
||||||
|
m_BlockCloseMsg = BlockCloseMsg;
|
||||||
mem_zero(m_ErrorString, sizeof(m_ErrorString));
|
mem_zero(m_ErrorString, sizeof(m_ErrorString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +214,8 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
|
||||||
m_State = NET_CONNSTATE_ERROR;
|
m_State = NET_CONNSTATE_ERROR;
|
||||||
m_RemoteClosed = 1;
|
m_RemoteClosed = 1;
|
||||||
|
|
||||||
|
if(!m_BlockCloseMsg)
|
||||||
|
{
|
||||||
if(pPacket->m_DataSize)
|
if(pPacket->m_DataSize)
|
||||||
{
|
{
|
||||||
// make sure to sanitize the error string form the other party
|
// make sure to sanitize the error string form the other party
|
||||||
|
@ -228,6 +231,7 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SetError("No reason given");
|
SetError("No reason given");
|
||||||
|
}
|
||||||
|
|
||||||
if(g_Config.m_Debug)
|
if(g_Config.m_Debug)
|
||||||
dbg_msg("conn", "closed reason='%s'", ErrorString());
|
dbg_msg("conn", "closed reason='%s'", ErrorString());
|
||||||
|
|
|
@ -30,7 +30,7 @@ bool CNetServer::Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int Ma
|
||||||
m_MaxClientsPerIP = MaxClientsPerIP;
|
m_MaxClientsPerIP = MaxClientsPerIP;
|
||||||
|
|
||||||
for(int i = 0; i < NET_MAX_CLIENTS; i++)
|
for(int i = 0; i < NET_MAX_CLIENTS; i++)
|
||||||
m_aSlots[i].m_Connection.Init(m_Socket);
|
m_aSlots[i].m_Connection.Init(m_Socket, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue