From 1186350f7a2a8ba460d54cc077f9208237a88241 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Wed, 25 Jun 2025 09:14:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=9F=9F=E5=90=8D=E4=BB=A3?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/process/Proxy.php | 33 +++++++++++++++++++++++++++++++++ app/util/Xunfei.php | 3 ++- config/process.php | 15 +++++++++++---- 3 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 app/process/Proxy.php diff --git a/app/process/Proxy.php b/app/process/Proxy.php new file mode 100644 index 0000000..72a509d --- /dev/null +++ b/app/process/Proxy.php @@ -0,0 +1,33 @@ + 'api.openai.com', + 'ntrans.example.cn' => 'ntrans.xfyun.cn', + ]; + $host = $request->host(true); + if (!isset($replace[$host])) { + return $connection->send(response('404 not found', 404)); + } + $host = $replace[$host]; + $buffer = (string)$request; + $con = new AsyncTcpConnection("tcp://$host:443", ['ssl' =>[ + 'verify_peer' => false + ]]); + $buffer = preg_replace("/Host: ?(.*?)\r\n/", "Host: $host\r\n", $buffer); + $con->transport = 'ssl'; + $connection->protocol = null; + $con->send($buffer); + $con->pipe($connection); + $connection->pipe($con); + $con->connect(); + } +} \ No newline at end of file diff --git a/app/util/Xunfei.php b/app/util/Xunfei.php index 76918c9..7d5d887 100644 --- a/app/util/Xunfei.php +++ b/app/util/Xunfei.php @@ -53,7 +53,8 @@ class Xunfei //在控制台-我的应用-机器翻译获取 $api_key = "b6d805f240176ecaea85130cb5f2bca1"; // 机器翻译接口地址 - $url = "https://ntrans.xfyun.cn/v2/ots"; +// $url = "https://ntrans.xfyun.cn/v2/ots"; + $url = "https://ntrans.example.cn"; //body组装 // $text = "中华人民共和国于1949年成立";//待翻译文本 $body = json_encode($this->getBody($app_id, $from, $to, $text)); diff --git a/config/process.php b/config/process.php index d007100..6b31fa2 100644 --- a/config/process.php +++ b/config/process.php @@ -60,9 +60,16 @@ return [ ] ], // 船舶信息更新定时任务 - 'ship-update-scheduler' => [ - 'handler' => app\process\ShipUpdateScheduler::class, +// 'ship-update-scheduler' => [ +// 'handler' => app\process\ShipUpdateScheduler::class, +// 'reloadable' => false, +// 'constructor' => [] +// ], + // http代理配置 + 'proxy' => [ + 'handler' => app\process\Proxy::class, + 'listen' => 'http://0.0.0.0:25519', + 'count' => 1, 'reloadable' => false, - 'constructor' => [] - ] + ], ];