Fix RCON packet structure

This commit is contained in:
kotyaralih 2022-01-09 19:40:50 +05:00 • committed by GitHub
parent 6b9fdc0ffe
commit 4a0bb736c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -104,7 +104,11 @@ class RCONInstance extends Thread{
}
private function writePacket($client, $requestID, $packetType, $payload){
return socket_write($client, Utils::writeLInt(strlen($payload)).Utils::writeLInt((int) $requestID).Utils::writeLInt((int) $packetType).($payload === "" ? "\x00":$payload)."\x00");
$pk = Utils::writeLInt((int) $requestID)
. Utils::writeLInt((int) $packetType)
. $payload
. "\x00\x00"; //Terminate payload and packet
return socket_write($client, Utils::writeLInt(strlen($pk)).$pk);
}
private function readPacket($client, &$size, &$requestID, &$packetType, &$payload){
@ -223,4 +227,4 @@ class RCONInstance extends Thread{
unset($this->socket, $this->cmd, $this->response, $this->stop);
exit(0);
}
}
}