From 805b1ba1aaa663e96e8fb91321243e5448ace917 Mon Sep 17 00:00:00 2001 From: hgc Date: Mon, 6 Jan 2025 19:17:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/rpc/client/AuthRpcClient.php | 86 -------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 app/rpc/client/AuthRpcClient.php diff --git a/app/rpc/client/AuthRpcClient.php b/app/rpc/client/AuthRpcClient.php deleted file mode 100644 index 72ff133..0000000 --- a/app/rpc/client/AuthRpcClient.php +++ /dev/null @@ -1,86 +0,0 @@ -host = $host ?: Config::get('rpc.auth_host', '192.168.21.27'); -// $this->port = $port ?: Config::get('rpc.auth_port', 22101); -//// dump($this->host);dump($this->port); -// // 连接到 Auth RPC 服务 -// $this->client = stream_socket_client("tcp://{$this->host}:{$this->port}", $errorCode, $errorMessage); -// dump($this->client); -// if (false === $this->client) { -// throw new Exception("RPC 连接失败: {$errorMessage}"); -// } - } - - /** - * 验证 JWT token - * - * @param string $jwtToken - * @return array - * @throws Exception - */ - public function validateJwtToken(string $jwtToken): array - { - // 从配置文件中获取 RPC 服务的连接信息 - $host = config('rpc.auth_host', '192.168.21.27'); - $port = config('rpc.auth_port', 22101); -// dump($host);dump($port); return []; - // 创建连接到 Auth RPC 服务 - $client = stream_socket_client("tcp://{$host}:{$port}", $errorCode, $errorMessage); - - if (false === $client) { - throw new Exception("RPC 连接失败: {$errorMessage}"); - } - - $rpcRequest = [ - 'class' => 'Auth', - 'method' => 'ValidateJwtToken', - 'args' => [ - ['jwt_token' => $jwtToken], - ], - ]; -// dump($rpcRequest);return []; - - // 发送请求,Text 协议需要在末尾添加换行符 - fwrite($this->client, json_encode($rpcRequest) . "\n"); - - // 读取响应 - $result = fgets($this->client, 10240000); - if (!$result) { - throw new Exception('没有收到来自 Auth RPC 服务的响应'); - } - - // 解码 JSON 响应 - $response = json_decode($result, true); - - return $response; - } - - /** - * 关闭与 RPC 服务的连接 - */ - public function close() - { - if ($this->client) { - fclose($this->client); - } - } -}