From d3eef1b4a681d2a788bda3abbea52d4e5c5da6c5 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Thu, 5 Jan 2023 13:51:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20Nodes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/ServerController.php | 7 ++++++- app/Support/Cluster.php | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ServerController.php b/app/Http/Controllers/Api/ServerController.php index 5759b43..4a64886 100644 --- a/app/Http/Controllers/Api/ServerController.php +++ b/app/Http/Controllers/Api/ServerController.php @@ -26,6 +26,11 @@ public function module_reports(Request $request) public function nodes() { $nodes = Cluster::nodes(true); - return $this->success($nodes); + $current_node_id = Cluster::currentNode()['id']; + + return $this->success([ + 'nodes' => $nodes, + 'current_node_id' => $current_node_id, + ]); } } diff --git a/app/Support/Cluster.php b/app/Support/Cluster.php index 77c0a5d..ff78403 100644 --- a/app/Support/Cluster.php +++ b/app/Support/Cluster.php @@ -142,4 +142,9 @@ public static function registerThisNode($report = true): void Cluster::publish('node.ok'); } } + + public static function currentNode() + { + return config('settings.node'); + } }