forked from teamnwah/openmw-tes3coop
[General] Add packetValid flag to packets
This commit is contained in:
parent
695fb7d4a7
commit
d999cc0d55
3 changed files with 15 additions and 1 deletions
|
@ -217,7 +217,7 @@ void Networking::update(RakNet::Packet *packet)
|
|||
|
||||
bsIn.IgnoreBytes((unsigned int) RakNet::RakNetGUID::size()); // Ignore GUID from received packet
|
||||
|
||||
if (player == 0)
|
||||
if (player == nullptr)
|
||||
{
|
||||
if (packet->data[0] == ID_GAME_PREINIT)
|
||||
{
|
||||
|
@ -229,6 +229,13 @@ void Networking::update(RakNet::Packet *packet)
|
|||
packetPreInit.setChecksums(&plugins);
|
||||
packetPreInit.Read();
|
||||
|
||||
if (!packetPreInit.isPacketValid())
|
||||
{
|
||||
LOG_APPEND(Log::LOG_ERROR, "Invalid packetPreInit");
|
||||
peer->CloseConnection(packet->systemAddress, false); // close connection without notification
|
||||
return;
|
||||
}
|
||||
|
||||
auto plugin = plugins.begin();
|
||||
if (samples.size() == plugins.size())
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@ BasePacket::BasePacket(RakNet::RakPeerInterface *peer)
|
|||
void BasePacket::Packet(RakNet::BitStream *bs, bool send)
|
||||
{
|
||||
this->bs = bs;
|
||||
packetValid = true;
|
||||
|
||||
if (send)
|
||||
{
|
||||
|
|
|
@ -39,6 +39,11 @@ namespace mwmp
|
|||
return packetID;
|
||||
}
|
||||
|
||||
bool isPacketValid() const
|
||||
{
|
||||
return packetValid;
|
||||
}
|
||||
|
||||
protected:
|
||||
template<class templateType>
|
||||
void RW(templateType &data, uint32_t size, bool write)
|
||||
|
@ -112,6 +117,7 @@ namespace mwmp
|
|||
RakNet::BitStream *bsRead, *bsSend, *bs;
|
||||
RakNet::RakPeerInterface *peer;
|
||||
RakNet::RakNetGUID guid;
|
||||
bool packetValid;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue