You've already forked Atomcms-edit
Medium priority fixes: CORS from env, shared HasRadioSettings trait, lazy RconService, validated() fixes, LogoGenerator hardening, DB indexes, user profile consistency, radio rank N+1 fix
This commit is contained in:
@@ -27,12 +27,14 @@ class RconService
|
||||
'ip' => setting('rcon_ip'),
|
||||
'port' => (int) setting('rcon_port'),
|
||||
];
|
||||
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
private function initialize(): void
|
||||
public function connect(): bool
|
||||
{
|
||||
if ($this->isConnected) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
|
||||
if ($this->socket === false) {
|
||||
@@ -40,7 +42,7 @@ class RconService
|
||||
Log::error("RCON initialization failed: {$error}");
|
||||
$this->closeConnection();
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! @socket_connect($this->socket, $this->config['ip'], $this->config['port'])) {
|
||||
@@ -48,10 +50,17 @@ class RconService
|
||||
Log::error("RCON connection failed: {$error}");
|
||||
$this->closeConnection();
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->isConnected = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function initialize(): void
|
||||
{
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
private function closeConnection(): void
|
||||
@@ -66,6 +75,10 @@ class RconService
|
||||
|
||||
public function isConnected(): bool
|
||||
{
|
||||
if (! $this->isConnected) {
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
return $this->isConnected;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user