mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
vanilla handshake: ignore unknown sequence
This commit is contained in:
parent
9f1ab9a7bf
commit
051ec30832
|
@ -58,10 +58,13 @@ int CNetRecvUnpacker::FetchChunk(CNetChunk *pChunk)
|
||||||
// handle sequence stuff
|
// handle sequence stuff
|
||||||
if(m_pConnection && (Header.m_Flags&NET_CHUNKFLAG_VITAL))
|
if(m_pConnection && (Header.m_Flags&NET_CHUNKFLAG_VITAL))
|
||||||
{
|
{
|
||||||
if(Header.m_Sequence == (m_pConnection->m_Ack+1)%NET_MAX_SEQUENCE)
|
// anti spoof: ignore unknown sequence
|
||||||
|
if(Header.m_Sequence == (m_pConnection->m_Ack+1)%NET_MAX_SEQUENCE || m_pConnection->m_UnknownSeq)
|
||||||
{
|
{
|
||||||
|
m_pConnection->m_UnknownSeq = false;
|
||||||
|
|
||||||
// in sequence
|
// in sequence
|
||||||
m_pConnection->m_Ack = (m_pConnection->m_Ack+1)%NET_MAX_SEQUENCE;
|
m_pConnection->m_Ack = Header.m_Sequence;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,6 +158,7 @@ private:
|
||||||
SECURITY_TOKEN m_SecurityToken;
|
SECURITY_TOKEN m_SecurityToken;
|
||||||
int m_RemoteClosed;
|
int m_RemoteClosed;
|
||||||
bool m_BlockCloseMsg;
|
bool m_BlockCloseMsg;
|
||||||
|
bool m_UnknownSeq;
|
||||||
|
|
||||||
TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> m_Buffer;
|
TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> m_Buffer;
|
||||||
|
|
||||||
|
@ -219,6 +220,7 @@ public:
|
||||||
|
|
||||||
// anti spoof
|
// anti spoof
|
||||||
void DirectInit(NETADDR &Addr, SECURITY_TOKEN SecurityToken);
|
void DirectInit(NETADDR &Addr, SECURITY_TOKEN SecurityToken);
|
||||||
|
void SetUnknownSeq() { m_UnknownSeq = true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CConsoleNetConnection
|
class CConsoleNetConnection
|
||||||
|
|
|
@ -31,6 +31,7 @@ void CNetConnection::Reset()
|
||||||
m_Token = -1;
|
m_Token = -1;
|
||||||
m_SecurityToken = NET_SECURITY_TOKEN_UNKNOWN;
|
m_SecurityToken = NET_SECURITY_TOKEN_UNKNOWN;
|
||||||
//mem_zero(&m_PeerAddr, sizeof(m_PeerAddr));
|
//mem_zero(&m_PeerAddr, sizeof(m_PeerAddr));
|
||||||
|
m_UnknownSeq = false;
|
||||||
|
|
||||||
m_Buffer.Init();
|
m_Buffer.Init();
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,11 @@ int CNetServer::TryAcceptClient(NETADDR &Addr, SECURITY_TOKEN SecurityToken, boo
|
||||||
// init connection slot
|
// init connection slot
|
||||||
m_aSlots[Slot].m_Connection.DirectInit(Addr, SecurityToken);
|
m_aSlots[Slot].m_Connection.DirectInit(Addr, SecurityToken);
|
||||||
|
|
||||||
|
if (NoAuth)
|
||||||
|
// client sequence is unknown if the auth was done
|
||||||
|
// connection-less
|
||||||
|
m_aSlots[Slot].m_Connection.SetUnknownSeq();
|
||||||
|
|
||||||
if (g_Config.m_Debug)
|
if (g_Config.m_Debug)
|
||||||
{
|
{
|
||||||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||||
|
|
Loading…
Reference in a new issue