mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 15:05:33 +00:00
RakLibInterface: Disconnect players who trigger errors during handler
this is cleaner than leaving the player hanging for 5 seconds (which they'll often timeout from anyway). Banning the IP without kicking the player can often look like "lag" and end up getting brushed off as a performance issue.
This commit is contained in:
parent
50b89c30f8
commit
0e508876d2
@ -154,17 +154,19 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
|||||||
public function handleEncapsulated(string $identifier, EncapsulatedPacket $packet, int $flags) : void{
|
public function handleEncapsulated(string $identifier, EncapsulatedPacket $packet, int $flags) : void{
|
||||||
if(isset($this->players[$identifier])){
|
if(isset($this->players[$identifier])){
|
||||||
//get this now for blocking in case the player was closed before the exception was raised
|
//get this now for blocking in case the player was closed before the exception was raised
|
||||||
$address = $this->players[$identifier]->getAddress();
|
$player = $this->players[$identifier];
|
||||||
|
$address = $player->getAddress();
|
||||||
try{
|
try{
|
||||||
if($packet->buffer !== ""){
|
if($packet->buffer !== ""){
|
||||||
$pk = PacketPool::getPacket($packet->buffer);
|
$pk = PacketPool::getPacket($packet->buffer);
|
||||||
$this->players[$identifier]->handleDataPacket($pk);
|
$player->handleDataPacket($pk);
|
||||||
}
|
}
|
||||||
}catch(\Throwable $e){
|
}catch(\Throwable $e){
|
||||||
$logger = $this->server->getLogger();
|
$logger = $this->server->getLogger();
|
||||||
$logger->debug("Packet " . (isset($pk) ? get_class($pk) : "unknown") . " 0x" . bin2hex($packet->buffer));
|
$logger->debug("Packet " . (isset($pk) ? get_class($pk) : "unknown") . " 0x" . bin2hex($packet->buffer));
|
||||||
$logger->logException($e);
|
$logger->logException($e);
|
||||||
|
|
||||||
|
$player->close($player->getLeaveMessage(), "Internal server error");
|
||||||
$this->interface->blockAddress($address, 5);
|
$this->interface->blockAddress($address, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user