Compare commits

..

No commits in common. "6216622ea8887bacf38b405d4e041798cc900bdf" and "2c4a3b520f024c75bddd926c3ac8eedf9e08ef72" have entirely different histories.

3 changed files with 70 additions and 115 deletions

View File

@ -120,15 +120,18 @@ class ClientController extends Controller
if ($this->isBrowserAccess($request)) { if ($this->isBrowserAccess($request)) {
return $this->handleBrowserSubscribe($user, $userService); return $this->handleBrowserSubscribe($user, $userService);
} }
$clientInfo = $this->getClientInfo($request);
$types = $this->getFilteredTypes($request->input('types'), $clientInfo['supportHy2']); $types = $this->getFilteredTypes($request->input('types', 'all'));
$filterArr = $this->getFilterArray($request->input('filter')); $filterArr = $this->getFilterArray($request->input('filter'));
$clientInfo = $this->getClientInfo($request);
// 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));
@ -151,21 +154,14 @@ class ClientController extends Controller
return (new General($user, $serversFiltered))->handle(); return (new General($user, $serversFiltered))->handle();
} }
private function getFilteredTypes(string|null $types, bool $supportHy2): array private function getFilteredTypes(string $types): array
{ {
if ($types === 'all') { return $types === 'all'
return self::ALLOWED_TYPES;
}
$allowedTypes = $supportHy2
? self::ALLOWED_TYPES ? self::ALLOWED_TYPES
: array_diff(self::ALLOWED_TYPES, ['hysteria2']); : array_values(array_intersect(
if (!$types) { explode('|', str_replace(['|', '', ','], '|', $types)),
return array_values($allowedTypes); self::ALLOWED_TYPES
} ));
$userTypes = explode('|', str_replace(['|', '', ','], '|', $types));
return array_values(array_intersect($userTypes, $allowedTypes));
} }
private function getFilterArray(?string $filter): ?array private function getFilterArray(?string $filter): ?array
@ -203,16 +199,12 @@ 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): array private function filterServers(array $servers, array $types, ?array $filters, bool $supportHy2): array
{ {
return collect($servers)->reject(function ($server) use ($types, $filters) { return collect($servers)->reject(function ($server) use ($types, $filters, $supportHy2) {
// 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)) { if (!in_array('hysteria2', $types) || !$supportHy2) {
return true;
}
} else {
if (!in_array($server['type'], $types)) {
return true; return true;
} }
} }

View File

@ -114,7 +114,6 @@ docker compose up -d
``` ```
> - 如果您是较早安装的旧版本,需要将命令中的 `web` 改为 `xboard`,即: > - 如果您是较早安装的旧版本,需要将命令中的 `web` 改为 `xboard`,即:
```bash ```bash
git fetch --all && git reset --hard origin/master && git pull origin master
docker compose pull && \ docker compose pull && \
docker compose run -it --rm xboard php artisan xboard:update && \ docker compose run -it --rm xboard php artisan xboard:update && \
docker compose up -d docker compose up -d

View File

@ -1,69 +1,47 @@
## Xboard 在 aaPanel 环境下的部署指南 ## aaPanel 快速部署指南
## 目录 本指南介绍如何使用 aaPanel 部署 Xboard。
1. [环境要求](#环境要求)
2. [快速部署](#快速部署)
3. [详细配置](#详细配置)
4. [维护指南](#维护指南)
5. [故障排查](#故障排查)
## 环境要求 ⚠️ 不建议在 CentOS 7 上部署,可能会遇到兼容性问题。
### 硬件配置 ### 1. 环境准备
- CPU: 1核心及以上
- 内存: 2GB及以上
- 硬盘: 10GB及以上可用空间
### 软件要求 安装 aaPanel
- 操作系统: Ubuntu 20.04+ / Debian 10+ (⚠️ 不建议使用 CentOS 7)
- aaPanel 最新版
- PHP 8.2
- MySQL 5.7+
- Redis
- Nginx任意版本
## 快速部署
### 1. 安装 aaPanel
```bash ```bash
URL=https://www.aapanel.com/script/install_6.0_en.sh && \ URL=https://www.aapanel.com/script/install_6.0_en.sh && \
if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O install_6.0_en.sh "$URL";fi && \ if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O install_6.0_en.sh "$URL";fi && \
bash install_6.0_en.sh aapanel bash install_6.0_en.sh aapanel
``` ```
### 2. 基础环境配置 ### 2. 环境配置
#### 2.1 安装 LNMP 环境 1. 在 aaPanel 中安装 LNMP
在 aaPanel 面板中安装:
- Nginx任意版本 - Nginx任意版本
- MySQL 5.7 - MySQL 5.7
- PHP 8.2 - PHP 8.2
#### 2.2 安装 PHP 扩展 2. 安装 PHP 扩展:
必需的 PHP 扩展:
- redis - redis
- fileinfo - fileinfo
- swoole4 - swoole4
- readline - readline
- event - event
#### 2.3 解除 PHP 禁用函数 3. 解除 PHP 禁用函数:
需要启用的函数:
- putenv - putenv
- proc_open - proc_open
- pcntl_alarm - pcntl_alarm
- pcntl_signal - pcntl_signal
### 3. 站点配置 ### 3. 部署步骤
#### 3.1 创建站点 1. 添加站点:
1. 导航至aaPanel > Website > Add site - 进入 aaPanel > Website > Add site
2. 填写信息: - 填写域名
- 域名:填写您的站点域名 - 数据库选择 MySQL
- 数据库:选择 MySQL - PHP 版本选择 8.1
- PHP 版本:选择 8.2
#### 3.2 部署 Xboard 2. 安装 Xboard
```bash ```bash
# 进入站点目录 # 进入站点目录
cd /www/wwwroot/你的域名 cd /www/wwwroot/你的域名
@ -79,9 +57,9 @@ git clone https://github.com/cedar2025/Xboard.git ./
sh init.sh sh init.sh
``` ```
#### 3.3 配置站点 3. 配置站点
1. 设置运行目录为 `/public` - 设置运行目录为 `/public`
2. 添加伪静态规则: - 配置伪静态规则:
```nginx ```nginx
location /downloads { location /downloads {
} }
@ -98,32 +76,30 @@ location ~ .*\.(js|css)?$
} }
``` ```
## 详细配置 4. 配置守护进程:
- 安装 Supervisor
### 1. 配置守护进程 - 添加队列守护进程:
1. 安装 Supervisor
2. 添加队列守护进程:
- 名称:`Xboard` - 名称:`Xboard`
- 运行用户:`www` - 运行用户:`www`
- 运行目录:站点目录 - 运行目录:站点目录
- 启动命令:`php artisan horizon` - 启动命令:`php artisan horizon`
- 进程数1 - 进程数1
### 2. 配置计划任务 5. 添加计划任务:
- 类型Shell Script - 类型Shell Script
- 任务名v2board - 任务名v2board
- 周期1分钟 - 周期1分钟
- 脚本内容:`php /www/wwwroot/站点目录/artisan schedule:run` - 脚本内容:`php /www/wwwroot/站点目录/artisan schedule:run`
### 3. Octane 配置(可选) ### 4. 开启 Octane(可选)
#### 3.1 添加 Octane 守护进程 1. 添加 Octane 守护进程
- 名称Octane - 名称Octane
- 运行用户www - 运行用户www
- 运行目录:站点目录 - 运行目录:站点目录
- 启动命令:`/www/server/php/81/bin/php artisan octane:start --port 7010` - 启动命令:`/www/server/php/81/bin/php artisan octane:start --port 7010`
- 进程数1 - 进程数1
#### 3.2 Octane 专用伪静态规则 2. 更新伪静态规则:
```nginx ```nginx
location ~* \.(jpg|jpeg|png|gif|js|css|svg|woff2|woff|ttf|eot|wasm|json|ico)$ { location ~* \.(jpg|jpeg|png|gif|js|css|svg|woff2|woff|ttf|eot|wasm|json|ico)$ {
} }
@ -144,30 +120,18 @@ location ~ .* {
} }
``` ```
## 维护指南 ### 5. 版本更新
### 版本更新
```bash ```bash
# 进入站点目录 # 更新代码
cd /www/wwwroot/你的域名 cd /www/wwwroot/你的域名
# 执行更新脚本
git fetch --all && git reset --hard origin/master && git pull origin master
sh update.sh sh update.sh
# 如果启用了 Octane需要重启守护进程 # 如果启用了 Octane需要重启守护进程
# aaPanel > App Store > Tools > Supervisor > 重启 Octane # aaPanel > App Store > Tools > Supervisor > 重启 Octane
``` ```
### 日常维护 ### 注意事项
- 定期检查日志
- 监控系统资源使用情况
- 定期备份数据库和配置文件
## 故障排查 - 修改后台路径需要重启服务才能生效
- 启用 octane 后的任何代码修改都需要重启才能生效
### 常见问题
1. 修改后台路径需要重启服务才能生效
2. 启用 Octane 后的任何代码修改都需要重启才能生效
3. PHP 扩展安装失败时,请检查 PHP 版本是否正确
4. 数据库连接失败时,请检查数据库配置和权限