Added a hack to allow dropping garbage serverbound packets sent by a buggy client

This commit is contained in:
Dylan K. Taylor 2019-06-17 14:20:29 +01:00
parent 698193622a
commit b344427a30
2 changed files with 37 additions and 0 deletions

View File

@ -48,6 +48,7 @@ use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
use pocketmine\network\mcpe\protocol\ClientboundPacket;
use pocketmine\network\mcpe\protocol\ContainerSetDataPacket;
use pocketmine\network\mcpe\protocol\DisconnectPacket;
use pocketmine\network\mcpe\protocol\GarbageServerboundPacket;
use pocketmine\network\mcpe\protocol\InventoryContentPacket;
use pocketmine\network\mcpe\protocol\InventorySlotPacket;
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
@ -313,6 +314,10 @@ class NetworkSession{
*/
public function handleDataPacket(Packet $packet) : void{
if(!($packet instanceof ServerboundPacket)){
if($packet instanceof GarbageServerboundPacket){
$this->logger->debug("Garbage serverbound " . $packet->getName() . ": " . base64_encode($packet->getBuffer()));
return;
}
throw new BadPacketException("Unexpected non-serverbound packet");
}

View File

@ -0,0 +1,32 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
/**
* This interface can be implemented by packets which are erroneously sent to the server by a buggy client to filter
* them out.
*/
interface GarbageServerboundPacket extends Packet{
}