fix: 修复上一个commit造成的bug

This commit is contained in:
xboard 2024-07-19 07:04:02 +08:00
parent 163d09c71b
commit c18f55d6dd
2 changed files with 10 additions and 13 deletions

View File

@ -28,7 +28,7 @@ class ClientController extends Controller
'surge' => '2398' 'surge' => '2398'
]; ];
// allowed types // allowed types
const AllowedTypes = ['vmess', 'vless', 'trojan', 'hysteria', 'shadowsocks']; const AllowedTypes = ['vmess', 'vless', 'trojan', 'hysteria', 'shadowsocks', 'hysteria2'];
public function subscribe(Request $request) public function subscribe(Request $request)
{ {
@ -41,9 +41,8 @@ class ClientController extends Controller
$ip = $request->input('ip', $request->ip()); $ip = $request->input('ip', $request->ip());
// get client version // get client version
$version = preg_match('/\/v?(\d+(\.\d+){0,2})/', $flag, $matches) ? $matches[1] : null; $version = preg_match('/\/v?(\d+(\.\d+){0,2})/', $flag, $matches) ? $matches[1] : null;
$supportHy2 = $version $supportHy2 = $version ? collect(self::SupportedHy2ClientVersions)
&& collect(self::SupportedHy2ClientVersions) ->contains(fn($minVersion, $client) => stripos($flag, $client) !== false && $this->versionCompare($version, $minVersion)) : true;
->contains(fn($minVersion, $client) => stripos($flag, $client) !== false && $this->versionCompare($version, $minVersion));
$user = $request->user; $user = $request->user;
// account not expired and is not banned. // account not expired and is not banned.
$userService = new UserService(); $userService = new UserService();
@ -85,13 +84,12 @@ class ClientController extends Controller
private function serverFilter($servers, $typesArr, $filterArr, $region, $supportHy2) private function serverFilter($servers, $typesArr, $filterArr, $region, $supportHy2)
{ {
return collect($servers)->reject(function ($server) use ($typesArr, $filterArr, $region, $supportHy2) { return collect($servers)->reject(function ($server) use ($typesArr, $filterArr, $region, $supportHy2) {
if ( if ($server['type'] == "hysteria" && $server['version'] == 2) {
$typesArr && ( if(!in_array('hysteria2', $typesArr)){
($server['type'] == "hysteria" && $server['version'] == 2 && !in_array('hysteria2', $typesArr) && !$supportHy2) || return true;
(!in_array($server['type'], $typesArr) && !($server['type'] == "hysteria" && $server['version'] == 2 && in_array('hysteria2', $typesArr))) }elseif(false == $supportHy2){
) return true;
) { }
return true;
} }
if ($filterArr) { if ($filterArr) {
@ -167,7 +165,6 @@ class ClientController extends Controller
$expiredDate = $user['expired_at'] ? date('Y-m-d', $user['expired_at']) : '长期有效'; $expiredDate = $user['expired_at'] ? date('Y-m-d', $user['expired_at']) : '长期有效';
$userService = new UserService(); $userService = new UserService();
$resetDay = $userService->getResetDay($user); $resetDay = $userService->getResetDay($user);
// 筛选提示
array_unshift($servers, array_merge($servers[0], [ array_unshift($servers, array_merge($servers[0], [
'name' => "套餐到期:{$expiredDate}", 'name' => "套餐到期:{$expiredDate}",
])); ]));

View File

@ -112,7 +112,7 @@ class Helper
{ {
$subscribeUrls = explode(',', admin_setting('subscribe_url')); $subscribeUrls = explode(',', admin_setting('subscribe_url'));
$subscribeUrl = $subscribeUrls[array_rand($subscribeUrls)]; $subscribeUrl = $subscribeUrls[array_rand($subscribeUrls)];
$subscribeUrl = self::replaceRandomNumber($subscribeUrl); $subscribeUrl = self::replaceByPattern($subscribeUrl);
if ($subscribeUrl) return $subscribeUrl . $path; if ($subscribeUrl) return $subscribeUrl . $path;
return url($path); return url($path);
} }