mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Cleaned up LoginPacket handling, don't nuke the buffer
This commit is contained in:
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
class LoginPacket extends DataPacket{
|
||||
@ -63,17 +64,20 @@ class LoginPacket extends DataPacket{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function mayHaveUnreadBytes() : bool{
|
||||
return $this->protocol !== null and $this->protocol !== ProtocolInfo::CURRENT_PROTOCOL;
|
||||
}
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->protocol = $this->getInt();
|
||||
|
||||
if($this->protocol !== ProtocolInfo::CURRENT_PROTOCOL){
|
||||
$this->buffer = null;
|
||||
return; //Do not attempt to decode for non-accepted protocols
|
||||
return; //Do not attempt to continue decoding for non-accepted protocols
|
||||
}
|
||||
|
||||
$this->setBuffer($this->getString(), 0);
|
||||
$buffer = new BinaryStream($this->getString());
|
||||
|
||||
$this->chainData = json_decode($this->get($this->getLInt()), true);
|
||||
$this->chainData = json_decode($buffer->get($buffer->getLInt()), true);
|
||||
foreach($this->chainData["chain"] as $chain){
|
||||
$webtoken = Utils::decodeJWT($chain);
|
||||
if(isset($webtoken["extraData"])){
|
||||
@ -89,7 +93,7 @@ class LoginPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
$this->clientDataJwt = $this->get($this->getLInt());
|
||||
$this->clientDataJwt = $buffer->get($buffer->getLInt());
|
||||
$this->clientData = Utils::decodeJWT($this->clientDataJwt);
|
||||
|
||||
$this->clientId = $this->clientData["ClientRandomId"] ?? null;
|
||||
|
Reference in New Issue
Block a user