mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fix timeout protection with tokens
timeout protection code now transfers the token properly
This commit is contained in:
parent
1d061986d3
commit
0dc332c931
|
@ -205,7 +205,8 @@ public:
|
|||
|
||||
int AckSequence() const { return m_Ack; }
|
||||
int SeqSequence() const { return m_Sequence; }
|
||||
void SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack);
|
||||
int SecurityToken() const { return m_SecurityToken; }
|
||||
void SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SECURITY_TOKEN SecurityToken);
|
||||
};
|
||||
|
||||
class CConsoleNetConnection
|
||||
|
|
|
@ -200,17 +200,17 @@ void CNetConnection::Disconnect(const char *pReason)
|
|||
|
||||
int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_TOKEN SecurityToken)
|
||||
{
|
||||
if (m_SecurityToken != NET_SECURITY_TOKEN_UNKNOWN && m_SecurityToken != NET_SECURITY_TOKEN_UNSUPPORTED)
|
||||
if (State() != NET_CONNSTATE_OFFLINE && m_SecurityToken != NET_SECURITY_TOKEN_UNKNOWN && m_SecurityToken != NET_SECURITY_TOKEN_UNSUPPORTED)
|
||||
{
|
||||
// supposed to have a valid token in this packet, check it
|
||||
if (pPacket->m_DataSize < sizeof(m_SecurityToken))
|
||||
return -1;
|
||||
return 0;
|
||||
pPacket->m_DataSize -= sizeof(m_SecurityToken);
|
||||
if (m_SecurityToken != *(SECURITY_TOKEN*)&pPacket->m_aChunkData[pPacket->m_DataSize])
|
||||
{
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("security", "token mismatch, expected %d got %d", m_SecurityToken, *(SECURITY_TOKEN*)&pPacket->m_aChunkData[pPacket->m_DataSize]);
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ int CNetConnection::Update()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CNetConnection::SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack)
|
||||
void CNetConnection::SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SECURITY_TOKEN SecurityToken)
|
||||
{
|
||||
int64 Now = time_get();
|
||||
|
||||
|
@ -432,5 +432,6 @@ void CNetConnection::SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack)
|
|||
m_LastSendTime = Now;
|
||||
m_LastRecvTime = Now;
|
||||
m_LastUpdateTime = Now;
|
||||
m_SecurityToken = SecurityToken;
|
||||
m_Buffer.Init();
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ bool CNetServer::SetTimedOut(int ClientID, int OrigID)
|
|||
if (m_aSlots[ClientID].m_Connection.State() != NET_CONNSTATE_ERROR)
|
||||
return false;
|
||||
|
||||
m_aSlots[ClientID].m_Connection.SetTimedOut(ClientAddr(OrigID), m_aSlots[OrigID].m_Connection.SeqSequence(), m_aSlots[OrigID].m_Connection.AckSequence());
|
||||
m_aSlots[ClientID].m_Connection.SetTimedOut(ClientAddr(OrigID), m_aSlots[OrigID].m_Connection.SeqSequence(), m_aSlots[OrigID].m_Connection.AckSequence(), m_aSlots[OrigID].m_Connection.SecurityToken());
|
||||
m_aSlots[OrigID].m_Connection.Reset();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue