mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +00:00
Better BatchPacket decoding and LoginPacket handling
This commit is contained in:
parent
81fe98d4cc
commit
7f28deefcb
@ -211,10 +211,11 @@ class Network{
|
|||||||
$str = zlib_decode($packet->payload, 1024 * 1024 * 64); //Max 64MB
|
$str = zlib_decode($packet->payload, 1024 * 1024 * 64); //Max 64MB
|
||||||
$len = strlen($str);
|
$len = strlen($str);
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
|
try{
|
||||||
while($offset < $len){
|
while($offset < $len){
|
||||||
if(($pk = $this->getPacket(ord($str{$offset++}))) !== null){
|
if(($pk = $this->getPacket(ord($str{$offset++}))) !== null){
|
||||||
if($pk->pid() === Info::BATCH_PACKET){
|
if($pk->pid() === Info::BATCH_PACKET){
|
||||||
return;
|
throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket");
|
||||||
}
|
}
|
||||||
$pk->setBuffer(substr($str, $offset));
|
$pk->setBuffer(substr($str, $offset));
|
||||||
$pk->decode();
|
$pk->decode();
|
||||||
@ -225,6 +226,15 @@ class Network{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}catch(\Exception $e){
|
||||||
|
if(\pocketmine\DEBUG > 1){
|
||||||
|
$logger = $this->server->getLogger();
|
||||||
|
if($logger instanceof MainLogger){
|
||||||
|
$logger->debug("BatchPacket " . " 0x" . bin2hex($packet->payload));
|
||||||
|
$logger->logException($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,10 +157,12 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($this->players[$identifier])){
|
||||||
$this->interface->blockAddress($this->players[$identifier]->getAddress(), 5);
|
$this->interface->blockAddress($this->players[$identifier]->getAddress(), 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function blockAddress($address, $timeout = 300){
|
public function blockAddress($address, $timeout = 300){
|
||||||
$this->interface->blockAddress($address, $timeout);
|
$this->interface->blockAddress($address, $timeout);
|
||||||
|
@ -44,7 +44,7 @@ class LoginPacket extends DataPacket{
|
|||||||
$this->username = $this->getString();
|
$this->username = $this->getString();
|
||||||
$this->protocol1 = $this->getInt();
|
$this->protocol1 = $this->getInt();
|
||||||
$this->protocol2 = $this->getInt();
|
$this->protocol2 = $this->getInt();
|
||||||
if(Info::CURRENT_PROTOCOL != $this->protocol1){
|
if($this->protocol1 < 21){ //New fields!
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->clientId = $this->getInt();
|
$this->clientId = $this->getInt();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user