Renamed BadPacketException -> PacketHandlingException

this better describes the intent, instead of just vaguely describing a packet as 'bad'.
This commit is contained in:
Dylan K. Taylor
2021-03-30 01:15:28 +01:00
parent 25998720ce
commit b7a6c9dc17
7 changed files with 35 additions and 31 deletions

View File

@@ -37,7 +37,6 @@ use pocketmine\form\Form;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\network\BadPacketException;
use pocketmine\network\mcpe\cache\ChunkCache;
use pocketmine\network\mcpe\compression\CompressBatchPromise;
use pocketmine\network\mcpe\compression\Compressor;
@@ -96,6 +95,7 @@ use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
use pocketmine\network\NetworkSessionManager;
use pocketmine\network\PacketHandlingException;
use pocketmine\permission\DefaultPermissions;
use pocketmine\player\GameMode;
use pocketmine\player\Player;
@@ -324,7 +324,7 @@ class NetworkSession{
}
/**
* @throws BadPacketException
* @throws PacketHandlingException
*/
public function handleEncoded(string $payload) : void{
if(!$this->connected){
@@ -337,7 +337,7 @@ class NetworkSession{
$payload = $this->cipher->decrypt($payload);
}catch(DecryptionException $e){
$this->logger->debug("Encrypted packet: " . base64_encode($payload));
throw BadPacketException::wrap($e, "Packet decryption error");
throw PacketHandlingException::wrap($e, "Packet decryption error");
}finally{
Timings::$playerNetworkReceiveDecrypt->stopTiming();
}
@@ -348,7 +348,7 @@ class NetworkSession{
$stream = new PacketBatch($this->compressor->decompress($payload));
}catch(DecompressionException $e){
$this->logger->debug("Failed to decompress packet: " . base64_encode($payload));
throw BadPacketException::wrap($e, "Compressed packet batch decode error");
throw PacketHandlingException::wrap($e, "Compressed packet batch decode error");
}finally{
Timings::$playerNetworkReceiveDecompress->stopTiming();
}
@@ -357,19 +357,19 @@ class NetworkSession{
foreach($stream->getPackets($this->packetPool, 500) as $packet){
try{
$this->handleDataPacket($packet);
}catch(BadPacketException $e){
}catch(PacketHandlingException $e){
$this->logger->debug($packet->getName() . ": " . base64_encode($packet->getSerializer()->getBuffer()));
throw BadPacketException::wrap($e, "Error processing " . $packet->getName());
throw PacketHandlingException::wrap($e, "Error processing " . $packet->getName());
}
}
}catch(PacketDecodeException $e){
$this->logger->logException($e);
throw BadPacketException::wrap($e, "Packet batch decode error");
throw PacketHandlingException::wrap($e, "Packet batch decode error");
}
}
/**
* @throws BadPacketException
* @throws PacketHandlingException
*/
public function handleDataPacket(Packet $packet) : void{
if(!($packet instanceof ServerboundPacket)){
@@ -377,7 +377,7 @@ class NetworkSession{
$this->logger->debug("Garbage serverbound " . $packet->getName() . ": " . base64_encode($packet->getSerializer()->getBuffer()));
return;
}
throw new BadPacketException("Unexpected non-serverbound packet");
throw new PacketHandlingException("Unexpected non-serverbound packet");
}
$timings = Timings::getReceiveDataPacketTimings($packet);
@@ -387,7 +387,7 @@ class NetworkSession{
try{
$packet->decode();
}catch(PacketDecodeException $e){
throw BadPacketException::wrap($e);
throw PacketHandlingException::wrap($e);
}
$stream = $packet->getSerializer();
if(!$stream->feof()){