mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
fix: correct know issues
Some checks are pending
Docker Build and Publish / build (push) Waiting to run
Some checks are pending
Docker Build and Publish / build (push) Waiting to run
This commit is contained in:
parent
6342591821
commit
6216622ea8
@ -120,18 +120,15 @@ class ClientController extends Controller
|
|||||||
if ($this->isBrowserAccess($request)) {
|
if ($this->isBrowserAccess($request)) {
|
||||||
return $this->handleBrowserSubscribe($user, $userService);
|
return $this->handleBrowserSubscribe($user, $userService);
|
||||||
}
|
}
|
||||||
|
|
||||||
$types = $this->getFilteredTypes($request->input('types', 'all'));
|
|
||||||
$filterArr = $this->getFilterArray($request->input('filter'));
|
|
||||||
$clientInfo = $this->getClientInfo($request);
|
$clientInfo = $this->getClientInfo($request);
|
||||||
|
$types = $this->getFilteredTypes($request->input('types'), $clientInfo['supportHy2']);
|
||||||
|
$filterArr = $this->getFilterArray($request->input('filter'));
|
||||||
// Get available servers and apply filters
|
// Get available servers and apply filters
|
||||||
$servers = ServerService::getAvailableServers($user);
|
$servers = ServerService::getAvailableServers($user);
|
||||||
$serversFiltered = $this->filterServers(
|
$serversFiltered = $this->filterServers(
|
||||||
servers: $servers,
|
servers: $servers,
|
||||||
types: $types,
|
types: $types,
|
||||||
filters: $filterArr,
|
filters: $filterArr,
|
||||||
supportHy2: $clientInfo['supportHy2']
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->setSubscribeInfoToServers($serversFiltered, $user, count($servers) - count($serversFiltered));
|
$this->setSubscribeInfoToServers($serversFiltered, $user, count($servers) - count($serversFiltered));
|
||||||
@ -154,14 +151,21 @@ class ClientController extends Controller
|
|||||||
return (new General($user, $serversFiltered))->handle();
|
return (new General($user, $serversFiltered))->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFilteredTypes(string $types): array
|
private function getFilteredTypes(string|null $types, bool $supportHy2): array
|
||||||
{
|
{
|
||||||
return $types === 'all'
|
if ($types === 'all') {
|
||||||
|
return self::ALLOWED_TYPES;
|
||||||
|
}
|
||||||
|
|
||||||
|
$allowedTypes = $supportHy2
|
||||||
? self::ALLOWED_TYPES
|
? self::ALLOWED_TYPES
|
||||||
: array_values(array_intersect(
|
: array_diff(self::ALLOWED_TYPES, ['hysteria2']);
|
||||||
explode('|', str_replace(['|', '|', ','], '|', $types)),
|
if (!$types) {
|
||||||
self::ALLOWED_TYPES
|
return array_values($allowedTypes);
|
||||||
));
|
}
|
||||||
|
|
||||||
|
$userTypes = explode('|', str_replace(['|', '|', ','], '|', $types));
|
||||||
|
return array_values(array_intersect($userTypes, $allowedTypes));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFilterArray(?string $filter): ?array
|
private function getFilterArray(?string $filter): ?array
|
||||||
@ -199,12 +203,16 @@ class ClientController extends Controller
|
|||||||
return $result || !count(self::CLIENT_VERSIONS);
|
return $result || !count(self::CLIENT_VERSIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function filterServers(array $servers, array $types, ?array $filters, bool $supportHy2): array
|
private function filterServers(array $servers, array $types, ?array $filters): array
|
||||||
{
|
{
|
||||||
return collect($servers)->reject(function ($server) use ($types, $filters, $supportHy2) {
|
return collect($servers)->reject(function ($server) use ($types, $filters) {
|
||||||
// Check Hysteria2 compatibility
|
// Check Hysteria2 compatibility
|
||||||
if ($server['type'] === 'hysteria' && optional($server['protocol_settings'])['version'] === 2) {
|
if ($server['type'] === 'hysteria' && optional($server['protocol_settings'])['version'] === 2) {
|
||||||
if (!in_array('hysteria2', $types) || !$supportHy2) {
|
if (!in_array('hysteria2', $types)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!in_array($server['type'], $types)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user