RakLibInterface: log the name of the session which triggered an unhandled exception

this makes it easier to identify what sequence of events led up to the crash.
This commit is contained in:
Dylan K. Taylor 2023-03-26 18:56:24 +01:00
parent acc8ae87fb
commit 006cdaf6ea
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -192,6 +192,7 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
$session = $this->sessions[$sessionId];
$address = $session->getIp();
$buf = substr($packet, 1);
$name = $session->getDisplayName();
try{
$session->handleEncoded($buf);
}catch(PacketHandlingException $e){
@ -204,6 +205,10 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
$logger->debug(implode("\n", Utils::printableExceptionInfo($e)));
$session->disconnect("Packet processing error (Error ID: $errorId)");
$this->interface->blockAddress($address, 5);
}catch(\Throwable $e){
//record the name of the player who caused the crash, to make it easier to find the reproducing steps
$this->server->getLogger()->emergency("Crash occurred while handling a packet from session: $name");
throw $e;
}
}
}