mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 08:56:15 +00:00
Fixed crashes starting RCON
This commit is contained in:
@ -47,23 +47,23 @@ class RCON{
|
||||
$this->password = (string) $password;
|
||||
$this->server->getLogger()->info("Starting remote control listener");
|
||||
if($this->password === ""){
|
||||
$this->server->getLogger()->critical("RCON can't be started: Empty password");
|
||||
|
||||
return;
|
||||
throw new \InvalidArgumentException("Empty password");
|
||||
}
|
||||
|
||||
$this->threads = (int) max(1, $threads);
|
||||
$this->clientsPerThread = (int) max(1, $clientsPerThread);
|
||||
$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
if($this->socket === false or !socket_bind($this->socket, $interface, (int) $port) or !socket_listen($this->socket)){
|
||||
$this->server->getLogger()->critical("RCON can't be started: " . socket_strerror(socket_last_error()));
|
||||
$this->threads = 0;
|
||||
return;
|
||||
|
||||
if($this->socket === false or !@socket_bind($this->socket, $interface, (int) $port) or !@socket_listen($this->socket)){
|
||||
throw new \RuntimeException(trim(socket_strerror(socket_last_error())));
|
||||
}
|
||||
|
||||
socket_set_block($this->socket);
|
||||
|
||||
for($n = 0; $n < $this->threads; ++$n){
|
||||
$this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
|
||||
}
|
||||
|
||||
socket_getsockname($this->socket, $addr, $port);
|
||||
$this->server->getLogger()->info("RCON running on $addr:$port");
|
||||
}
|
||||
|
Reference in New Issue
Block a user