nodes = $nodes; } else { $this->nodes = new Collection([$nodes]); } } public function handle(): bool { foreach ($this->nodes as $node) { $data = $node->getSSRConfig(); if ($node->is_ddns) { if (! $this->send($node->server.':'.$node->push_port, $node->auth->secret, $data)) { $result = false; } } else { // 多IP支持 foreach ($node->ips() as $ip) { if (! $this->send($ip.':'.$node->push_port, $node->auth->secret, $data)) { $result = false; } } } } return $result ?? true; } public function send(string $host, string $secret, array $data): bool { try { $response = Http::baseUrl($host)->timeout(15)->withHeaders(['secret' => $secret])->post('api/v2/node/reload', $data); $message = $response->json(); if ($message && Arr::has($message, ['success', 'content']) && $response->ok()) { if ($message['success'] === 'false') { Log::warning("【重载节点】失败:$host 反馈:".$message['content']); return false; } Log::notice("【重载节点】成功:$host 反馈:".$message['content']); return true; } Log::warning("【重载节点】失败:$host"); } catch (Exception $exception) { Log::alert('【重载节点】推送异常:'.$exception->getMessage()); } return false; } // 队列失败处理 public function failed(Throwable $exception): void { Log::alert('【重载节点】推送异常:'.$exception->getMessage()); } }