mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
force vital check on essential cl/srv messages and added additional sequence checking
Conflicts: src/engine/client/client.cpp src/engine/server/server.cpp
This commit is contained in:
parent
d4c00097a5
commit
cc2dcd865a
|
@ -1022,7 +1022,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
||||||
if(Sys)
|
if(Sys)
|
||||||
{
|
{
|
||||||
// system message
|
// system message
|
||||||
if(Msg == NETMSG_MAP_CHANGE)
|
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_MAP_CHANGE)
|
||||||
{
|
{
|
||||||
const char *pMap = Unpacker.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);
|
const char *pMap = Unpacker.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);
|
||||||
int MapCrc = Unpacker.GetInt();
|
int MapCrc = Unpacker.GetInt();
|
||||||
|
@ -1088,7 +1088,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_MAP_DATA)
|
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_MAP_DATA)
|
||||||
{
|
{
|
||||||
if(!m_MapdownloadFile)
|
if(!m_MapdownloadFile)
|
||||||
return;
|
return;
|
||||||
|
@ -1133,7 +1133,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
||||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client/network", "requested next chunk package");
|
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client/network", "requested next chunk package");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_CON_READY)
|
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_CON_READY)
|
||||||
{
|
{
|
||||||
GameClient()->OnConnected();
|
GameClient()->OnConnected();
|
||||||
}
|
}
|
||||||
|
@ -1142,7 +1142,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
||||||
CMsgPacker Msg(NETMSG_PING_REPLY, true);
|
CMsgPacker Msg(NETMSG_PING_REPLY, true);
|
||||||
SendMsg(&Msg, 0);
|
SendMsg(&Msg, 0);
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_RCON_CMD_ADD)
|
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_ADD)
|
||||||
{
|
{
|
||||||
const char *pName = Unpacker.GetString(CUnpacker::SANITIZE_CC);
|
const char *pName = Unpacker.GetString(CUnpacker::SANITIZE_CC);
|
||||||
const char *pHelp = Unpacker.GetString(CUnpacker::SANITIZE_CC);
|
const char *pHelp = Unpacker.GetString(CUnpacker::SANITIZE_CC);
|
||||||
|
@ -1150,25 +1150,25 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
||||||
if(Unpacker.Error() == 0)
|
if(Unpacker.Error() == 0)
|
||||||
m_pConsole->RegisterTemp(pName, pParams, CFGFLAG_SERVER, pHelp);
|
m_pConsole->RegisterTemp(pName, pParams, CFGFLAG_SERVER, pHelp);
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_RCON_CMD_REM)
|
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_REM)
|
||||||
{
|
{
|
||||||
const char *pName = Unpacker.GetString(CUnpacker::SANITIZE_CC);
|
const char *pName = Unpacker.GetString(CUnpacker::SANITIZE_CC);
|
||||||
if(Unpacker.Error() == 0)
|
if(Unpacker.Error() == 0)
|
||||||
m_pConsole->DeregisterTemp(pName);
|
m_pConsole->DeregisterTemp(pName);
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_RCON_AUTH_ON)
|
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_AUTH_ON)
|
||||||
{
|
{
|
||||||
m_RconAuthed = 1;
|
m_RconAuthed = 1;
|
||||||
m_UseTempRconCommands = 1;
|
m_UseTempRconCommands = 1;
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_RCON_AUTH_OFF)
|
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_AUTH_OFF)
|
||||||
{
|
{
|
||||||
m_RconAuthed = 0;
|
m_RconAuthed = 0;
|
||||||
if(m_UseTempRconCommands)
|
if(m_UseTempRconCommands)
|
||||||
m_pConsole->DeregisterTempAll();
|
m_pConsole->DeregisterTempAll();
|
||||||
m_UseTempRconCommands = 0;
|
m_UseTempRconCommands = 0;
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_RCON_LINE)
|
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_LINE)
|
||||||
{
|
{
|
||||||
const char *pLine = Unpacker.GetString();
|
const char *pLine = Unpacker.GetString();
|
||||||
if(Unpacker.Error() == 0)
|
if(Unpacker.Error() == 0)
|
||||||
|
@ -1394,6 +1394,8 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0)
|
||||||
{
|
{
|
||||||
// game message
|
// game message
|
||||||
GameClient()->OnMessage(Msg, &Unpacker);
|
GameClient()->OnMessage(Msg, &Unpacker);
|
||||||
|
@ -1401,6 +1403,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
||||||
if(m_RecordGameMessage && m_DemoRecorder.IsRecording())
|
if(m_RecordGameMessage && m_DemoRecorder.IsRecording())
|
||||||
m_DemoRecorder.RecordMessage(pPacket->m_pData, pPacket->m_DataSize);
|
m_DemoRecorder.RecordMessage(pPacket->m_pData, pPacket->m_DataSize);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::PumpNetwork()
|
void CClient::PumpNetwork()
|
||||||
|
|
|
@ -816,7 +816,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
// system message
|
// system message
|
||||||
if(Msg == NETMSG_INFO)
|
if(Msg == NETMSG_INFO)
|
||||||
{
|
{
|
||||||
if(m_aClients[ClientID].m_State == CClient::STATE_AUTH)
|
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && m_aClients[ClientID].m_State == CClient::STATE_AUTH)
|
||||||
{
|
{
|
||||||
const char *pVersion = Unpacker.GetString(CUnpacker::SANITIZE_CC);
|
const char *pVersion = Unpacker.GetString(CUnpacker::SANITIZE_CC);
|
||||||
if(str_comp(pVersion, GameServer()->NetVersion()) != 0)
|
if(str_comp(pVersion, GameServer()->NetVersion()) != 0)
|
||||||
|
@ -842,7 +842,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_REQUEST_MAP_DATA)
|
else if(Msg == NETMSG_REQUEST_MAP_DATA)
|
||||||
{
|
{
|
||||||
if(m_aClients[ClientID].m_State == CClient::STATE_CONNECTING)
|
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) == 0 || m_aClients[ClientID].m_State == CClient::STATE_CONNECTING)
|
||||||
{
|
{
|
||||||
int ChunkSize = MAP_CHUNK_SIZE;
|
int ChunkSize = MAP_CHUNK_SIZE;
|
||||||
|
|
||||||
|
@ -876,7 +876,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_READY)
|
else if(Msg == NETMSG_READY)
|
||||||
{
|
{
|
||||||
if(m_aClients[ClientID].m_State == CClient::STATE_CONNECTING)
|
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && m_aClients[ClientID].m_State == CClient::STATE_CONNECTING)
|
||||||
{
|
{
|
||||||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||||
net_addr_str(m_NetServer.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true);
|
net_addr_str(m_NetServer.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true);
|
||||||
|
@ -891,7 +891,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
}
|
}
|
||||||
else if(Msg == NETMSG_ENTERGAME)
|
else if(Msg == NETMSG_ENTERGAME)
|
||||||
{
|
{
|
||||||
if(m_aClients[ClientID].m_State == CClient::STATE_READY && GameServer()->IsClientReady(ClientID))
|
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && m_aClients[ClientID].m_State == CClient::STATE_READY && GameServer()->IsClientReady(ClientID))
|
||||||
{
|
{
|
||||||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||||
net_addr_str(m_NetServer.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true);
|
net_addr_str(m_NetServer.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true);
|
||||||
|
@ -959,7 +959,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
{
|
{
|
||||||
const char *pCmd = Unpacker.GetString();
|
const char *pCmd = Unpacker.GetString();
|
||||||
|
|
||||||
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed)
|
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed)
|
||||||
{
|
{
|
||||||
char aBuf[256];
|
char aBuf[256];
|
||||||
str_format(aBuf, sizeof(aBuf), "ClientID=%d rcon='%s'", ClientID, pCmd);
|
str_format(aBuf, sizeof(aBuf), "ClientID=%d rcon='%s'", ClientID, pCmd);
|
||||||
|
@ -977,7 +977,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
{
|
{
|
||||||
const char *pPw = Unpacker.GetString(CUnpacker::SANITIZE_CC);
|
const char *pPw = Unpacker.GetString(CUnpacker::SANITIZE_CC);
|
||||||
|
|
||||||
if(Unpacker.Error() == 0)
|
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Unpacker.Error() == 0)
|
||||||
{
|
{
|
||||||
if(g_Config.m_SvRconPassword[0] == 0 && g_Config.m_SvRconModPassword[0] == 0)
|
if(g_Config.m_SvRconPassword[0] == 0 && g_Config.m_SvRconModPassword[0] == 0)
|
||||||
{
|
{
|
||||||
|
@ -1057,7 +1057,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// game message
|
// game message
|
||||||
if(m_aClients[ClientID].m_State >= CClient::STATE_READY)
|
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && m_aClients[ClientID].m_State >= CClient::STATE_READY)
|
||||||
GameServer()->OnMessage(Msg, &Unpacker, ClientID);
|
GameServer()->OnMessage(Msg, &Unpacker, ClientID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ int CNetRecvUnpacker::FetchChunk(CNetChunk *pChunk)
|
||||||
// fill in the info
|
// fill in the info
|
||||||
pChunk->m_ClientID = m_ClientID;
|
pChunk->m_ClientID = m_ClientID;
|
||||||
pChunk->m_Address = m_Addr;
|
pChunk->m_Address = m_Addr;
|
||||||
pChunk->m_Flags = 0;
|
pChunk->m_Flags = Header.m_Flags;
|
||||||
pChunk->m_DataSize = Header.m_Size;
|
pChunk->m_DataSize = Header.m_Size;
|
||||||
pChunk->m_pData = pData;
|
pChunk->m_pData = pData;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -138,6 +138,7 @@ class CNetConnection
|
||||||
private:
|
private:
|
||||||
unsigned short m_Sequence;
|
unsigned short m_Sequence;
|
||||||
unsigned short m_Ack;
|
unsigned short m_Ack;
|
||||||
|
unsigned short m_PeerAck;
|
||||||
unsigned m_State;
|
unsigned m_State;
|
||||||
|
|
||||||
int m_Token;
|
int m_Token;
|
||||||
|
|
|
@ -13,6 +13,7 @@ void CNetConnection::Reset()
|
||||||
{
|
{
|
||||||
m_Sequence = 0;
|
m_Sequence = 0;
|
||||||
m_Ack = 0;
|
m_Ack = 0;
|
||||||
|
m_PeerAck = 0;
|
||||||
m_RemoteClosed = 0;
|
m_RemoteClosed = 0;
|
||||||
|
|
||||||
m_State = NET_CONNSTATE_OFFLINE;
|
m_State = NET_CONNSTATE_OFFLINE;
|
||||||
|
@ -196,6 +197,19 @@ void CNetConnection::Disconnect(const char *pReason)
|
||||||
|
|
||||||
int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
|
int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
|
||||||
{
|
{
|
||||||
|
// check if actual ack value is valid(own sequence..latest peer ack)
|
||||||
|
if(m_Sequence >= m_PeerAck)
|
||||||
|
{
|
||||||
|
if(pPacket->m_Ack < m_PeerAck || pPacket->m_Ack > m_Sequence)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(pPacket->m_Ack < m_PeerAck && pPacket->m_Ack > m_Sequence)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
m_PeerAck = pPacket->m_Ack;
|
||||||
|
|
||||||
int64 Now = time_get();
|
int64 Now = time_get();
|
||||||
|
|
||||||
// check if resend is requested
|
// check if resend is requested
|
||||||
|
|
|
@ -350,7 +350,7 @@ void CCharacter::FireWeapon()
|
||||||
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
|
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
|
||||||
Msg.AddInt(((int *)&p)[i]);
|
Msg.AddInt(((int *)&p)[i]);
|
||||||
|
|
||||||
Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());
|
Server()->SendMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
|
||||||
|
|
||||||
GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE);
|
GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE);
|
||||||
} break;
|
} break;
|
||||||
|
@ -384,7 +384,7 @@ void CCharacter::FireWeapon()
|
||||||
Msg.AddInt(((int *)&p)[i]);
|
Msg.AddInt(((int *)&p)[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Server()->SendMsg(&Msg, 0,m_pPlayer->GetCID());
|
Server()->SendMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
|
||||||
|
|
||||||
GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE);
|
GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE);
|
||||||
} break;
|
} break;
|
||||||
|
@ -406,7 +406,7 @@ void CCharacter::FireWeapon()
|
||||||
Msg.AddInt(1);
|
Msg.AddInt(1);
|
||||||
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
|
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
|
||||||
Msg.AddInt(((int *)&p)[i]);
|
Msg.AddInt(((int *)&p)[i]);
|
||||||
Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());
|
Server()->SendMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
|
||||||
|
|
||||||
GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE);
|
GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE);
|
||||||
} break;
|
} break;
|
||||||
|
|
Loading…
Reference in a new issue