원격 syslog 기능 제거
This commit is contained in:
1 parent
95a4750137
commit
c0dadcc8a9
5 files changed
+4
-482
No files matched your search
+1
-63
@@ -16,12 +16,11 @@ require_once __DIR__ . '/../public/api.php';
|
||||
|
||||
final class ControlWebSocket implements MessageComponentInterface
|
||||
{
|
||||
/** @var SplObjectStorage<ConnectionInterface, array{dmesg: bool, synology_log: bool, ip: string}> */
|
||||
/** @var SplObjectStorage<ConnectionInterface, array{dmesg: bool, ip: string}> */
|
||||
private SplObjectStorage $clients;
|
||||
|
||||
private bool $statusBusy = false;
|
||||
private bool $dmesgBusy = false;
|
||||
private bool $synologyLogBusy = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -48,7 +47,6 @@ final class ControlWebSocket implements MessageComponentInterface
|
||||
|
||||
$this->clients[$conn] = [
|
||||
'dmesg' => false,
|
||||
'synology_log' => false,
|
||||
'ip' => $ip,
|
||||
];
|
||||
$this->sendStatus($conn);
|
||||
@@ -63,7 +61,6 @@ final class ControlWebSocket implements MessageComponentInterface
|
||||
|
||||
$state = $this->clients[$from] ?? [
|
||||
'dmesg' => false,
|
||||
'synology_log' => false,
|
||||
'ip' => '127.0.0.1',
|
||||
];
|
||||
|
||||
@@ -76,15 +73,6 @@ final class ControlWebSocket implements MessageComponentInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (($data['type'] ?? '') === 'synology_log') {
|
||||
$state['synology_log'] = !empty($data['open']);
|
||||
$this->clients[$from] = $state;
|
||||
if ($state['synology_log']) {
|
||||
$this->sendSynologyLog($from);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (($data['type'] ?? '') === 'status_refresh') {
|
||||
$this->sendStatus($from);
|
||||
}
|
||||
@@ -159,40 +147,6 @@ final class ControlWebSocket implements MessageComponentInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function broadcastSynologyLog(): void
|
||||
{
|
||||
if ($this->clients->count() === 0 || $this->synologyLogBusy) {
|
||||
return;
|
||||
}
|
||||
|
||||
$targets = [];
|
||||
foreach ($this->clients as $client) {
|
||||
$state = $this->clients[$client];
|
||||
if (!empty($state['synology_log'])) {
|
||||
$targets[] = $client;
|
||||
}
|
||||
}
|
||||
|
||||
if ($targets === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->synologyLogBusy = true;
|
||||
try {
|
||||
$payload = $this->json([
|
||||
'type' => 'synology_log',
|
||||
'data' => synology_remote_log(),
|
||||
]);
|
||||
foreach ($targets as $client) {
|
||||
$client->send($payload);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
$this->broadcastError($e);
|
||||
} finally {
|
||||
$this->synologyLogBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function sendStatus(ConnectionInterface $conn): void
|
||||
{
|
||||
try {
|
||||
@@ -220,21 +174,6 @@ final class ControlWebSocket implements MessageComponentInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function sendSynologyLog(ConnectionInterface $conn): void
|
||||
{
|
||||
try {
|
||||
$conn->send($this->json([
|
||||
'type' => 'synology_log',
|
||||
'data' => synology_remote_log(),
|
||||
]));
|
||||
} catch (Throwable $e) {
|
||||
$conn->send($this->json([
|
||||
'type' => 'error',
|
||||
'message' => $e->getMessage(),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
private function statusPayload(): string
|
||||
{
|
||||
try {
|
||||
@@ -341,7 +280,6 @@ $startedSignature = $watchSignature($watchFiles);
|
||||
|
||||
$loop->addPeriodicTimer(1.0, static fn() => $app->broadcastStatus());
|
||||
$loop->addPeriodicTimer(1.0, static fn() => $app->broadcastDmesg());
|
||||
$loop->addPeriodicTimer(1.0, static fn() => $app->broadcastSynologyLog());
|
||||
$loop->addPeriodicTimer(15.0, static function () use ($watchFiles, $watchSignature, $startedSignature): void {
|
||||
if ($watchSignature($watchFiles) === $startedSignature) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user