init
This commit is contained in:
@@ -1,36 +1,114 @@
|
||||
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
||||
# HY2 Panel
|
||||
|
||||
## Getting Started
|
||||
单机自托管的 Next 16 管理面板,面向 Hysteria 2 HTTP 鉴权与多节点流量聚合场景。
|
||||
|
||||
First, run the development server:
|
||||
功能包括:
|
||||
|
||||
- 单管理员本地登录,基于 SQLite 持久化会话
|
||||
- hy2 用户管理:启用/禁用、重置密码、到期时间、总流量上限、稳定 `auth_id`
|
||||
- 多节点管理:每节点独立鉴权 URL + token、`trafficStats` URL/secret、轮询间隔
|
||||
- 公开 HTTP 鉴权接口:返回标准 `200 + { ok, id }`
|
||||
- 后台轮询 `trafficStats`、聚合用户流量、记录同步错误与鉴权审计
|
||||
- 对禁用、过期、超额用户调用节点 `kick` 做准实时断开
|
||||
|
||||
## Environment
|
||||
|
||||
复制 `.env.example` 为 `.env`,至少设置:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
bun dev
|
||||
APP_URL=http://127.0.0.1:3000
|
||||
SESSION_SECRET=your-long-random-secret
|
||||
SESSION_COOKIE_SECURE=auto
|
||||
ADMIN_PASSWORD=your-strong-admin-password
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
说明:
|
||||
|
||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||
- `ADMIN_USERNAME` / `ADMIN_PASSWORD` 是单管理员账号,启动时会同步到数据库中的唯一管理员记录
|
||||
- `SESSION_COOKIE_SECURE=auto` 时会按 `APP_URL` 协议决定是否开启 `Secure` cookie;如果你是直接用 `http://IP:3000` 访问,不要强制设成 `true`
|
||||
- `DATABASE_PATH` 默认是 `./data/hy2-panel.db`
|
||||
- `POLLER_ENABLED=true` 时,Next `instrumentation.ts` 会在 Node 进程启动后启动轮询器
|
||||
|
||||
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||
## Development
|
||||
|
||||
## Learn More
|
||||
```bash
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
打开 `http://127.0.0.1:3000`。
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
## Build
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
||||
```bash
|
||||
npm run lint
|
||||
npm run build
|
||||
```
|
||||
|
||||
## Deploy on Vercel
|
||||
这里将生产构建固定为 `next build --webpack`。原因是 Next 16 默认 Turbopack,但在部分受限环境下会触发构建期端口绑定问题;Webpack 构建已验证通过。
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
## HY2 Node Access
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
||||
面板里的每个节点都会生成独立鉴权 URL,例如:
|
||||
|
||||
```yaml
|
||||
auth:
|
||||
type: http
|
||||
http:
|
||||
url: http://127.0.0.1:3000/api/hy2/nodes/tokyo-01/auth?token=YOUR_TOKEN
|
||||
insecure: false
|
||||
```
|
||||
|
||||
根据 Hysteria 官方文档,HTTP 鉴权回调请求体是:
|
||||
|
||||
```json
|
||||
{
|
||||
"addr": "123.123.123.123:44556",
|
||||
"auth": "username:password",
|
||||
"tx": 123456
|
||||
}
|
||||
```
|
||||
|
||||
面板响应:
|
||||
|
||||
```json
|
||||
{
|
||||
"ok": true,
|
||||
"id": "immutable-auth-id"
|
||||
}
|
||||
```
|
||||
|
||||
多节点识别依赖“不同的 URL 路径”,不是依赖 hy2 自动附带节点 ID。
|
||||
|
||||
## trafficStats
|
||||
|
||||
节点需启用:
|
||||
|
||||
```yaml
|
||||
trafficStats:
|
||||
listen: :9999
|
||||
secret: some_secret
|
||||
```
|
||||
|
||||
面板会轮询:
|
||||
|
||||
- `GET /traffic?clear=1`
|
||||
- `GET /online`
|
||||
- `GET /dump/streams`
|
||||
- `POST /kick`
|
||||
|
||||
## systemd
|
||||
|
||||
已提供示例单元文件 [deploy/hy2-panel.service](/root/hy2-panel/deploy/hy2-panel.service)。
|
||||
|
||||
典型流程:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run build
|
||||
sudo cp deploy/hy2-panel.service /etc/systemd/system/hy2-panel.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now hy2-panel
|
||||
```
|
||||
|
||||
如果你需要对外开放,再在 Nginx/Caddy 前面反代 `127.0.0.1:3000` 即可。
|
||||
|
||||
Reference in New Issue
Block a user