diff --git a/src/engine/shared/network.h b/src/engine/shared/network.h index 7e2c9d43b..2a7765960 100644 --- a/src/engine/shared/network.h +++ b/src/engine/shared/network.h @@ -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 diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index fd052647b..b5a5e2e3f 100644 --- a/src/engine/shared/network_conn.cpp +++ b/src/engine/shared/network_conn.cpp @@ -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(); } diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 6c20307ab..082e9d362 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -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; }