From 033b8c702aa5c7dd0c7888edf4ef650dc7cba0c4 Mon Sep 17 00:00:00 2001 From: xboard Date: Thu, 23 May 2024 16:42:57 +0800 Subject: [PATCH] =?UTF-8?q?hy2:=20=E4=B8=8D=E5=B8=A6=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E7=9A=84=E5=AE=A2=E6=88=B7=E7=AB=AF=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E4=B8=8B=E5=8F=91hy2=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/V1/Client/ClientController.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/V1/Client/ClientController.php b/app/Http/Controllers/V1/Client/ClientController.php index f0d16c8..467131f 100644 --- a/app/Http/Controllers/V1/Client/ClientController.php +++ b/app/Http/Controllers/V1/Client/ClientController.php @@ -31,9 +31,7 @@ class ClientController extends Controller preg_match('/\/v?(\d+(\.\d+){0,2})/', $flag, $matches); $version = $matches[1]??null; - - $supportHy2 = false; - $minSupportHy2ClinetVersionMap = [ + $supportedClientVersions = [ 'NekoBox' => '1.2.7', 'sing-box' => '1.5.0', 'stash' => '2.5.0', @@ -47,14 +45,12 @@ class ClientController extends Controller 'v2rayN' => '6.31', 'surge' => '2398' ]; - foreach($minSupportHy2ClinetVersionMap as $client => $minVersion){ - if (stripos($flag, $client) !== false && $this->versionCompare($version, $minVersion)) { - $supportHy2 = true; - break; // 如果已经找到支持的客户端,提前退出循环 - } - } - if(config('app.debug')){ - Log::channel('daily')->info($flag); + $supportHy2 = true; + if ($version) { + $supportHy2 = collect($supportedClientVersions) + ->contains(function ($minVersion, $client) use ($flag, $version) { + return stripos($flag, $client) !== false && $this->versionCompare($version, $minVersion); + }); } $user = $request->user; // account not expired and is not banned.