RakLibInterface: split error ID into 4-character chunks

this makes it easier to read, since the error ID can't be copy-pasted from the disconnection screen on the client.
This commit is contained in:
Dylan K. Taylor 2023-04-17 14:05:46 +01:00
parent 9561ae5af7
commit d07acd0013
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -53,6 +53,7 @@ use function implode;
use function mt_rand;
use function random_bytes;
use function rtrim;
use function str_split;
use function substr;
use const PHP_INT_MAX;
@ -196,7 +197,7 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
try{
$session->handleEncoded($buf);
}catch(PacketHandlingException $e){
$errorId = bin2hex(random_bytes(6));
$errorId = implode("-", str_split(bin2hex(random_bytes(6)), 4));
$logger = $session->getLogger();
$logger->error("Bad packet (error ID $errorId): " . $e->getMessage());