hy2: 不带版本号的客户端默认下发hy2节点

This commit is contained in:
xboard 2024-05-23 16:42:57 +08:00
parent dd78dbde5c
commit 033b8c702a

View File

@ -31,9 +31,7 @@ class ClientController extends Controller
preg_match('/\/v?(\d+(\.\d+){0,2})/', $flag, $matches); preg_match('/\/v?(\d+(\.\d+){0,2})/', $flag, $matches);
$version = $matches[1]??null; $version = $matches[1]??null;
$supportedClientVersions = [
$supportHy2 = false;
$minSupportHy2ClinetVersionMap = [
'NekoBox' => '1.2.7', 'NekoBox' => '1.2.7',
'sing-box' => '1.5.0', 'sing-box' => '1.5.0',
'stash' => '2.5.0', 'stash' => '2.5.0',
@ -47,14 +45,12 @@ class ClientController extends Controller
'v2rayN' => '6.31', 'v2rayN' => '6.31',
'surge' => '2398' 'surge' => '2398'
]; ];
foreach($minSupportHy2ClinetVersionMap as $client => $minVersion){ $supportHy2 = true;
if (stripos($flag, $client) !== false && $this->versionCompare($version, $minVersion)) { if ($version) {
$supportHy2 = true; $supportHy2 = collect($supportedClientVersions)
break; // 如果已经找到支持的客户端,提前退出循环 ->contains(function ($minVersion, $client) use ($flag, $version) {
} return stripos($flag, $client) !== false && $this->versionCompare($version, $minVersion);
} });
if(config('app.debug')){
Log::channel('daily')->info($flag);
} }
$user = $request->user; $user = $request->user;
// account not expired and is not banned. // account not expired and is not banned.