mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 22:06:38 +08:00
[优化] 改名
This commit is contained in:
@@ -50,7 +50,7 @@ jobs:
|
||||
CI: ""
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
cd atsf_server/web
|
||||
cd openflare_server/web
|
||||
corepack enable
|
||||
pnpm install --frozen-lockfile
|
||||
NEXT_PUBLIC_APP_VERSION="$VERSION" pnpm build
|
||||
@@ -59,7 +59,7 @@ jobs:
|
||||
if: steps.version.outputs.should_run == 'true'
|
||||
uses: https://github.com/actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: atsf_server/go.mod
|
||||
go-version-file: openflare_server/go.mod
|
||||
|
||||
- name: Build Server Binaries
|
||||
if: steps.version.outputs.should_run == 'true'
|
||||
@@ -72,18 +72,18 @@ jobs:
|
||||
|
||||
mkdir -p dist
|
||||
|
||||
cd atsf_server
|
||||
cd openflare_server
|
||||
go mod download
|
||||
|
||||
while read -r GOOS GOARCH ASSET_NAME; do
|
||||
GOOS="$GOOS" GOARCH="$GOARCH" \
|
||||
go build -trimpath -ldflags "-s -w -X 'atsflare/common.Version=$VERSION'" -o "../dist/$ASSET_NAME" .
|
||||
go build -trimpath -ldflags "-s -w -X 'openflare/common.Version=$VERSION'" -o "../dist/$ASSET_NAME" .
|
||||
done <<'EOF'
|
||||
linux amd64 atsflare-server-linux-amd64
|
||||
linux arm64 atsflare-server-linux-arm64
|
||||
darwin amd64 atsflare-server-darwin-amd64
|
||||
darwin arm64 atsflare-server-darwin-arm64
|
||||
windows amd64 atsflare-server-windows-amd64.exe
|
||||
linux amd64 openflare-server-linux-amd64
|
||||
linux arm64 openflare-server-linux-arm64
|
||||
darwin amd64 openflare-server-darwin-amd64
|
||||
darwin arm64 openflare-server-darwin-arm64
|
||||
windows amd64 openflare-server-windows-amd64.exe
|
||||
EOF
|
||||
|
||||
- name: Build Agent Binaries
|
||||
@@ -95,18 +95,18 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
cd atsf_agent
|
||||
cd openflare_agent
|
||||
go mod download
|
||||
|
||||
while read -r GOOS GOARCH ASSET_NAME; do
|
||||
GOOS="$GOOS" GOARCH="$GOARCH" \
|
||||
go build -trimpath -ldflags "-s -w -X 'atsflare-agent/internal/config.AgentVersion=$VERSION'" -o "../dist/$ASSET_NAME" ./cmd/agent
|
||||
go build -trimpath -ldflags "-s -w -X 'openflare-agent/internal/config.AgentVersion=$VERSION'" -o "../dist/$ASSET_NAME" ./cmd/agent
|
||||
done <<'EOF'
|
||||
linux amd64 atsflare-agent-linux-amd64
|
||||
linux arm64 atsflare-agent-linux-arm64
|
||||
darwin amd64 atsflare-agent-darwin-amd64
|
||||
darwin arm64 atsflare-agent-darwin-arm64
|
||||
windows amd64 atsflare-agent-windows-amd64.exe
|
||||
linux amd64 openflare-agent-linux-amd64
|
||||
linux arm64 openflare-agent-linux-arm64
|
||||
darwin amd64 openflare-agent-darwin-amd64
|
||||
darwin arm64 openflare-agent-darwin-arm64
|
||||
windows amd64 openflare-agent-windows-amd64.exe
|
||||
EOF
|
||||
|
||||
- name: Publish Release
|
||||
|
||||
@@ -53,8 +53,8 @@ jobs:
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ./atsf_server
|
||||
file: ./atsf_server/Dockerfile
|
||||
context: ./openflare_server
|
||||
file: ./openflare_server/Dockerfile
|
||||
platforms: ${{ matrix.platform }}
|
||||
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||
build-args: |
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
env:
|
||||
CI: ""
|
||||
run: |
|
||||
cd atsf_server/web
|
||||
cd openflare_server/web
|
||||
corepack enable
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm build
|
||||
@@ -27,4 +27,4 @@ jobs:
|
||||
with:
|
||||
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
BRANCH: gh-pages # The branch the action should deploy to.
|
||||
FOLDER: atsf_server/web/build # The folder the action should deploy.
|
||||
FOLDER: openflare_server/web/build # The folder the action should deploy.
|
||||
@@ -63,7 +63,7 @@ jobs:
|
||||
CI: ""
|
||||
VERSION: ${{ needs.prepare.outputs.version }}
|
||||
run: |
|
||||
cd atsf_server/web
|
||||
cd openflare_server/web
|
||||
corepack enable
|
||||
pnpm install --frozen-lockfile
|
||||
NEXT_PUBLIC_APP_VERSION="$VERSION" pnpm build
|
||||
@@ -72,7 +72,7 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: frontend-build
|
||||
path: atsf_server/web/build
|
||||
path: openflare_server/web/build
|
||||
retention-days: 1
|
||||
|
||||
build-binaries:
|
||||
@@ -87,19 +87,19 @@ jobs:
|
||||
include:
|
||||
- goos: linux
|
||||
goarch: amd64
|
||||
asset_name: atsflare-server-linux-amd64
|
||||
asset_name: openflare-server-linux-amd64
|
||||
- goos: linux
|
||||
goarch: arm64
|
||||
asset_name: atsflare-server-linux-arm64
|
||||
asset_name: openflare-server-linux-arm64
|
||||
- goos: darwin
|
||||
goarch: amd64
|
||||
asset_name: atsflare-server-darwin-amd64
|
||||
asset_name: openflare-server-darwin-amd64
|
||||
- goos: darwin
|
||||
goarch: arm64
|
||||
asset_name: atsflare-server-darwin-arm64
|
||||
asset_name: openflare-server-darwin-arm64
|
||||
- goos: windows
|
||||
goarch: amd64
|
||||
asset_name: atsflare-server-windows-amd64.exe
|
||||
asset_name: openflare-server-windows-amd64.exe
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -111,15 +111,15 @@ jobs:
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: frontend-build
|
||||
path: atsf_server/web/build
|
||||
path: openflare_server/web/build
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: atsf_server/go.mod
|
||||
go-version-file: openflare_server/go.mod
|
||||
|
||||
- name: Build Server
|
||||
working-directory: atsf_server
|
||||
working-directory: openflare_server
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOOS: ${{ matrix.goos }}
|
||||
@@ -129,7 +129,7 @@ jobs:
|
||||
run: |
|
||||
go mod download
|
||||
mkdir -p ../dist
|
||||
go build -trimpath -ldflags "-s -w -X 'atsflare/common.Version=$VERSION'" -o "../dist/$ASSET_NAME" .
|
||||
go build -trimpath -ldflags "-s -w -X 'openflare/common.Version=$VERSION'" -o "../dist/$ASSET_NAME" .
|
||||
|
||||
- name: Upload Binary Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -148,16 +148,16 @@ jobs:
|
||||
include:
|
||||
- goos: linux
|
||||
goarch: amd64
|
||||
asset_name: atsflare-agent-linux-amd64
|
||||
asset_name: openflare-agent-linux-amd64
|
||||
- goos: linux
|
||||
goarch: arm64
|
||||
asset_name: atsflare-agent-linux-arm64
|
||||
asset_name: openflare-agent-linux-arm64
|
||||
- goos: darwin
|
||||
goarch: amd64
|
||||
asset_name: atsflare-agent-darwin-amd64
|
||||
asset_name: openflare-agent-darwin-amd64
|
||||
- goos: darwin
|
||||
goarch: arm64
|
||||
asset_name: atsflare-agent-darwin-arm64
|
||||
asset_name: openflare-agent-darwin-arm64
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -168,10 +168,10 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: atsf_agent/go.mod
|
||||
go-version-file: openflare_agent/go.mod
|
||||
|
||||
- name: Build Agent
|
||||
working-directory: atsf_agent
|
||||
working-directory: openflare_agent
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOOS: ${{ matrix.goos }}
|
||||
@@ -181,7 +181,7 @@ jobs:
|
||||
run: |
|
||||
go mod download
|
||||
mkdir -p ../dist
|
||||
go build -trimpath -ldflags "-s -w -X 'atsflare-agent/internal/config.AgentVersion=$VERSION'" -o "../dist/$ASSET_NAME" ./cmd/agent
|
||||
go build -trimpath -ldflags "-s -w -X 'openflare-agent/internal/config.AgentVersion=$VERSION'" -o "../dist/$ASSET_NAME" ./cmd/agent
|
||||
|
||||
- name: Upload Agent Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# AGENTS.md
|
||||
|
||||
本文件是 ATSFlare 的 AI 接手入口,不承载详细设计、规范和计划。接手项目时,先按顺序阅读以下文档:
|
||||
本文件是 OpenFlare 的 AI 接手入口,不承载详细设计、规范和计划。接手项目时,先按顺序阅读以下文档:
|
||||
|
||||
1. [docs/design.md](./docs/design.md)
|
||||
作用:理解当前 MVP 的产品范围、系统边界、核心对象和整体架构。
|
||||
|
||||
+26
-26
@@ -4,31 +4,31 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
# ATSFlare
|
||||
# OpenFlare
|
||||
|
||||
_✨ control plane for reverse proxy management ✨_
|
||||
|
||||
</div>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/LICENSE">
|
||||
<img src="https://img.shields.io/github/license/Rain-kl/ATSFlare?color=brightgreen" alt="license">
|
||||
<a href="https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/LICENSE">
|
||||
<img src="https://img.shields.io/github/license/Rain-kl/OpenFlare?color=brightgreen" alt="license">
|
||||
</a>
|
||||
<a href="https://github.com/Rain-kl/ATSFlare/releases/latest">
|
||||
<img src="https://img.shields.io/github/v/release/Rain-kl/ATSFlare?color=brightgreen&include_prereleases" alt="release">
|
||||
<a href="https://github.com/Rain-kl/OpenFlare/releases/latest">
|
||||
<img src="https://img.shields.io/github/v/release/Rain-kl/OpenFlare?color=brightgreen&include_prereleases" alt="release">
|
||||
</a>
|
||||
<a href="https://github.com/Rain-kl/ATSFlare/releases/latest">
|
||||
<img src="https://img.shields.io/github/downloads/Rain-kl/ATSFlare/total?color=brightgreen&include_prereleases" alt="release">
|
||||
<a href="https://github.com/Rain-kl/OpenFlare/releases/latest">
|
||||
<img src="https://img.shields.io/github/downloads/Rain-kl/OpenFlare/total?color=brightgreen&include_prereleases" alt="release">
|
||||
</a>
|
||||
<a href="https://goreportcard.com/report/github.com/Rain-kl/ATSFlare">
|
||||
<img src="https://goreportcard.com/badge/github.com/Rain-kl/ATSFlare" alt="GoReportCard">
|
||||
<a href="https://goreportcard.com/report/github.com/Rain-kl/OpenFlare">
|
||||
<img src="https://goreportcard.com/badge/github.com/Rain-kl/OpenFlare" alt="GoReportCard">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## Repository layout
|
||||
|
||||
- `atsf_server`: Gin + GORM + SQLite control plane, including admin API, Agent API and Web UI
|
||||
- `atsf_agent`: single-binary Go Agent for registration, heartbeat, config sync and OpenResty reload
|
||||
- `openflare_server`: Gin + GORM + SQLite control plane, including admin API, Agent API and Web UI
|
||||
- `openflare_agent`: single-binary Go Agent for registration, heartbeat, config sync and OpenResty reload
|
||||
- `docs`: design, development guidelines, implementation plan and deployment docs
|
||||
|
||||
## Quick start
|
||||
@@ -39,21 +39,21 @@ The fastest way is to run the published GHCR image with Docker Compose:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
atsflare:
|
||||
image: ghcr.io/rain-kl/atsflare:latest
|
||||
container_name: atsflare
|
||||
openflare:
|
||||
image: ghcr.io/rain-kl/openflare:latest
|
||||
container_name: openflare
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
SESSION_SECRET: replace-with-random-string
|
||||
SQLITE_PATH: /data/atsflare.db
|
||||
SQLITE_PATH: /data/openflare.db
|
||||
GIN_MODE: release
|
||||
volumes:
|
||||
- atsflare-data:/data
|
||||
- openflare-data:/data
|
||||
|
||||
volumes:
|
||||
atsflare-data:
|
||||
openflare-data:
|
||||
```
|
||||
|
||||
```bash
|
||||
@@ -65,8 +65,8 @@ Default URL: `http://localhost:3000`
|
||||
Notes:
|
||||
|
||||
* Replace `SESSION_SECRET` with a random string
|
||||
* Replace `latest` with a fixed version tag if needed, for example `ghcr.io/rain-kl/atsflare:v0.3.0`
|
||||
* SQLite data is persisted in the Docker volume `atsflare-data`
|
||||
* Replace `latest` with a fixed version tag if needed, for example `ghcr.io/rain-kl/openflare:v0.3.0`
|
||||
* SQLite data is persisted in the Docker volume `openflare-data`
|
||||
* For source build and full deployment steps, see [docs/deployment.md](./docs/deployment.md)
|
||||
|
||||
### 1.1 Server environment variables
|
||||
@@ -88,7 +88,7 @@ Example:
|
||||
|
||||
```bash
|
||||
export SESSION_SECRET='replace-with-random-string'
|
||||
export SQLITE_PATH='./atsflare.db'
|
||||
export SQLITE_PATH='./openflare.db'
|
||||
export GIN_MODE='release'
|
||||
export PORT='3000'
|
||||
```
|
||||
@@ -98,7 +98,7 @@ export PORT='3000'
|
||||
Use this for first-time node bootstrap. The Agent will auto-register with `discovery_token` and exchange it for a node-specific `agent_token`.
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
--server-url http://your-server:3000 \
|
||||
--discovery-token YOUR_DISCOVERY_TOKEN
|
||||
```
|
||||
@@ -108,7 +108,7 @@ curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/insta
|
||||
Use this when the node has already been created in the control plane and you already have a dedicated `agent_token`.
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
--server-url http://your-server:3000 \
|
||||
--agent-token YOUR_AGENT_TOKEN
|
||||
```
|
||||
@@ -116,7 +116,7 @@ curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/insta
|
||||
Notes:
|
||||
|
||||
* Replace `--server-url` with your actual control plane address, for example `http://192.168.1.10:3000`
|
||||
* On Linux, the installer defaults to `/opt/atsflare-agent` and creates the `atsflare-agent` systemd service
|
||||
* On Linux, the installer defaults to `/opt/openflare-agent` and creates the `openflare-agent` systemd service
|
||||
* Re-running the same command upgrades the Agent to the latest release
|
||||
|
||||
## Delivery channels
|
||||
@@ -124,7 +124,7 @@ Notes:
|
||||
Current release outputs:
|
||||
|
||||
* Server binaries: GitHub Releases
|
||||
* Server Docker image: GitHub Container Registry at `ghcr.io/rain-kl/atsflare`
|
||||
* Server Docker image: GitHub Container Registry at `ghcr.io/rain-kl/openflare`
|
||||
* Agent binaries: GitHub Releases
|
||||
|
||||
## Documentation
|
||||
@@ -138,6 +138,6 @@ See:
|
||||
|
||||
Frontend notes:
|
||||
|
||||
* The new admin frontend lives in `atsf_server/web`
|
||||
* The new admin frontend lives in `openflare_server/web`
|
||||
* `pnpm` is the default package manager
|
||||
* `pnpm build` exports static assets into `atsf_server/web/build`
|
||||
* `pnpm build` exports static assets into `openflare_server/web/build`
|
||||
@@ -3,32 +3,32 @@
|
||||
</p>
|
||||
|
||||
<div align="center">
|
||||
<img src="./atsf_server/web/public/logo.png" width="120" height="120" alt="ATSFlare logo">
|
||||
<img src="./openflare_server/web/public/logo.png" width="120" height="120" alt="OpenFlare logo">
|
||||
|
||||
# ATSFlare
|
||||
# OpenFlare
|
||||
|
||||
轻量、自托管的反向代理控制面,用于管理 Nginx 配置发布、节点同步、TLS 证书与版本回滚。
|
||||
|
||||
</div>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/LICENSE">
|
||||
<img src="https://img.shields.io/github/license/Rain-kl/ATSFlare?color=brightgreen" alt="license">
|
||||
<a href="https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/LICENSE">
|
||||
<img src="https://img.shields.io/github/license/Rain-kl/OpenFlare?color=brightgreen" alt="license">
|
||||
</a>
|
||||
<a href="https://github.com/Rain-kl/ATSFlare/releases/latest">
|
||||
<img src="https://img.shields.io/github/v/release/Rain-kl/ATSFlare?color=brightgreen&include_prereleases" alt="release">
|
||||
<a href="https://github.com/Rain-kl/OpenFlare/releases/latest">
|
||||
<img src="https://img.shields.io/github/v/release/Rain-kl/OpenFlare?color=brightgreen&include_prereleases" alt="release">
|
||||
</a>
|
||||
<a href="https://github.com/Rain-kl/ATSFlare/pkgs/container/atsflare">
|
||||
<img src="https://img.shields.io/badge/GHCR-ghcr.io%2Frain--kl%2Fatsflare-brightgreen" alt="ghcr">
|
||||
<a href="https://github.com/Rain-kl/OpenFlare/pkgs/container/openflare">
|
||||
<img src="https://img.shields.io/badge/GHCR-ghcr.io%2Frain--kl%2Fopenflare-brightgreen" alt="ghcr">
|
||||
</a>
|
||||
<a href="https://goreportcard.com/report/github.com/Rain-kl/ATSFlare">
|
||||
<img src="https://goreportcard.com/badge/github.com/Rain-kl/ATSFlare" alt="GoReportCard">
|
||||
<a href="https://goreportcard.com/report/github.com/Rain-kl/OpenFlare">
|
||||
<img src="https://goreportcard.com/badge/github.com/Rain-kl/OpenFlare" alt="GoReportCard">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## 项目定位
|
||||
|
||||
ATSFlare 当前定位为内部自用的反向代理控制面,不面向外部租户提供 CDN SaaS 能力。
|
||||
OpenFlare 当前定位为内部自用的反向代理控制面,不面向外部租户提供 CDN SaaS 能力。
|
||||
|
||||
它解决的是一套更直接的运维问题:
|
||||
|
||||
@@ -61,24 +61,24 @@ ATSFlare 当前定位为内部自用的反向代理控制面,不面向外部
|
||||
|
||||
### 仪表盘总览
|
||||
|
||||

|
||||

|
||||
|
||||
### 节点详情与安装命令
|
||||
|
||||

|
||||

|
||||
|
||||
### 配置发布与版本管理
|
||||
|
||||

|
||||

|
||||
|
||||
## 系统架构
|
||||
|
||||
```text
|
||||
ATSFlare Server (Gin + GORM + SQLite + Web UI)
|
||||
OpenFlare Server (Gin + GORM + SQLite + Web UI)
|
||||
|
|
||||
| HTTP API / Config Pull
|
||||
v
|
||||
ATSFlare Agent (register / heartbeat / sync / apply / update)
|
||||
OpenFlare Agent (register / heartbeat / sync / apply / update)
|
||||
|
|
||||
v
|
||||
Local Nginx or Docker Nginx
|
||||
@@ -89,15 +89,15 @@ Origin
|
||||
|
||||
职责划分:
|
||||
|
||||
* `atsf_server`:管理端 UI、管理 API、Agent API、配置渲染、发布与激活、状态存储
|
||||
* `atsf_agent`:节点注册、心跳、同步、本地文件写入、Nginx 校验、reload、回滚、自更新
|
||||
* `atsf_server/web`:新版管理端前端,静态导出后由 Go Server 托管
|
||||
* `openflare_server`:管理端 UI、管理 API、Agent API、配置渲染、发布与激活、状态存储
|
||||
* `openflare_agent`:节点注册、心跳、同步、本地文件写入、Nginx 校验、reload、回滚、自更新
|
||||
* `openflare_server/web`:新版管理端前端,静态导出后由 Go Server 托管
|
||||
|
||||
## 仓库结构
|
||||
|
||||
* `atsf_server`:Gin + GORM + SQLite 单体控制面
|
||||
* `atsf_server/web`:Next.js 15 App Router 管理端前端
|
||||
* `atsf_agent`:Go 单体 Agent
|
||||
* `openflare_server`:Gin + GORM + SQLite 单体控制面
|
||||
* `openflare_server/web`:Next.js 15 App Router 管理端前端
|
||||
* `openflare_agent`:Go 单体 Agent
|
||||
* `scripts`:安装脚本与辅助脚本
|
||||
* `docs`:设计、开发规范、部署、配置项等文档
|
||||
|
||||
@@ -107,22 +107,22 @@ Origin
|
||||
|
||||
```yaml
|
||||
services:
|
||||
atsflare:
|
||||
image: ghcr.io/rain-kl/atsflare:latest
|
||||
openflare:
|
||||
image: ghcr.io/rain-kl/openflare:latest
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
SESSION_SECRET: replace-with-random-string
|
||||
SQLITE_PATH: /data/atsflare.db
|
||||
SQLITE_PATH: /data/openflare.db
|
||||
GIN_MODE: release
|
||||
LOG_LEVEL: info
|
||||
PORT: "3000"
|
||||
volumes:
|
||||
- atsflare-data:/data
|
||||
- openflare-data:/data
|
||||
|
||||
volumes:
|
||||
atsflare-data:
|
||||
openflare-data:
|
||||
```
|
||||
|
||||
```bash
|
||||
@@ -141,7 +141,7 @@ docker compose up -d
|
||||
适用于新节点首次接入,Agent 会自动注册并换取节点专属 `agent_token`。
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
--server-url http://your-server:3000 \
|
||||
--discovery-token YOUR_DISCOVERY_TOKEN
|
||||
```
|
||||
@@ -151,7 +151,7 @@ curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/insta
|
||||
适用于已经在管理端预创建节点、并拿到节点专属 `agent_token` 的场景。
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
--server-url http://your-server:3000 \
|
||||
--agent-token YOUR_AGENT_TOKEN
|
||||
```
|
||||
@@ -159,8 +159,8 @@ curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/insta
|
||||
说明:
|
||||
|
||||
* `--server-url` 替换为实际控制面地址,例如 `http://192.168.1.10:3000`
|
||||
* 默认安装目录为 `/opt/atsflare-agent`
|
||||
* 脚本会创建 `atsflare-agent.service` 并启动 systemd 服务
|
||||
* 默认安装目录为 `/opt/openflare-agent`
|
||||
* 脚本会创建 `openflare-agent.service` 并启动 systemd 服务
|
||||
* 重复执行安装命令可用于重装或升级 Agent 到最新 Release
|
||||
* 重装时会先删除整个安装目录,再重新生成 `agent.json`、本地状态和二进制;旧数据不会保留
|
||||
|
||||
@@ -182,10 +182,10 @@ curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/insta
|
||||
当前仓库的交付形式:
|
||||
|
||||
* Server 二进制发布到 GitHub Releases
|
||||
* Server Docker 镜像发布到 GitHub Container Registry:`ghcr.io/rain-kl/atsflare`
|
||||
* Server Docker 镜像发布到 GitHub Container Registry:`ghcr.io/rain-kl/openflare`
|
||||
* Agent 二进制发布到 GitHub Releases
|
||||
|
||||
Docker 镜像工作流仅构建 `atsf_server`,并产出 `linux/amd64` 与 `linux/arm64` 多架构镜像。
|
||||
Docker 镜像工作流仅构建 `openflare_server`,并产出 `linux/amd64` 与 `linux/arm64` 多架构镜像。
|
||||
|
||||
## 常用配置
|
||||
|
||||
@@ -196,7 +196,7 @@ Docker 镜像工作流仅构建 `atsf_server`,并产出 `linux/amd64` 与 `lin
|
||||
| `PORT` | Server 监听端口 | `3000` |
|
||||
| `GIN_MODE` | Gin 运行模式 | 非 `debug` 时按 release |
|
||||
| `SESSION_SECRET` | Session 签名密钥 | 启动时随机生成 |
|
||||
| `SQLITE_PATH` | SQLite 数据库文件路径 | `atsflare.db` |
|
||||
| `SQLITE_PATH` | SQLite 数据库文件路径 | `openflare.db` |
|
||||
| `SQL_DSN` | MySQL DSN,设置后优先于 SQLite | 空 |
|
||||
| `UPLOAD_PATH` | 上传目录 | `upload` |
|
||||
|
||||
@@ -230,16 +230,16 @@ Docker 镜像工作流仅构建 `atsf_server`,并产出 `linux/amd64` 与 `lin
|
||||
### Server
|
||||
|
||||
```bash
|
||||
cd atsf_server
|
||||
cd openflare_server
|
||||
export SESSION_SECRET='replace-with-random-string'
|
||||
export SQLITE_PATH='./atsflare.db'
|
||||
export SQLITE_PATH='./openflare.db'
|
||||
go run .
|
||||
```
|
||||
|
||||
### Frontend
|
||||
|
||||
```bash
|
||||
cd atsf_server/web
|
||||
cd openflare_server/web
|
||||
corepack enable
|
||||
pnpm install
|
||||
pnpm build
|
||||
@@ -248,20 +248,20 @@ pnpm build
|
||||
### Agent
|
||||
|
||||
```bash
|
||||
cd atsf_agent
|
||||
cd openflare_agent
|
||||
go run ./cmd/agent -config /path/to/agent.json
|
||||
```
|
||||
|
||||
### 常用验证命令
|
||||
|
||||
```bash
|
||||
cd atsf_server
|
||||
GOCACHE=/tmp/atsflare-go-cache go test ./...
|
||||
cd openflare_server
|
||||
GOCACHE=/tmp/openflare-go-cache go test ./...
|
||||
```
|
||||
|
||||
```bash
|
||||
cd atsf_agent
|
||||
GOCACHE=/tmp/atsflare-go-cache go test ./...
|
||||
cd openflare_agent
|
||||
GOCACHE=/tmp/openflare-go-cache go test ./...
|
||||
```
|
||||
|
||||
## 文档导航
|
||||
@@ -304,5 +304,5 @@ GOCACHE=/tmp/atsflare-go-cache go test ./...
|
||||
|
||||
* 超出设计边界的改动,先更新设计文档再编码
|
||||
* Server 继续保持单体结构,不为简单需求引入额外基础设施
|
||||
* 前端统一位于 `atsf_server/web`,请求层统一收敛到 `lib/api/`
|
||||
* 前端统一位于 `openflare_server/web`,请求层统一收敛到 `lib/api/`
|
||||
* 新代码默认遵循当前正式基线,不回退到旧版 CRA / Semantic UI 结构
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
module atsflare-agent
|
||||
|
||||
go 1.23.0
|
||||
@@ -1,131 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import type { EChartsOption } from 'echarts';
|
||||
import ReactECharts from 'echarts-for-react';
|
||||
|
||||
type RankChartItem = {
|
||||
label: string;
|
||||
value: number;
|
||||
};
|
||||
|
||||
type RankChartProps = {
|
||||
items: RankChartItem[];
|
||||
color: string;
|
||||
valueFormatter?: (value: number) => string;
|
||||
emptyMessage?: string;
|
||||
};
|
||||
|
||||
const defaultFormatter = (value: number) => value.toLocaleString('zh-CN');
|
||||
|
||||
function getChartValue(params: unknown) {
|
||||
if (typeof params !== 'object' || params === null || !('value' in params)) {
|
||||
return 0;
|
||||
}
|
||||
const rawValue = (params as { value?: unknown }).value;
|
||||
if (Array.isArray(rawValue)) {
|
||||
const candidate = rawValue[0];
|
||||
return typeof candidate === 'number' ? candidate : 0;
|
||||
}
|
||||
return typeof rawValue === 'number' ? rawValue : 0;
|
||||
}
|
||||
|
||||
export function RankChart({
|
||||
items,
|
||||
color,
|
||||
valueFormatter = defaultFormatter,
|
||||
emptyMessage = '暂无分布数据',
|
||||
}: RankChartProps) {
|
||||
const option = useMemo<EChartsOption>(
|
||||
() => ({
|
||||
animationDuration: 400,
|
||||
grid: {
|
||||
left: 16,
|
||||
right: 24,
|
||||
top: 12,
|
||||
bottom: 12,
|
||||
containLabel: true,
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow',
|
||||
},
|
||||
backgroundColor: 'rgba(15, 23, 42, 0.92)',
|
||||
borderWidth: 0,
|
||||
textStyle: {
|
||||
color: '#e2e8f0',
|
||||
fontSize: 12,
|
||||
},
|
||||
formatter: (params: unknown) => {
|
||||
const item = Array.isArray(params) ? params[0] : params;
|
||||
const data = item as { name?: string; value?: number };
|
||||
return `${data.name ?? ''}<br/>${valueFormatter(data.value ?? 0)}`;
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
axisLabel: {
|
||||
color: '#94a3b8',
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: 'rgba(148, 163, 184, 0.16)',
|
||||
type: 'dashed',
|
||||
},
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: items.map((item) => item.label),
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
axisLabel: {
|
||||
color: '#cbd5e1',
|
||||
width: 120,
|
||||
overflow: 'truncate',
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
data: items.map((item) => item.value),
|
||||
barWidth: 12,
|
||||
showBackground: true,
|
||||
backgroundStyle: {
|
||||
color: 'rgba(148, 163, 184, 0.12)',
|
||||
borderRadius: 999,
|
||||
},
|
||||
itemStyle: {
|
||||
color,
|
||||
borderRadius: 999,
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
position: 'right',
|
||||
color: '#e2e8f0',
|
||||
formatter: (params: unknown) => valueFormatter(getChartValue(params)),
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
[color, items, valueFormatter],
|
||||
);
|
||||
|
||||
if (items.length === 0) {
|
||||
return (
|
||||
<div className="flex h-[220px] items-center justify-center rounded-3xl border border-dashed border-[var(--border-default)] bg-[var(--surface-muted)] text-sm text-[var(--foreground-secondary)]">
|
||||
{emptyMessage}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ReactECharts
|
||||
option={option}
|
||||
notMerge
|
||||
lazyUpdate
|
||||
style={{ height: Math.max(220, items.length * 44), width: '100%' }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import type { EChartsOption } from 'echarts';
|
||||
import ReactECharts from 'echarts-for-react';
|
||||
|
||||
import { calculateNiceAxisMax, formatCompactNumber } from '@/lib/utils/metrics';
|
||||
|
||||
type TrendChartSeries = {
|
||||
label: string;
|
||||
color: string;
|
||||
fillColor?: string;
|
||||
values: number[];
|
||||
variant?: 'line' | 'area';
|
||||
valueFormatter?: (value: number) => string;
|
||||
};
|
||||
|
||||
type TrendChartProps = {
|
||||
labels: string[];
|
||||
series: TrendChartSeries[];
|
||||
height?: number;
|
||||
yAxisValueFormatter?: (value: number) => string;
|
||||
};
|
||||
|
||||
type TooltipParam = {
|
||||
axisValueLabel?: string;
|
||||
color?: string;
|
||||
seriesName?: string;
|
||||
value?: number | string | Array<number | string>;
|
||||
};
|
||||
|
||||
const defaultFormatter = (value: number) => formatCompactNumber(value);
|
||||
|
||||
export function TrendChart({
|
||||
labels,
|
||||
series,
|
||||
height = 220,
|
||||
yAxisValueFormatter,
|
||||
}: TrendChartProps) {
|
||||
const option = useMemo<EChartsOption>(() => {
|
||||
const axisFormatter = yAxisValueFormatter ?? defaultFormatter;
|
||||
const maxValue = calculateNiceAxisMax(
|
||||
series.flatMap((item) => item.values),
|
||||
);
|
||||
|
||||
return {
|
||||
animationDuration: 500,
|
||||
animationEasing: 'cubicOut',
|
||||
grid: {
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 20,
|
||||
bottom: 20,
|
||||
containLabel: true,
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
backgroundColor: 'rgba(15, 23, 42, 0.92)',
|
||||
borderWidth: 0,
|
||||
textStyle: {
|
||||
color: '#e2e8f0',
|
||||
fontSize: 12,
|
||||
},
|
||||
formatter: (params: unknown) => {
|
||||
const items = Array.isArray(params) ? (params as TooltipParam[]) : [];
|
||||
if (items.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const header = items[0]?.axisValueLabel ?? '';
|
||||
const rows = items.map((item) => {
|
||||
const matchedSeries = series.find(
|
||||
(seriesItem) => seriesItem.label === item.seriesName,
|
||||
);
|
||||
const formatter =
|
||||
matchedSeries?.valueFormatter ??
|
||||
yAxisValueFormatter ??
|
||||
defaultFormatter;
|
||||
const rawValue = Array.isArray(item.value)
|
||||
? item.value[1]
|
||||
: item.value;
|
||||
const numericValue =
|
||||
typeof rawValue === 'number' ? rawValue : Number(rawValue ?? 0);
|
||||
|
||||
return [
|
||||
'<span style="display:inline-flex;align-items:center;gap:8px;">',
|
||||
`<span style="display:inline-block;width:8px;height:8px;border-radius:9999px;background:${item.color ?? '#94a3b8'};"></span>`,
|
||||
`<span>${item.seriesName ?? ''}</span>`,
|
||||
`<strong style="margin-left:8px;">${formatter(numericValue)}</strong>`,
|
||||
'</span>',
|
||||
].join('');
|
||||
});
|
||||
|
||||
return [header, ...rows].join('<br/>');
|
||||
},
|
||||
},
|
||||
legend: {
|
||||
show: false,
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: labels,
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: 'rgba(148, 163, 184, 0.24)',
|
||||
},
|
||||
},
|
||||
axisTick: {
|
||||
show: false,
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#94a3b8',
|
||||
margin: 14,
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
min: 0,
|
||||
max: maxValue,
|
||||
splitNumber: 4,
|
||||
axisLabel: {
|
||||
color: '#94a3b8',
|
||||
formatter: (value: number) => axisFormatter(value),
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: 'rgba(148, 163, 184, 0.16)',
|
||||
type: 'dashed',
|
||||
},
|
||||
},
|
||||
},
|
||||
series: series.map((item) => ({
|
||||
name: item.label,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
showSymbol: false,
|
||||
symbol: 'circle',
|
||||
symbolSize: 8,
|
||||
lineStyle: {
|
||||
color: item.color,
|
||||
width: 3,
|
||||
},
|
||||
itemStyle: {
|
||||
color: item.color,
|
||||
},
|
||||
areaStyle:
|
||||
item.variant === 'area'
|
||||
? {
|
||||
color: item.fillColor ?? `${item.color}33`,
|
||||
}
|
||||
: undefined,
|
||||
emphasis: {
|
||||
focus: 'series',
|
||||
scale: true,
|
||||
},
|
||||
data: item.values,
|
||||
})),
|
||||
};
|
||||
}, [labels, series, yAxisValueFormatter]);
|
||||
|
||||
if (labels.length === 0 || series.length === 0) {
|
||||
return (
|
||||
<div className="flex h-[220px] items-center justify-center rounded-3xl border border-dashed border-[var(--border-default)] bg-[var(--surface-muted)] text-sm text-[var(--foreground-secondary)]">
|
||||
暂无趋势数据
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{series.map((item) => {
|
||||
const latestValue = item.values[item.values.length - 1] ?? 0;
|
||||
const formatter = item.valueFormatter ?? defaultFormatter;
|
||||
return (
|
||||
<div
|
||||
key={item.label}
|
||||
className="min-w-[140px] rounded-2xl border border-[var(--border-default)] bg-[var(--surface-elevated)] px-4 py-3"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<span
|
||||
className="h-2.5 w-2.5 rounded-full"
|
||||
style={{ backgroundColor: item.color }}
|
||||
/>
|
||||
<p className="text-xs tracking-[0.18em] text-[var(--foreground-muted)] uppercase">
|
||||
{item.label}
|
||||
</p>
|
||||
</div>
|
||||
<p className="mt-2 text-lg font-semibold text-[var(--foreground-primary)]">
|
||||
{formatter(latestValue)}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="overflow-hidden rounded-[28px] border border-[var(--border-default)] bg-[linear-gradient(180deg,rgba(255,255,255,0.03),rgba(255,255,255,0))] px-4 py-4">
|
||||
<ReactECharts
|
||||
option={option}
|
||||
notMerge
|
||||
lazyUpdate
|
||||
style={{ height, width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
+34
-34
@@ -1,6 +1,6 @@
|
||||
# ATSFlare 配置项说明
|
||||
# OpenFlare 配置项说明
|
||||
|
||||
本文档汇总当前 ATSFlare Server 与 Agent 在启动、部署和运行时支持的参数、环境变量与配置文件字段,并说明其作用、默认值和示例。
|
||||
本文档汇总当前 OpenFlare Server 与 Agent 在启动、部署和运行时支持的参数、环境变量与配置文件字段,并说明其作用、默认值和示例。
|
||||
|
||||
---
|
||||
|
||||
@@ -20,14 +20,14 @@ Server 当前支持两类启动配置:
|
||||
启动示例:
|
||||
|
||||
```bash
|
||||
cd atsf_server
|
||||
cd openflare_server
|
||||
go run . --port 3000 --log-dir ./logs
|
||||
```
|
||||
|
||||
或在编译后二进制中使用:
|
||||
|
||||
```bash
|
||||
./atsflare --port 3000 --log-dir ./logs
|
||||
./openflare --port 3000 --log-dir ./logs
|
||||
```
|
||||
|
||||
支持的命令行参数:
|
||||
@@ -36,8 +36,8 @@ go run . --port 3000 --log-dir ./logs
|
||||
| --- | --- | --- | --- |
|
||||
| `--port` | 指定 Server 监听端口 | `3000` | `--port 3000` |
|
||||
| `--log-dir` | 指定日志目录;设置后会自动创建目录并写入日志 | 空,默认输出到 stdout | `--log-dir ./logs` |
|
||||
| `--version` | 输出当前版本后退出 | `false` | `./atsflare --version` |
|
||||
| `--help` | 输出帮助信息后退出 | `false` | `./atsflare --help` |
|
||||
| `--version` | 输出当前版本后退出 | `false` | `./openflare --version` |
|
||||
| `--help` | 输出帮助信息后退出 | `false` | `./openflare --help` |
|
||||
|
||||
说明:
|
||||
|
||||
@@ -49,9 +49,9 @@ go run . --port 3000 --log-dir ./logs
|
||||
源码启动示例:
|
||||
|
||||
```bash
|
||||
cd atsf_server
|
||||
cd openflare_server
|
||||
export SESSION_SECRET='replace-with-random-string'
|
||||
export SQLITE_PATH='./atsflare.db'
|
||||
export SQLITE_PATH='./openflare.db'
|
||||
export GIN_MODE='release'
|
||||
export LOG_LEVEL='info'
|
||||
export PORT='3000'
|
||||
@@ -62,22 +62,22 @@ Docker Compose 示例:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
atsflare:
|
||||
image: ghcr.io/rain-kl/atsflare:latest
|
||||
openflare:
|
||||
image: ghcr.io/rain-kl/openflare:latest
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
SESSION_SECRET: replace-with-random-string
|
||||
SQLITE_PATH: /data/atsflare.db
|
||||
SQLITE_PATH: /data/openflare.db
|
||||
GIN_MODE: release
|
||||
LOG_LEVEL: info
|
||||
PORT: "3000"
|
||||
volumes:
|
||||
- atsflare-data:/data
|
||||
- openflare-data:/data
|
||||
|
||||
volumes:
|
||||
atsflare-data:
|
||||
openflare-data:
|
||||
```
|
||||
|
||||
支持的环境变量:
|
||||
@@ -88,8 +88,8 @@ volumes:
|
||||
| `GIN_MODE` | 指定 Gin 运行模式;仅当值为 `debug` 时启用 debug,其余情况按 release 运行 | 非 `debug` 默认按 release 运行 | `GIN_MODE=release` |
|
||||
| `LOG_LEVEL` | 指定系统日志等级;支持 `debug`/`info`/`warn`/`error`(`warning` 兼容为 `warn`) | `info` | `LOG_LEVEL=warn` |
|
||||
| `SESSION_SECRET` | Session 签名密钥;生产环境必须显式设置,避免重启后会话失效 | 启动时随机生成 UUID | `SESSION_SECRET=replace-with-random-string` |
|
||||
| `SQLITE_PATH` | SQLite 数据库文件路径 | `atsflare.db` | `SQLITE_PATH=/data/atsflare.db` |
|
||||
| `SQL_DSN` | MySQL DSN;设置后优先使用 MySQL,而不是 SQLite | 未设置时使用 SQLite | `SQL_DSN=user:pass@tcp(127.0.0.1:3306)/atsflare` |
|
||||
| `SQLITE_PATH` | SQLite 数据库文件路径 | `openflare.db` | `SQLITE_PATH=/data/openflare.db` |
|
||||
| `SQL_DSN` | MySQL DSN;设置后优先使用 MySQL,而不是 SQLite | 未设置时使用 SQLite | `SQL_DSN=user:pass@tcp(127.0.0.1:3306)/openflare` |
|
||||
| `REDIS_CONN_STRING` | Redis 连接串;设置后启用 Redis,用于 Session/限流相关能力 | 未设置时关闭 Redis | `REDIS_CONN_STRING=redis://default:pass@127.0.0.1:6379/0` |
|
||||
| `UPLOAD_PATH` | 上传文件目录 | `upload` | `UPLOAD_PATH=/data/upload` |
|
||||
| `AGENT_TOKEN` | 全局 Agent Token 兼容配置;当前默认部署不依赖该变量 | 空 | `AGENT_TOKEN=legacy-shared-token` |
|
||||
@@ -110,7 +110,7 @@ volumes:
|
||||
| --- | --- | --- |
|
||||
| `AgentHeartbeatInterval` | Agent 心跳间隔(毫秒) | `10000` |
|
||||
| `NodeOfflineThreshold` | 节点离线判定阈值(毫秒) | `120000` |
|
||||
| `AgentUpdateRepo` | Agent 自更新仓库 | `Rain-kl/ATSFlare` |
|
||||
| `AgentUpdateRepo` | Agent 自更新仓库 | `Rain-kl/OpenFlare` |
|
||||
| `GeoIPProvider` | 节点/IP 归属解析方式;支持 `disabled`、`mmdb`、`ip-api`、`geojs`、`ipinfo` | `ipinfo` |
|
||||
| `GlobalApiRateLimitNum` / `GlobalApiRateLimitDuration` | 全局 API 限流次数 / 时间窗口(秒) | `300` / `180` |
|
||||
| `GlobalWebRateLimitNum` / `GlobalWebRateLimitDuration` | 全局 Web 限流次数 / 时间窗口(秒) | `300` / `180` |
|
||||
@@ -172,7 +172,7 @@ volumes:
|
||||
|
||||
### 1.3 前端构建环境变量
|
||||
|
||||
新版管理端位于 `atsf_server/web`,构建时支持以下公开环境变量:
|
||||
新版管理端位于 `openflare_server/web`,构建时支持以下公开环境变量:
|
||||
|
||||
| 环境变量 | 作用 | 默认值 | 示例 |
|
||||
| --- | --- | --- | --- |
|
||||
@@ -216,21 +216,21 @@ Agent 当前支持两类启动配置:
|
||||
启动示例:
|
||||
|
||||
```bash
|
||||
cd atsf_agent
|
||||
cd openflare_agent
|
||||
go run ./cmd/agent -config ./agent.json
|
||||
```
|
||||
|
||||
或编译后二进制:
|
||||
|
||||
```bash
|
||||
./atsflare-agent -config /path/to/agent.json
|
||||
./openflare-agent -config /path/to/agent.json
|
||||
```
|
||||
|
||||
支持的命令行参数:
|
||||
|
||||
| 参数 | 作用 | 默认值 | 示例 |
|
||||
| --- | --- | --- | --- |
|
||||
| `-config` | 指定 Agent 配置文件路径 | `./agent.json` | `-config /etc/atsflare/agent.json` |
|
||||
| `-config` | 指定 Agent 配置文件路径 | `./agent.json` | `-config /etc/openflare/agent.json` |
|
||||
|
||||
### 2.2 Agent 配置文件示例
|
||||
|
||||
@@ -241,7 +241,7 @@ go run ./cmd/agent -config ./agent.json
|
||||
"server_url": "http://127.0.0.1:3000",
|
||||
"discovery_token": "replace-with-global-discovery-token",
|
||||
"data_dir": "./data",
|
||||
"openresty_container_name": "atsflare-openresty",
|
||||
"openresty_container_name": "openflare-openresty",
|
||||
"openresty_docker_image": "openresty/openresty:alpine",
|
||||
"openresty_observability_port": 18081,
|
||||
"observability_replay_minutes": 15,
|
||||
@@ -261,7 +261,7 @@ go run ./cmd/agent -config ./agent.json
|
||||
"data_dir": "./data",
|
||||
"openresty_path": "/usr/local/openresty/nginx/sbin/openresty",
|
||||
"main_config_path": "/usr/local/openresty/nginx/conf/nginx.conf",
|
||||
"route_config_path": "/usr/local/openresty/nginx/conf/conf.d/atsflare_routes.conf",
|
||||
"route_config_path": "/usr/local/openresty/nginx/conf/conf.d/openflare_routes.conf",
|
||||
"cert_dir": "/usr/local/openresty/nginx/conf/certs",
|
||||
"openresty_cert_dir": "/usr/local/openresty/nginx/conf/certs",
|
||||
"lua_dir": "/usr/local/openresty/nginx/conf/lua",
|
||||
@@ -285,18 +285,18 @@ go run ./cmd/agent -config ./agent.json
|
||||
| `node_name` | 节点名称 | 否 | 自动使用主机名 | `node-01` |
|
||||
| `node_ip` | 节点 IP | 否 | 自动探测第一个可用 IPv4 | `192.168.1.20` |
|
||||
| `openresty_path` | 本机 OpenResty 可执行文件路径;设置后按本机 OpenResty 模式运行 | 否 | 空;未设置时按 Docker OpenResty 模式处理 | `/usr/local/openresty/nginx/sbin/openresty` |
|
||||
| `openresty_container_name` | Docker 模式下的 OpenResty 容器名 | 否 | `atsflare-openresty` | `atsflare-openresty` |
|
||||
| `openresty_container_name` | Docker 模式下的 OpenResty 容器名 | 否 | `openflare-openresty` | `openflare-openresty` |
|
||||
| `openresty_docker_image` | Docker 模式下用于初始化/管理的 OpenResty 镜像 | 否 | `openresty/openresty:alpine` | `openresty/openresty:alpine` |
|
||||
| `openresty_observability_port` | Agent 注入的 OpenResty 本地观测端口;用于 heartbeat 前读取 Lua 窗口指标和 `stub_status`,默认仅监听 `127.0.0.1` | 否 | `18081` | `18081` |
|
||||
| `docker_binary` | Docker 可执行文件名或路径 | 否 | `docker` | `/usr/bin/docker` |
|
||||
| `data_dir` | Agent 数据目录,用于存储托管配置、证书和状态文件 | 否 | 配置文件所在目录下的 `data` 子目录 | `./data` |
|
||||
| `main_config_path` | 第五版主配置接管时 OpenResty 主配置文件写入路径 | 第五版本机模式建议必填 | Docker 模式可使用受管默认路径;本机模式建议显式设置 | `/usr/local/openresty/nginx/conf/nginx.conf` |
|
||||
| `route_config_path` | 路由配置文件写入路径 | 否 | 默认为 `data_dir` 下托管路径 | `/etc/nginx/conf.d/atsflare_routes.conf` |
|
||||
| `route_config_path` | 路由配置文件写入路径 | 否 | 默认为 `data_dir` 下托管路径 | `/etc/nginx/conf.d/openflare_routes.conf` |
|
||||
| `cert_dir` | Agent 在本机写入受管证书文件的目录 | 否 | 默认为 `data_dir` 下托管 certs 目录 | `./data/etc/nginx/certs` |
|
||||
| `openresty_cert_dir` | OpenResty 实际读取受管证书文件的目录 | 否 | 本机模式默认等于 `cert_dir`;Docker 模式默认 `/etc/nginx/atsflare-certs` | `/usr/local/openresty/nginx/conf/certs` |
|
||||
| `openresty_cert_dir` | OpenResty 实际读取受管证书文件的目录 | 否 | 本机模式默认等于 `cert_dir`;Docker 模式默认 `/etc/nginx/openflare-certs` | `/usr/local/openresty/nginx/conf/certs` |
|
||||
| `lua_dir` | Agent 在本机写入受管 Lua 观测脚本的目录;每次启动都会覆盖释放 | 否 | 默认为 `data_dir` 下托管 lua 目录 | `./data/etc/nginx/lua` |
|
||||
| `openresty_lua_dir` | OpenResty 实际读取受管 Lua 观测脚本的目录 | 否 | 本机模式默认等于 `lua_dir`;Docker 模式默认 `/etc/nginx/atsflare-lua` | `/usr/local/openresty/nginx/conf/lua` |
|
||||
| `observability_buffer_path` | Agent 本地观测补报缓冲文件路径;用于在 server 短暂离线时按时间窗口落盘待补传数据 | 否 | 默认为 `data_dir` 下托管观测缓冲文件 | `./data/var/lib/atsflare/observability-buffer.json` |
|
||||
| `openresty_lua_dir` | OpenResty 实际读取受管 Lua 观测脚本的目录 | 否 | 本机模式默认等于 `lua_dir`;Docker 模式默认 `/etc/nginx/openflare-lua` | `/usr/local/openresty/nginx/conf/lua` |
|
||||
| `observability_buffer_path` | Agent 本地观测补报缓冲文件路径;用于在 server 短暂离线时按时间窗口落盘待补传数据 | 否 | 默认为 `data_dir` 下托管观测缓冲文件 | `./data/var/lib/openflare/observability-buffer.json` |
|
||||
| `observability_replay_minutes` | Agent 恢复心跳后允许批量补传的最近观测窗口时长(分钟) | 否 | `15` | `30` |
|
||||
| `state_path` | Agent 本地状态文件路径 | 否 | 默认为 `data_dir` 下托管状态文件 | `./data/agent-state.json` |
|
||||
| `heartbeat_interval` | 心跳间隔 | 否 | `10000` 毫秒 | `10000` |
|
||||
@@ -322,23 +322,23 @@ go run ./cmd/agent -config ./agent.json
|
||||
| 字段 | 默认值 |
|
||||
| --- | --- |
|
||||
| `main_config_path` | 第五版 Docker 模式默认可落在 `data_dir/etc/nginx/nginx.conf`;本机模式建议显式配置 |
|
||||
| `route_config_path` | `data_dir/etc/nginx/conf.d/atsflare_routes.conf` |
|
||||
| `route_config_path` | `data_dir/etc/nginx/conf.d/openflare_routes.conf` |
|
||||
| `cert_dir` | `data_dir/etc/nginx/certs` |
|
||||
| `lua_dir` | `data_dir/etc/nginx/lua` |
|
||||
| `observability_buffer_path` | `data_dir/var/lib/atsflare/observability-buffer.json` |
|
||||
| `state_path` | `data_dir/var/lib/atsflare/agent-state.json` |
|
||||
| `observability_buffer_path` | `data_dir/var/lib/openflare/observability-buffer.json` |
|
||||
| `state_path` | `data_dir/var/lib/openflare/agent-state.json` |
|
||||
|
||||
Docker OpenResty 模式下:
|
||||
|
||||
| 字段 | 默认值 |
|
||||
| --- | --- |
|
||||
| `openresty_cert_dir` | `/etc/nginx/atsflare-certs` |
|
||||
| `openresty_lua_dir` | `/etc/nginx/atsflare-lua` |
|
||||
| `openresty_cert_dir` | `/etc/nginx/openflare-certs` |
|
||||
| `openresty_lua_dir` | `/etc/nginx/openflare-lua` |
|
||||
|
||||
补充说明:
|
||||
|
||||
* Agent 会在每次启动时把受管 Lua 观测脚本覆盖释放到 `lua_dir`,不再由 Server 随配置版本下发
|
||||
* OpenResty 通过 `openresty_lua_dir` 读取这些本地脚本,并在每次 heartbeat 前通过 `http://127.0.0.1:<openresty_observability_port>/atsflare/observability` 读取最近窗口请求指标
|
||||
* OpenResty 通过 `openresty_lua_dir` 读取这些本地脚本,并在每次 heartbeat 前通过 `http://127.0.0.1:<openresty_observability_port>/openflare/observability` 读取最近窗口请求指标
|
||||
* 若 server 短暂离线,Agent 会把最近窗口观测先写入 `observability_buffer_path`,待 heartbeat 恢复后按时间窗口批量补传最近 `observability_replay_minutes` 分钟的数据
|
||||
* 同一端口还会暴露仅本机可访问的 `stub_status`,用于采集 OpenResty 活动连接数
|
||||
|
||||
@@ -366,7 +366,7 @@ Docker OpenResty 模式下:
|
||||
"agent_token": "replace-with-node-auth-token",
|
||||
"openresty_path": "/usr/local/openresty/nginx/sbin/openresty",
|
||||
"main_config_path": "/usr/local/openresty/nginx/conf/nginx.conf",
|
||||
"route_config_path": "/usr/local/openresty/nginx/conf/conf.d/atsflare_routes.conf",
|
||||
"route_config_path": "/usr/local/openresty/nginx/conf/conf.d/openflare_routes.conf",
|
||||
"cert_dir": "/usr/local/openresty/nginx/conf/certs",
|
||||
"openresty_cert_dir": "/usr/local/openresty/nginx/conf/certs",
|
||||
"lua_dir": "/usr/local/openresty/nginx/conf/lua",
|
||||
|
||||
+49
-49
@@ -1,4 +1,4 @@
|
||||
# ATSFlare 部署说明
|
||||
# OpenFlare 部署说明
|
||||
|
||||
本文档仅保留当前可用基线的最小部署方式,并补充第五版(0.5.x)开发期间与 OpenResty 主配置接管相关的联调约束。
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
### 2.1 构建前端
|
||||
|
||||
```bash
|
||||
cd atsf_server/web
|
||||
cd openflare_server/web
|
||||
corepack enable
|
||||
pnpm install
|
||||
pnpm build
|
||||
@@ -36,7 +36,7 @@ pnpm build
|
||||
说明:
|
||||
|
||||
* 前端使用 Next.js 静态导出模式构建
|
||||
* `pnpm build` 会生成供 Go Server 托管的 `atsf_server/web/build` 目录
|
||||
* `pnpm build` 会生成供 Go Server 托管的 `openflare_server/web/build` 目录
|
||||
* 如需覆盖默认接口地址,可在构建前设置 `NEXT_PUBLIC_API_BASE_URL`
|
||||
|
||||
### 2.1.1 本地前端热更新开发
|
||||
@@ -44,7 +44,7 @@ pnpm build
|
||||
在本地联调时,可单独启动前端开发服务器:
|
||||
|
||||
```bash
|
||||
cd atsf_server/web
|
||||
cd openflare_server/web
|
||||
corepack enable
|
||||
pnpm install
|
||||
pnpm dev
|
||||
@@ -60,9 +60,9 @@ pnpm dev
|
||||
### 2.2 启动服务
|
||||
|
||||
```bash
|
||||
cd atsf_server
|
||||
cd openflare_server
|
||||
export SESSION_SECRET='replace-with-random-string'
|
||||
export SQLITE_PATH='./atsflare.db'
|
||||
export SQLITE_PATH='./openflare.db'
|
||||
export LOG_LEVEL='info'
|
||||
go run .
|
||||
```
|
||||
@@ -82,21 +82,21 @@ go run .
|
||||
|
||||
```yaml
|
||||
services:
|
||||
atsflare:
|
||||
image: ghcr.io/rain-kl/atsflare:latest
|
||||
container_name: atsflare
|
||||
openflare:
|
||||
image: ghcr.io/rain-kl/openflare:latest
|
||||
container_name: openflare
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
SESSION_SECRET: replace-with-random-string
|
||||
SQLITE_PATH: /data/atsflare.db
|
||||
SQLITE_PATH: /data/openflare.db
|
||||
GIN_MODE: release
|
||||
volumes:
|
||||
- atsflare-data:/data
|
||||
- openflare-data:/data
|
||||
|
||||
volumes:
|
||||
atsflare-data:
|
||||
openflare-data:
|
||||
```
|
||||
|
||||
启动命令:
|
||||
@@ -108,16 +108,16 @@ docker compose up -d
|
||||
说明:
|
||||
|
||||
* `SESSION_SECRET` 必须替换为随机字符串
|
||||
* SQLite 数据文件持久化到 Docker volume `atsflare-data`
|
||||
* SQLite 数据文件持久化到 Docker volume `openflare-data`
|
||||
* 镜像默认监听容器内 `3000` 端口
|
||||
* 若要固定版本,可将 `latest` 替换为具体 tag,例如 `ghcr.io/rain-kl/atsflare:v0.3.0`
|
||||
* 若要固定版本,可将 `latest` 替换为具体 tag,例如 `ghcr.io/rain-kl/openflare:v0.3.0`
|
||||
|
||||
版本升级说明:
|
||||
|
||||
* Root 用户可在管理端顶栏点击「版本」默认检查正式版 GitHub Release
|
||||
* 若需尝试 preview 版本,可在同一弹窗中手动检查 preview 发布并选择是否升级
|
||||
* 当前运行的是 Release 二进制且二进制目录可写时,可直接在弹窗内触发 Server 自升级
|
||||
* Server 自升级会下载匹配当前平台的 `atsflare-server-*` 资产,替换当前二进制并自动重启进程
|
||||
* Server 自升级会下载匹配当前平台的 `openflare-server-*` 资产,替换当前二进制并自动重启进程
|
||||
* 也可在同一弹窗中手动上传 Server 二进制,服务端先检测上传文件版本,前端确认后再执行替换与重启
|
||||
* 节点 Agent 默认仅跟随正式版自动更新;如需 preview 版本,可在节点详情中手动检查 preview 发布并下发更新
|
||||
|
||||
@@ -138,7 +138,7 @@ docker compose up -d
|
||||
|
||||
* Swagger UI 受管理端登录态保护,未登录不可直接访问
|
||||
* 可在浏览器中查看当前 Server API 与 Agent API 定义,并直接发起调试请求
|
||||
* 当 Server API 新增或变更时,需要同步更新 Swag 注解并重新生成 `atsf_server/docs`
|
||||
* 当 Server API 新增或变更时,需要同步更新 Swag 注解并重新生成 `openflare_server/docs`
|
||||
|
||||
如需在本地重新生成 Swagger 文档,先安装 `swag`:
|
||||
|
||||
@@ -151,7 +151,7 @@ go install github.com/swaggo/swag/cmd/swag@latest
|
||||
* Linux / macOS:`$HOME/go/bin`
|
||||
* Windows:`%USERPROFILE%\go\bin`
|
||||
|
||||
如需在本地重新生成 Swagger 文档,可在 `atsf_server` 目录执行:
|
||||
如需在本地重新生成 Swagger 文档,可在 `openflare_server` 目录执行:
|
||||
|
||||
```bash
|
||||
swag init -g main.go -o docs
|
||||
@@ -170,7 +170,7 @@ swag init -g main.go -o docs
|
||||
"server_url": "http://127.0.0.1:3000",
|
||||
"agent_token": "replace-with-node-auth-token",
|
||||
"data_dir": "./data",
|
||||
"openresty_container_name": "atsflare-openresty",
|
||||
"openresty_container_name": "openflare-openresty",
|
||||
"openresty_docker_image": "openresty/openresty:alpine",
|
||||
"openresty_observability_port": 18081,
|
||||
"observability_replay_minutes": 15,
|
||||
@@ -186,7 +186,7 @@ swag init -g main.go -o docs
|
||||
"server_url": "http://127.0.0.1:3000",
|
||||
"discovery_token": "replace-with-global-discovery-token",
|
||||
"data_dir": "./data",
|
||||
"openresty_container_name": "atsflare-openresty",
|
||||
"openresty_container_name": "openflare-openresty",
|
||||
"openresty_docker_image": "openresty/openresty:alpine",
|
||||
"openresty_observability_port": 18081,
|
||||
"observability_replay_minutes": 15,
|
||||
@@ -214,7 +214,7 @@ swag init -g main.go -o docs
|
||||
* 本机 OpenResty 模式需要为 Agent 显式提供主配置文件写入路径
|
||||
* Docker OpenResty 模式需要保证主配置、路由配置和证书目录位于同一套受管挂载路径中
|
||||
* Docker OpenResty 模式会额外挂载一个仅本机可访问的 `127.0.0.1:<openresty_observability_port>` 观测端口,用于 Agent 在 heartbeat 前抓取 Lua 窗口指标
|
||||
* Docker / 本机两种模式都会在 `data_dir/var/lib/atsflare/observability-buffer.json` 保留最近待补传窗口;若节点磁盘是临时盘,重启后该缓冲也会丢失
|
||||
* Docker / 本机两种模式都会在 `data_dir/var/lib/openflare/observability-buffer.json` 保留最近待补传窗口;若节点磁盘是临时盘,重启后该缓冲也会丢失
|
||||
* 节点现存手工维护的主配置如继续保留,必须先迁移为 Server 渲染模板的等价配置,再切换到受管模式
|
||||
* 主配置切换前必须预留回滚副本,并通过一次 `openresty -t` 失败演练验证回滚
|
||||
|
||||
@@ -225,7 +225,7 @@ swag init -g main.go -o docs
|
||||
### 4.1 直接运行
|
||||
|
||||
```bash
|
||||
cd atsf_agent
|
||||
cd openflare_agent
|
||||
export LOG_LEVEL='info'
|
||||
go run ./cmd/agent -config /path/to/agent.json
|
||||
```
|
||||
@@ -233,10 +233,10 @@ go run ./cmd/agent -config /path/to/agent.json
|
||||
### 4.2 编译后二进制运行
|
||||
|
||||
```bash
|
||||
cd atsf_agent
|
||||
go build -o atsflare-agent ./cmd/agent
|
||||
cd openflare_agent
|
||||
go build -o openflare-agent ./cmd/agent
|
||||
export LOG_LEVEL='info'
|
||||
./atsflare-agent -config /path/to/agent.json
|
||||
./openflare-agent -config /path/to/agent.json
|
||||
```
|
||||
|
||||
---
|
||||
@@ -277,7 +277,7 @@ export LOG_LEVEL='info'
|
||||
"server_url": "http://127.0.0.1:3000",
|
||||
"discovery_token": "replace-with-global-discovery-token",
|
||||
"data_dir": "./data",
|
||||
"openresty_container_name": "atsflare-openresty",
|
||||
"openresty_container_name": "openflare-openresty",
|
||||
"openresty_docker_image": "openresty/openresty:alpine",
|
||||
"openresty_observability_port": 18081
|
||||
}
|
||||
@@ -285,24 +285,24 @@ export LOG_LEVEL='info'
|
||||
|
||||
验证点:
|
||||
|
||||
1. 首次启动后确认 `data/etc/nginx/nginx.conf`、`data/etc/nginx/conf.d/atsflare_routes.conf`、`data/etc/nginx/certs` 与 `data/etc/nginx/lua` 已由 Agent 创建
|
||||
1. 首次启动后确认 `data/etc/nginx/nginx.conf`、`data/etc/nginx/conf.d/openflare_routes.conf`、`data/etc/nginx/certs` 与 `data/etc/nginx/lua` 已由 Agent 创建
|
||||
2. 确认容器实际挂载了主配置、路由目录、证书目录和 Lua 目录
|
||||
3. 确认宿主机本地可访问 `http://127.0.0.1:18081/atsflare/observability` 与 `http://127.0.0.1:18081/atsflare/stub_status`
|
||||
3. 确认宿主机本地可访问 `http://127.0.0.1:18081/openflare/observability` 与 `http://127.0.0.1:18081/openflare/stub_status`
|
||||
3. 在管理端发布一次新版本后,确认节点 `current_version` 追平激活版本
|
||||
4. 在节点详情查看“当前目标版本”与“最近应用”,确认主配置/路由配置快照和 checksum 已可见
|
||||
|
||||
推荐检查命令:
|
||||
|
||||
```bash
|
||||
docker inspect atsflare-openresty
|
||||
docker exec atsflare-openresty openresty -t
|
||||
docker inspect openflare-openresty
|
||||
docker exec openflare-openresty openresty -t
|
||||
```
|
||||
|
||||
说明:
|
||||
|
||||
* `docker inspect` 重点确认主配置文件、`conf.d` 目录、证书目录和 Lua 目录都来自 Agent 受管路径
|
||||
* 观测端口默认只绑定 `127.0.0.1`;若节点已有冲突,可在 `agent.json` 中调整 `openresty_observability_port`
|
||||
* 若容器名使用默认值,请将上述命令中的名称替换为 `atsflare-openresty`
|
||||
* 若容器名使用默认值,请将上述命令中的名称替换为 `openflare-openresty`
|
||||
|
||||
### 5.3.2 本机 OpenResty 模式最小验证
|
||||
|
||||
@@ -314,7 +314,7 @@ docker exec atsflare-openresty openresty -t
|
||||
"agent_token": "replace-with-node-auth-token",
|
||||
"openresty_path": "/usr/local/openresty/nginx/sbin/openresty",
|
||||
"main_config_path": "/usr/local/openresty/nginx/conf/nginx.conf",
|
||||
"route_config_path": "/usr/local/openresty/nginx/conf/conf.d/atsflare_routes.conf",
|
||||
"route_config_path": "/usr/local/openresty/nginx/conf/conf.d/openflare_routes.conf",
|
||||
"cert_dir": "/usr/local/openresty/nginx/conf/certs",
|
||||
"openresty_cert_dir": "/usr/local/openresty/nginx/conf/certs",
|
||||
"lua_dir": "/usr/local/openresty/nginx/conf/lua",
|
||||
@@ -327,7 +327,7 @@ docker exec atsflare-openresty openresty -t
|
||||
|
||||
1. 发布前先备份 `main_config_path` 与 `route_config_path`
|
||||
2. 首次发布后执行 `openresty -t`,确认主配置已由 Server 模板接管且 include 指向 Agent 写入的路由文件
|
||||
3. 确认本机可访问 `http://127.0.0.1:18081/atsflare/observability` 与 `http://127.0.0.1:18081/atsflare/stub_status`
|
||||
3. 确认本机可访问 `http://127.0.0.1:18081/openflare/observability` 与 `http://127.0.0.1:18081/openflare/stub_status`
|
||||
4. 再次发布修改后的规则或 OpenResty 参数,确认 `openresty -s reload` 成功且节点版本更新
|
||||
5. 在节点详情与应用记录页确认主配置 checksum、路由配置 checksum 和支持文件数已上报
|
||||
|
||||
@@ -364,7 +364,7 @@ Docker OpenResty 模式:
|
||||
|
||||
1. 在测试节点上保留默认受管路径
|
||||
2. 临时将 `openresty_docker_image` 指向一个不包含 `openresty` 运行时的错误镜像标签,或在测试环境用包装镜像让 `openresty -t` 固定失败
|
||||
3. 再次发布,确认节点应用失败但 `data/etc/nginx/nginx.conf` 与 `data/etc/nginx/conf.d/atsflare_routes.conf` 已回滚为旧版本
|
||||
3. 再次发布,确认节点应用失败但 `data/etc/nginx/nginx.conf` 与 `data/etc/nginx/conf.d/openflare_routes.conf` 已回滚为旧版本
|
||||
4. 恢复正确镜像后重新发布,确认节点恢复健康
|
||||
|
||||
说明:
|
||||
@@ -379,21 +379,21 @@ Docker OpenResty 模式:
|
||||
### 6.1 Server
|
||||
|
||||
```bash
|
||||
cd atsf_server
|
||||
GOCACHE=/tmp/atsflare-go-cache go test ./...
|
||||
cd openflare_server
|
||||
GOCACHE=/tmp/openflare-go-cache go test ./...
|
||||
```
|
||||
|
||||
### 6.2 Agent
|
||||
|
||||
```bash
|
||||
cd atsf_agent
|
||||
GOCACHE=/tmp/atsflare-go-cache go test ./...
|
||||
cd openflare_agent
|
||||
GOCACHE=/tmp/openflare-go-cache go test ./...
|
||||
```
|
||||
|
||||
### 6.3 前端
|
||||
|
||||
```bash
|
||||
cd atsf_server/web
|
||||
cd openflare_server/web
|
||||
pnpm build
|
||||
```
|
||||
|
||||
@@ -406,7 +406,7 @@ pnpm build
|
||||
|
||||
Docker 镜像发布使用 [.github/workflows/docker-image.yml](.github/workflows/docker-image.yml):
|
||||
|
||||
* 仅构建 `atsf_server` 服务端镜像
|
||||
* 仅构建 `openflare_server` 服务端镜像
|
||||
* 发布到 GitHub Container Registry(`ghcr.io/<owner>/<repo>:<tag>`)
|
||||
* 单个工作流通过分架构原生构建再合并 manifest 的方式产出 `linux/amd64` 与 `linux/arm64` 多架构镜像,避免 `arm64` 长时间模拟编译
|
||||
|
||||
@@ -419,7 +419,7 @@ Docker 镜像发布使用 [.github/workflows/docker-image.yml](.github/workflows
|
||||
在目标机器上运行:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
--server-url http://your-server:3000 \
|
||||
--discovery-token YOUR_DISCOVERY_TOKEN
|
||||
```
|
||||
@@ -431,23 +431,23 @@ curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/insta
|
||||
| `--server-url` | Server 地址(必填) | - |
|
||||
| `--discovery-token` | 全局 Discovery Token | - |
|
||||
| `--agent-token` | 节点专属 Token | - |
|
||||
| `--install-dir` | 安装目录 | `/opt/atsflare-agent` |
|
||||
| `--repo` | GitHub Release 仓库 | `Rain-kl/ATSFlare` |
|
||||
| `--install-dir` | 安装目录 | `/opt/openflare-agent` |
|
||||
| `--repo` | GitHub Release 仓库 | `Rain-kl/OpenFlare` |
|
||||
| `--no-service` | 不创建 systemd 服务 | - |
|
||||
|
||||
安装脚本会:
|
||||
|
||||
1. 从 GitHub Releases 下载最新 Agent 二进制(`atsflare-agent-{os}-{arch}`)
|
||||
2. 若检测到已存在安装目录,会先停止运行中的 `atsflare-agent` 服务并删除整个安装目录
|
||||
1. 从 GitHub Releases 下载最新 Agent 二进制(`openflare-agent-{os}-{arch}`)
|
||||
2. 若检测到已存在安装目录,会先停止运行中的 `openflare-agent` 服务并删除整个安装目录
|
||||
3. 先下载到临时文件,再写入全新的安装目录,避免覆盖运行中进程导致写入失败
|
||||
4. 生成 `agent.json` 配置文件
|
||||
5. 创建 systemd 服务 `atsflare-agent.service`
|
||||
5. 创建 systemd 服务 `openflare-agent.service`
|
||||
6. 启动并启用自启
|
||||
|
||||
说明:
|
||||
|
||||
* 脚本可重复执行,用于重装或升级到最新 Release
|
||||
* 若检测到已运行的 `atsflare-agent` systemd 服务,会先停止服务、清空安装目录,再重新安装
|
||||
* 若检测到已运行的 `openflare-agent` systemd 服务,会先停止服务、清空安装目录,再重新安装
|
||||
* 重装会删除旧的 `agent.json`、本地状态、缓存数据和旧二进制,因此节点会按新的 Token 或 Discovery Token 重新接入
|
||||
|
||||
### 7.2 管理端生成部署命令
|
||||
@@ -471,9 +471,9 @@ Agent 自动更新默认为关闭。
|
||||
|
||||
GitHub Release 中的 Agent 二进制命名格式:
|
||||
|
||||
* `atsflare-agent-linux-amd64`
|
||||
* `atsflare-agent-linux-arm64`
|
||||
* `atsflare-agent-darwin-arm64`
|
||||
* `openflare-agent-linux-amd64`
|
||||
* `openflare-agent-linux-arm64`
|
||||
* `openflare-agent-darwin-arm64`
|
||||
|
||||
---
|
||||
|
||||
|
||||
+15
-15
@@ -1,13 +1,13 @@
|
||||
# ATSFlare 设计基线
|
||||
# OpenFlare 设计基线
|
||||
|
||||
## 1. 文档目的
|
||||
|
||||
本文档只保留 ATSFlare 当前有效的产品边界、系统结构与稳定约束。
|
||||
本文档只保留 OpenFlare 当前有效的产品边界、系统结构与稳定约束。
|
||||
|
||||
当前状态:
|
||||
|
||||
* 第一版、第二版、第三版均已完成
|
||||
* 前端改造已完成,`atsf_server/web` 新版工程已成为正式基线
|
||||
* 前端改造已完成,`openflare_server/web` 新版工程已成为正式基线
|
||||
* 第五版(0.5.x)已完成,OpenResty 反代、缓存性能优化与主配置接管已落地
|
||||
* 第六版(0.6.x)已立项,目标聚焦节点流量数据采集、访问分析与数据看板升级
|
||||
* 已完成阶段的实现细节以代码与 Git 历史为准,不再在本文档中维护过程性设计
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
## 2. 产品定位
|
||||
|
||||
ATSFlare 当前定位为内部自用的反向代理控制面,不面向外部租户提供 CDN SaaS 能力。
|
||||
OpenFlare 当前定位为内部自用的反向代理控制面,不面向外部租户提供 CDN SaaS 能力。
|
||||
|
||||
当前核心能力:
|
||||
|
||||
@@ -70,7 +70,7 @@ ATSFlare 当前定位为内部自用的反向代理控制面,不面向外部
|
||||
* 主配置文件由 Server 统一生成并由 Agent 受控落地,不开放节点侧手改后再回传合并
|
||||
* 性能优化参数统一在 Server 配置,不支持按节点分叉不同性能模板
|
||||
* 第五版不开放任意自定义 Nginx/OpenResty 片段上传,不提供任意指令执行入口, 但是需要保留拓展能力, 为后续开放准备
|
||||
* 允许在管理端提供 OpenResty 主配置模板编辑能力,但模板必须保留 ATSFlare 预留占位符,确保性能参数、证书目录与受管路由 include 继续由 Server 统一渲染
|
||||
* 允许在管理端提供 OpenResty 主配置模板编辑能力,但模板必须保留 OpenFlare 预留占位符,确保性能参数、证书目录与受管路由 include 继续由 Server 统一渲染
|
||||
|
||||
第六版边界补充:
|
||||
|
||||
@@ -93,18 +93,18 @@ ATSFlare 当前定位为内部自用的反向代理控制面,不面向外部
|
||||
|
||||
### 4.1 Server
|
||||
|
||||
`atsf_server` 继续作为单体控制面:
|
||||
`openflare_server` 继续作为单体控制面:
|
||||
|
||||
* Gin
|
||||
* GORM
|
||||
* SQLite
|
||||
* 现有 ATSFlare 登录体系
|
||||
* 托管 `atsf_server/web` 静态构建产物
|
||||
* 现有 OpenFlare 登录体系
|
||||
* 托管 `openflare_server/web` 静态构建产物
|
||||
* 托管 OpenResty 主配置模板、性能参数与缓存参数
|
||||
|
||||
### 4.2 Agent
|
||||
|
||||
`atsf_agent` 继续作为 Go 单体程序:
|
||||
`openflare_agent` 继续作为 Go 单体程序:
|
||||
|
||||
* 单二进制
|
||||
* 节点本地执行
|
||||
@@ -115,7 +115,7 @@ ATSFlare 当前定位为内部自用的反向代理控制面,不面向外部
|
||||
|
||||
### 4.3 Frontend
|
||||
|
||||
`atsf_server/web` 作为正式管理端前端基线:
|
||||
`openflare_server/web` 作为正式管理端前端基线:
|
||||
|
||||
* Next.js App Router
|
||||
* React 19
|
||||
@@ -128,11 +128,11 @@ ATSFlare 当前定位为内部自用的反向代理控制面,不面向外部
|
||||
## 5. 总体架构
|
||||
|
||||
```text
|
||||
ATSFlare Server (Gin + SQLite + Web UI)
|
||||
OpenFlare Server (Gin + SQLite + Web UI)
|
||||
|
|
||||
| HTTP API / Config Pull
|
||||
v
|
||||
ATSFlare Agent (register / heartbeat / sync / apply / update)
|
||||
OpenFlare Agent (register / heartbeat / sync / apply / update)
|
||||
|
|
||||
v
|
||||
Local OpenResty or Docker OpenResty
|
||||
@@ -239,7 +239,7 @@ ATSFlare Agent (register / heartbeat / sync / apply / update)
|
||||
|
||||
## 8. 模块边界
|
||||
|
||||
### 8.1 `atsf_server`
|
||||
### 8.1 `openflare_server`
|
||||
|
||||
负责:
|
||||
|
||||
@@ -252,7 +252,7 @@ ATSFlare Agent (register / heartbeat / sync / apply / update)
|
||||
* 发布与激活
|
||||
* 节点状态与设置管理
|
||||
|
||||
### 8.2 `atsf_agent`
|
||||
### 8.2 `openflare_agent`
|
||||
|
||||
负责:
|
||||
|
||||
@@ -266,7 +266,7 @@ ATSFlare Agent (register / heartbeat / sync / apply / update)
|
||||
* 自我更新
|
||||
* 应用结果上报
|
||||
|
||||
### 8.3 `atsf_server/web`
|
||||
### 8.3 `openflare_server/web`
|
||||
|
||||
负责:
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ATSFlare 开发规范
|
||||
# OpenFlare 开发规范
|
||||
|
||||
## 1. 适用范围
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
* 第一版、第二版、第三版已完成
|
||||
* `docs/design.md` 是当前系统边界的唯一设计基线
|
||||
* `atsf_server/web` 新版前端已完成迁移并成为正式基线
|
||||
* `openflare_server/web` 新版前端已完成迁移并成为正式基线
|
||||
* 第五版(0.5.x)已完成
|
||||
* 第六版(0.6.x)以节点流量数据采集、访问分析与看板升级为主线
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
### 2.1 Server
|
||||
|
||||
`atsf_server` 继续作为单体控制面:
|
||||
`openflare_server` 继续作为单体控制面:
|
||||
|
||||
* Go 1.24+
|
||||
* Gin
|
||||
* GORM
|
||||
* SQLite
|
||||
* 现有 ATSFlare 登录体系
|
||||
* 现有 OpenFlare 登录体系
|
||||
|
||||
约束:
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
### 2.2 Agent
|
||||
|
||||
`atsf_agent` 继续作为 Go 单体程序:
|
||||
`openflare_agent` 继续作为 Go 单体程序:
|
||||
|
||||
* Go 1.23+
|
||||
* 单二进制
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
### 2.3 Frontend
|
||||
|
||||
新版前端基线以当前 `atsf_server/web` 实现为准:
|
||||
新版前端基线以当前 `openflare_server/web` 实现为准:
|
||||
|
||||
* Next.js 15 App Router
|
||||
* React 19
|
||||
@@ -186,7 +186,7 @@
|
||||
|
||||
管理端:
|
||||
|
||||
* 继续复用 ATSFlare 登录、角色与 session
|
||||
* 继续复用 OpenFlare 登录、角色与 session
|
||||
|
||||
Agent:
|
||||
|
||||
@@ -375,4 +375,4 @@ Agent 必须满足:
|
||||
|
||||
* Server 提供 Swagger UI 入口:`/swagger/index.html`
|
||||
* Swagger UI 仅对已登录的管理端用户开放
|
||||
* 新增或修改 API 时,必须同步更新 Swag 注解并重新生成 `atsf_server/docs`
|
||||
* 新增或修改 API 时,必须同步更新 Swag 注解并重新生成 `openflare_server/docs`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ATSFlare 开发计划
|
||||
# OpenFlare 开发计划
|
||||
|
||||
## 1. 当前状态
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
* 首屏新增世界地图看板,用于展示全部节点分布与在线状态
|
||||
* 调整总览信息结构,不再以单一“四卡摘要”作为主布局
|
||||
* 增加趋势、分布、Top 榜单、容量风险和异常信号展示
|
||||
* 引入类似 WAF/安全运营面板的信息组织方式,但聚焦 ATSFlare 当前系统健康与流量状态
|
||||
* 引入类似 WAF/安全运营面板的信息组织方式,但聚焦 OpenFlare 当前系统健康与流量状态
|
||||
|
||||
4. 节点详情页改造
|
||||
* 第一行重构为三块核心卡片:系统信息、实时资源占用、网络流量监控
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# ATSFlare 前端开发规范
|
||||
# OpenFlare 前端开发规范
|
||||
|
||||
## 1. 适用范围
|
||||
|
||||
本文档约束 `atsf_server/web` 新版前端的工程结构、请求层、组件设计、样式体系、状态管理与测试方式。
|
||||
本文档约束 `openflare_server/web` 新版前端的工程结构、请求层、组件设计、样式体系、状态管理与测试方式。
|
||||
|
||||
当前状态:
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# ATSFlare 前端改造说明
|
||||
# OpenFlare 前端改造说明
|
||||
|
||||
## 1. 当前状态
|
||||
|
||||
前端改造已完成,`atsf_server/web` 的 Next.js 新版工程已经成为正式管理端基线。
|
||||
前端改造已完成,`openflare_server/web` 的 Next.js 新版工程已经成为正式管理端基线。
|
||||
|
||||
当前结论:
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
## 2. 当前前端基线
|
||||
|
||||
新版管理端位于 `atsf_server/web`,当前基线为:
|
||||
新版管理端位于 `openflare_server/web`,当前基线为:
|
||||
|
||||
* Next.js 15 App Router
|
||||
* React 19
|
||||
@@ -28,7 +28,7 @@
|
||||
工程与运行方式:
|
||||
|
||||
* `next build` 后生成静态导出产物
|
||||
* 构建后通过现有流程交由 `atsf_server` 托管
|
||||
* 构建后通过现有流程交由 `openflare_server` 托管
|
||||
* 登录态继续兼容现有 Session/Cookie 体系
|
||||
|
||||
---
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ATSFlare 整理维护期改进计划
|
||||
# OpenFlare 整理维护期改进计划
|
||||
|
||||
## 1. 背景
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
### 2.1 总目标
|
||||
|
||||
在不扩大产品边界的前提下,把 ATSFlare 从“功能可用”推进到“长期可维护、风险可控、成本可预测”。
|
||||
在不扩大产品边界的前提下,把 OpenFlare 从“功能可用”推进到“长期可维护、风险可控、成本可预测”。
|
||||
|
||||
### 2.2 具体目标
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"server_url": "http://127.0.0.1:3000",
|
||||
"agent_token": "d873f8084cb7539a2d2f6273ba7fbebe",
|
||||
"agent_token": "89d0efbf7bcc8fa53fe48889dce4d045",
|
||||
"data_dir": "./data",
|
||||
"openresty_container_name": "atsflare-openresty",
|
||||
"openresty_container_name": "openflare-openresty",
|
||||
"openresty_docker_image": "openresty/openresty:alpine",
|
||||
"heartbeat_interval": 10000,
|
||||
"request_timeout": 10000
|
||||
@@ -8,15 +8,15 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"atsflare-agent/internal/agent"
|
||||
"atsflare-agent/internal/config"
|
||||
"atsflare-agent/internal/heartbeat"
|
||||
"atsflare-agent/internal/httpclient"
|
||||
"atsflare-agent/internal/logging"
|
||||
"atsflare-agent/internal/nginx"
|
||||
"atsflare-agent/internal/state"
|
||||
syncservice "atsflare-agent/internal/sync"
|
||||
"atsflare-agent/internal/updater"
|
||||
"openflare-agent/internal/agent"
|
||||
"openflare-agent/internal/config"
|
||||
"openflare-agent/internal/heartbeat"
|
||||
"openflare-agent/internal/httpclient"
|
||||
"openflare-agent/internal/logging"
|
||||
"openflare-agent/internal/nginx"
|
||||
"openflare-agent/internal/state"
|
||||
syncservice "openflare-agent/internal/sync"
|
||||
"openflare-agent/internal/updater"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -0,0 +1,3 @@
|
||||
module openflare-agent
|
||||
|
||||
go 1.23.0
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"atsflare-agent/internal/config"
|
||||
"atsflare-agent/internal/observability"
|
||||
"atsflare-agent/internal/protocol"
|
||||
"atsflare-agent/internal/state"
|
||||
"openflare-agent/internal/config"
|
||||
"openflare-agent/internal/observability"
|
||||
"openflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/state"
|
||||
)
|
||||
|
||||
type HeartbeatService interface {
|
||||
+7
-7
@@ -9,9 +9,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"atsflare-agent/internal/config"
|
||||
"atsflare-agent/internal/protocol"
|
||||
"atsflare-agent/internal/state"
|
||||
"openflare-agent/internal/config"
|
||||
"openflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/state"
|
||||
)
|
||||
|
||||
type fakeHeartbeatService struct {
|
||||
@@ -301,7 +301,7 @@ func TestRunnerHeartbeatPayloadIncludesObservabilityExtensions(t *testing.T) {
|
||||
AgentVersion: config.AgentVersion,
|
||||
NginxVersion: "1.27.1.2",
|
||||
DataDir: tempDir,
|
||||
RouteConfigPath: filepath.Join(tempDir, "conf.d", "atsflare_routes.conf"),
|
||||
RouteConfigPath: filepath.Join(tempDir, "conf.d", "openflare_routes.conf"),
|
||||
HeartbeatInterval: config.MillisecondDuration(10 * time.Millisecond),
|
||||
},
|
||||
StateStore: stateStore,
|
||||
@@ -310,7 +310,7 @@ func TestRunnerHeartbeatPayloadIncludesObservabilityExtensions(t *testing.T) {
|
||||
t.Fatalf("failed to prepare route config dir: %v", err)
|
||||
}
|
||||
if err := os.WriteFile(
|
||||
filepath.Join(filepath.Dir(runner.Config.RouteConfigPath), "atsflare_access.log"),
|
||||
filepath.Join(filepath.Dir(runner.Config.RouteConfigPath), "openflare_access.log"),
|
||||
[]byte("{\"ts\":\""+time.Now().UTC().Format(time.RFC3339)+"\",\"host\":\"edge.example.com\",\"path\":\"/\",\"remote_addr\":\"10.0.0.8\",\"status\":200}\n"),
|
||||
0o644,
|
||||
); err != nil {
|
||||
@@ -383,7 +383,7 @@ func TestRunnerReplaysBufferedObservabilityAfterHeartbeatRecovery(t *testing.T)
|
||||
AgentVersion: config.AgentVersion,
|
||||
NginxVersion: "1.27.1.2",
|
||||
DataDir: tempDir,
|
||||
RouteConfigPath: filepath.Join(tempDir, "conf.d", "atsflare_routes.conf"),
|
||||
RouteConfigPath: filepath.Join(tempDir, "conf.d", "openflare_routes.conf"),
|
||||
HeartbeatInterval: config.MillisecondDuration(10 * time.Millisecond),
|
||||
ObservabilityReplayMinutes: 15,
|
||||
},
|
||||
@@ -396,7 +396,7 @@ func TestRunnerReplaysBufferedObservabilityAfterHeartbeatRecovery(t *testing.T)
|
||||
t.Fatalf("failed to prepare route config dir: %v", err)
|
||||
}
|
||||
if err := os.WriteFile(
|
||||
filepath.Join(filepath.Dir(runner.Config.RouteConfigPath), "atsflare_access.log"),
|
||||
filepath.Join(filepath.Dir(runner.Config.RouteConfigPath), "openflare_access.log"),
|
||||
[]byte("{\"ts\":\""+time.Now().UTC().Format(time.RFC3339)+"\",\"host\":\"edge.example.com\",\"path\":\"/\",\"remote_addr\":\"10.0.0.8\",\"status\":200}\n"),
|
||||
0o644,
|
||||
); err != nil {
|
||||
@@ -13,13 +13,13 @@ import (
|
||||
|
||||
const (
|
||||
defaultDockerMainConfigRelativePath = "etc/nginx/nginx.conf"
|
||||
defaultDockerRouteConfigRelativePath = "etc/nginx/conf.d/atsflare_routes.conf"
|
||||
defaultDockerRouteConfigRelativePath = "etc/nginx/conf.d/openflare_routes.conf"
|
||||
defaultCertDirRelativePath = "etc/nginx/certs"
|
||||
defaultLuaDirRelativePath = "etc/nginx/lua"
|
||||
defaultDockerStateRelativePath = "var/lib/atsflare/agent-state.json"
|
||||
defaultObservabilityBufferRelativePath = "var/lib/atsflare/observability-buffer.json"
|
||||
defaultDockerOpenRestyCertDir = "/etc/nginx/atsflare-certs"
|
||||
defaultDockerOpenRestyLuaDir = "/etc/nginx/atsflare-lua"
|
||||
defaultDockerStateRelativePath = "var/lib/openflare/agent-state.json"
|
||||
defaultObservabilityBufferRelativePath = "var/lib/openflare/observability-buffer.json"
|
||||
defaultDockerOpenRestyCertDir = "/etc/nginx/openflare-certs"
|
||||
defaultDockerOpenRestyLuaDir = "/etc/nginx/openflare-lua"
|
||||
defaultOpenRestyObservabilityPort = 18081
|
||||
defaultObservabilityReplayMinutes = 15
|
||||
)
|
||||
@@ -122,7 +122,7 @@ func applyDefaults(cfg *Config, baseDir string) {
|
||||
baseDir = filepath.Clean(baseDir)
|
||||
cfg.AgentVersion = AgentVersion
|
||||
if cfg.OpenrestyContainerName == "" {
|
||||
cfg.OpenrestyContainerName = "atsflare-openresty"
|
||||
cfg.OpenrestyContainerName = "openflare-openresty"
|
||||
}
|
||||
if cfg.OpenrestyDockerImage == "" {
|
||||
cfg.OpenrestyDockerImage = "openresty/openresty:alpine"
|
||||
+8
-8
@@ -45,7 +45,7 @@ func TestLoadDockerModeUsesManagedPaths(t *testing.T) {
|
||||
if cfg.LuaDir != filepath.Join(dir, "data", defaultLuaDirRelativePath) {
|
||||
t.Fatalf("unexpected lua dir: %s", cfg.LuaDir)
|
||||
}
|
||||
if cfg.OpenrestyContainerName != "atsflare-openresty" {
|
||||
if cfg.OpenrestyContainerName != "openflare-openresty" {
|
||||
t.Fatalf("unexpected openresty container name: %s", cfg.OpenrestyContainerName)
|
||||
}
|
||||
if cfg.OpenrestyDockerImage != "openresty/openresty:alpine" {
|
||||
@@ -128,7 +128,7 @@ func TestLoadUsesCustomDataDirForGeneratedFiles(t *testing.T) {
|
||||
"agent_token": "token",
|
||||
"node_name": "edge-01",
|
||||
"node_ip": "10.0.0.8",
|
||||
"data_dir": "/srv/atsflare",
|
||||
"data_dir": "/srv/openflare",
|
||||
}
|
||||
data, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
@@ -143,22 +143,22 @@ func TestLoadUsesCustomDataDirForGeneratedFiles(t *testing.T) {
|
||||
t.Fatalf("Load failed: %v", err)
|
||||
}
|
||||
|
||||
if cfg.RouteConfigPath != "/srv/atsflare/"+defaultDockerRouteConfigRelativePath {
|
||||
if cfg.RouteConfigPath != "/srv/openflare/"+defaultDockerRouteConfigRelativePath {
|
||||
t.Fatalf("unexpected route config path: %s", cfg.RouteConfigPath)
|
||||
}
|
||||
if cfg.MainConfigPath != "/srv/atsflare/"+defaultDockerMainConfigRelativePath {
|
||||
if cfg.MainConfigPath != "/srv/openflare/"+defaultDockerMainConfigRelativePath {
|
||||
t.Fatalf("unexpected main config path: %s", cfg.MainConfigPath)
|
||||
}
|
||||
if cfg.StatePath != "/srv/atsflare/"+defaultDockerStateRelativePath {
|
||||
if cfg.StatePath != "/srv/openflare/"+defaultDockerStateRelativePath {
|
||||
t.Fatalf("unexpected state path: %s", cfg.StatePath)
|
||||
}
|
||||
if cfg.ObservabilityBufferPath != "/srv/atsflare/"+defaultObservabilityBufferRelativePath {
|
||||
if cfg.ObservabilityBufferPath != "/srv/openflare/"+defaultObservabilityBufferRelativePath {
|
||||
t.Fatalf("unexpected observability buffer path: %s", cfg.ObservabilityBufferPath)
|
||||
}
|
||||
if cfg.CertDir != "/srv/atsflare/"+defaultCertDirRelativePath {
|
||||
if cfg.CertDir != "/srv/openflare/"+defaultCertDirRelativePath {
|
||||
t.Fatalf("unexpected cert dir: %s", cfg.CertDir)
|
||||
}
|
||||
if cfg.LuaDir != "/srv/atsflare/"+defaultLuaDirRelativePath {
|
||||
if cfg.LuaDir != "/srv/openflare/"+defaultLuaDirRelativePath {
|
||||
t.Fatalf("unexpected lua dir: %s", cfg.LuaDir)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@ package heartbeat
|
||||
import (
|
||||
"context"
|
||||
|
||||
"atsflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/protocol"
|
||||
)
|
||||
|
||||
type Client interface {
|
||||
+1
-1
@@ -10,7 +10,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"atsflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/protocol"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
@@ -15,18 +15,18 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"atsflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/protocol"
|
||||
)
|
||||
|
||||
const CertDirPlaceholder = "__ATSF_CERT_DIR__"
|
||||
const RouteConfigPlaceholder = "__ATSF_ROUTE_CONFIG__"
|
||||
const AccessLogPlaceholder = "__ATSF_ACCESS_LOG__"
|
||||
const LuaDirPlaceholder = "__ATSF_LUA_DIR__"
|
||||
const ObservabilityListenPlaceholder = "__ATSF_OBSERVABILITY_LISTEN__"
|
||||
const ObservabilityPortPlaceholder = "__ATSF_OBSERVABILITY_PORT__"
|
||||
const CertDirPlaceholder = "__OPENFLARE_CERT_DIR__"
|
||||
const RouteConfigPlaceholder = "__OPENFLARE_ROUTE_CONFIG__"
|
||||
const AccessLogPlaceholder = "__OPENFLARE_ACCESS_LOG__"
|
||||
const LuaDirPlaceholder = "__OPENFLARE_LUA_DIR__"
|
||||
const ObservabilityListenPlaceholder = "__OPENFLARE_OBSERVABILITY_LISTEN__"
|
||||
const ObservabilityPortPlaceholder = "__OPENFLARE_OBSERVABILITY_PORT__"
|
||||
const DockerMainConfigPath = "/usr/local/openresty/nginx/conf/nginx.conf"
|
||||
const DockerRouteConfigPath = "/etc/nginx/conf.d/atsflare_routes.conf"
|
||||
const DockerAccessLogPath = "/etc/nginx/conf.d/atsflare_access.log"
|
||||
const DockerRouteConfigPath = "/etc/nginx/conf.d/openflare_routes.conf"
|
||||
const DockerAccessLogPath = "/etc/nginx/conf.d/openflare_access.log"
|
||||
|
||||
const dockerRuntimeCommand = "openresty"
|
||||
|
||||
@@ -768,7 +768,7 @@ func (m *Manager) accessLogRuntimePath() string {
|
||||
if strings.TrimSpace(includePath) == "" {
|
||||
return ""
|
||||
}
|
||||
return filepath.ToSlash(filepath.Join(filepath.Dir(includePath), "atsflare_access.log"))
|
||||
return filepath.ToSlash(filepath.Join(filepath.Dir(includePath), "openflare_access.log"))
|
||||
}
|
||||
|
||||
func (m *Manager) luaRuntimePath() string {
|
||||
+47
-47
@@ -10,7 +10,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"atsflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/protocol"
|
||||
)
|
||||
|
||||
type runCall struct {
|
||||
@@ -118,14 +118,14 @@ func TestDockerExecutorCheckHealthFailsWhenContainerStopped(t *testing.T) {
|
||||
}
|
||||
executor := &DockerExecutor{
|
||||
DockerBinary: "docker",
|
||||
ContainerName: "atsflare-openresty",
|
||||
ContainerName: "openflare-openresty",
|
||||
Image: "openresty/openresty:alpine",
|
||||
MainConfigPath: filepath.Clean("/tmp/nginx.conf"),
|
||||
RouteConfigDir: filepath.Clean("/tmp/routes"),
|
||||
CertDir: filepath.Clean("/tmp/certs"),
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: filepath.Clean("/tmp/lua"),
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
Runner: runner,
|
||||
}
|
||||
if err := executor.CheckHealth(context.Background()); err == nil {
|
||||
@@ -144,14 +144,14 @@ func TestDockerExecutorStartsContainerWhenMissing(t *testing.T) {
|
||||
}
|
||||
executor := &DockerExecutor{
|
||||
DockerBinary: "docker",
|
||||
ContainerName: "atsflare-openresty",
|
||||
ContainerName: "openflare-openresty",
|
||||
Image: "openresty/openresty:alpine",
|
||||
MainConfigPath: filepath.Clean("/tmp/nginx.conf"),
|
||||
RouteConfigDir: filepath.Clean("/tmp/routes"),
|
||||
CertDir: filepath.Clean("/tmp/certs"),
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: filepath.Clean("/tmp/lua"),
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
Runner: runner,
|
||||
}
|
||||
|
||||
@@ -181,14 +181,14 @@ func TestDockerExecutorStartsStoppedContainer(t *testing.T) {
|
||||
}
|
||||
executor := &DockerExecutor{
|
||||
DockerBinary: "docker",
|
||||
ContainerName: "atsflare-openresty",
|
||||
ContainerName: "openflare-openresty",
|
||||
Image: "openresty/openresty:alpine",
|
||||
MainConfigPath: filepath.Clean("/tmp/nginx.conf"),
|
||||
RouteConfigDir: filepath.Clean("/tmp/routes"),
|
||||
CertDir: filepath.Clean("/tmp/certs"),
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: filepath.Clean("/tmp/lua"),
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
Runner: runner,
|
||||
}
|
||||
|
||||
@@ -218,14 +218,14 @@ func TestDockerExecutorRunContainerMountsManagedFiles(t *testing.T) {
|
||||
runner := &fakeRunner{}
|
||||
executor := &DockerExecutor{
|
||||
DockerBinary: "docker",
|
||||
ContainerName: "atsflare-openresty",
|
||||
ContainerName: "openflare-openresty",
|
||||
Image: "openresty/openresty:alpine",
|
||||
MainConfigPath: mainConfigPath,
|
||||
RouteConfigDir: routeConfigDir,
|
||||
CertDir: certDir,
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: luaDir,
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
OpenrestyObservabilityPort: 18081,
|
||||
Runner: runner,
|
||||
}
|
||||
@@ -240,14 +240,14 @@ func TestDockerExecutorRunContainerMountsManagedFiles(t *testing.T) {
|
||||
|
||||
expectedArgs := []string{
|
||||
"run", "-d",
|
||||
"--name", "atsflare-openresty",
|
||||
"--name", "openflare-openresty",
|
||||
"-p", "80:80",
|
||||
"-p", "443:443",
|
||||
"-p", "127.0.0.1:18081:18081",
|
||||
"-v", mainConfigPath + ":" + DockerMainConfigPath,
|
||||
"-v", routeConfigDir + ":/etc/nginx/conf.d",
|
||||
"-v", certDir + ":/etc/nginx/atsflare-certs",
|
||||
"-v", luaDir + ":/etc/nginx/atsflare-lua",
|
||||
"-v", certDir + ":/etc/nginx/openflare-certs",
|
||||
"-v", luaDir + ":/etc/nginx/openflare-lua",
|
||||
"openresty/openresty:alpine",
|
||||
}
|
||||
if !reflect.DeepEqual(runner.calls[0].args, expectedArgs) {
|
||||
@@ -266,14 +266,14 @@ func TestDockerExecutorRecreatesContainerOnStartup(t *testing.T) {
|
||||
}
|
||||
executor := &DockerExecutor{
|
||||
DockerBinary: "docker",
|
||||
ContainerName: "atsflare-openresty",
|
||||
ContainerName: "openflare-openresty",
|
||||
Image: "openresty/openresty:alpine",
|
||||
MainConfigPath: filepath.Clean("/tmp/nginx.conf"),
|
||||
RouteConfigDir: filepath.Clean("/tmp/routes"),
|
||||
CertDir: filepath.Clean("/tmp/certs"),
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: filepath.Clean("/tmp/lua"),
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
OpenrestyObservabilityPort: 18081,
|
||||
Runner: runner,
|
||||
}
|
||||
@@ -295,14 +295,14 @@ func TestDockerExecutorRecreatesContainerOnStartup(t *testing.T) {
|
||||
func TestNewExecutorUsesAbsoluteDockerMountPath(t *testing.T) {
|
||||
executor := NewExecutor(ExecutorOptions{
|
||||
DockerBinary: "docker",
|
||||
ContainerName: "atsflare-openresty",
|
||||
ContainerName: "openflare-openresty",
|
||||
Image: "openresty/openresty:alpine",
|
||||
MainConfigPath: "./data/etc/nginx/nginx.conf",
|
||||
RouteConfigPath: "./data/etc/nginx/conf.d/atsflare_routes.conf",
|
||||
RouteConfigPath: "./data/etc/nginx/conf.d/openflare_routes.conf",
|
||||
CertDir: "./data/etc/nginx/certs",
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: "./data/etc/nginx/lua",
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
OpenrestyObservabilityPort: 18081,
|
||||
})
|
||||
|
||||
@@ -343,22 +343,22 @@ func TestDetectVersionFromBinary(t *testing.T) {
|
||||
func TestManagerApplyAndChecksumIncludeMainConfig(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
mainPath := filepath.Join(tempDir, "nginx.conf")
|
||||
routePath := filepath.Join(tempDir, "conf.d", "atsflare_routes.conf")
|
||||
routePath := filepath.Join(tempDir, "conf.d", "openflare_routes.conf")
|
||||
certDir := filepath.Join(tempDir, "certs")
|
||||
manager := &Manager{
|
||||
MainConfigPath: mainPath,
|
||||
RouteConfigPath: routePath,
|
||||
CertDir: certDir,
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: filepath.Join(tempDir, "lua"),
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
Executor: &fakeExecutor{},
|
||||
}
|
||||
|
||||
err := manager.Apply(
|
||||
context.Background(),
|
||||
"include __ATSF_ROUTE_CONFIG__;\naccess_log __ATSF_ACCESS_LOG__ atsflare_json;\n",
|
||||
"ssl_certificate __ATSF_CERT_DIR__/1.crt;\n",
|
||||
"include __OPENFLARE_ROUTE_CONFIG__;\naccess_log __OPENFLARE_ACCESS_LOG__ openflare_json;\n",
|
||||
"ssl_certificate __OPENFLARE_CERT_DIR__/1.crt;\n",
|
||||
[]protocol.SupportFile{{Path: "1.crt", Content: "cert"}},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -369,7 +369,7 @@ func TestManagerApplyAndChecksumIncludeMainConfig(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read main config: %v", err)
|
||||
}
|
||||
expectedMain := "include " + routePath + ";\naccess_log " + filepath.Join(filepath.Dir(routePath), "atsflare_access.log") + " atsflare_json;\n"
|
||||
expectedMain := "include " + routePath + ";\naccess_log " + filepath.Join(filepath.Dir(routePath), "openflare_access.log") + " openflare_json;\n"
|
||||
if string(mainData) != expectedMain {
|
||||
t.Fatalf("unexpected main config: %s", string(mainData))
|
||||
}
|
||||
@@ -378,7 +378,7 @@ func TestManagerApplyAndChecksumIncludeMainConfig(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read route config: %v", err)
|
||||
}
|
||||
if string(routeData) != "ssl_certificate /etc/nginx/atsflare-certs/1.crt;\n" {
|
||||
if string(routeData) != "ssl_certificate /etc/nginx/openflare-certs/1.crt;\n" {
|
||||
t.Fatalf("unexpected route config: %s", string(routeData))
|
||||
}
|
||||
|
||||
@@ -387,8 +387,8 @@ func TestManagerApplyAndChecksumIncludeMainConfig(t *testing.T) {
|
||||
t.Fatalf("CurrentChecksum failed: %v", err)
|
||||
}
|
||||
expected := bundleChecksum(
|
||||
"include __ATSF_ROUTE_CONFIG__;\naccess_log __ATSF_ACCESS_LOG__ atsflare_json;\n",
|
||||
"ssl_certificate __ATSF_CERT_DIR__/1.crt;\n",
|
||||
"include __OPENFLARE_ROUTE_CONFIG__;\naccess_log __OPENFLARE_ACCESS_LOG__ openflare_json;\n",
|
||||
"ssl_certificate __OPENFLARE_CERT_DIR__/1.crt;\n",
|
||||
[]protocol.SupportFile{{Path: "1.crt", Content: "cert"}},
|
||||
)
|
||||
if value != expected {
|
||||
@@ -399,19 +399,19 @@ func TestManagerApplyAndChecksumIncludeMainConfig(t *testing.T) {
|
||||
func TestManagerApplyUsesRuntimeRouteConfigPath(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
mainPath := filepath.Join(tempDir, "nginx.conf")
|
||||
routePath := filepath.Join(tempDir, "conf.d", "atsflare_routes.conf")
|
||||
routePath := filepath.Join(tempDir, "conf.d", "openflare_routes.conf")
|
||||
manager := &Manager{
|
||||
MainConfigPath: mainPath,
|
||||
RouteConfigPath: routePath,
|
||||
RuntimeRouteConfigPath: DockerRouteConfigPath,
|
||||
CertDir: filepath.Join(tempDir, "certs"),
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: filepath.Join(tempDir, "lua"),
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
Executor: &fakeExecutor{},
|
||||
}
|
||||
|
||||
if err := manager.Apply(context.Background(), "include __ATSF_ROUTE_CONFIG__;\naccess_log __ATSF_ACCESS_LOG__ atsflare_json;\n", "server { listen 80; }\n", nil); err != nil {
|
||||
if err := manager.Apply(context.Background(), "include __OPENFLARE_ROUTE_CONFIG__;\naccess_log __OPENFLARE_ACCESS_LOG__ openflare_json;\n", "server { listen 80; }\n", nil); err != nil {
|
||||
t.Fatalf("Apply failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ func TestManagerApplyUsesRuntimeRouteConfigPath(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read main config: %v", err)
|
||||
}
|
||||
expectedMain := "include " + DockerRouteConfigPath + ";\naccess_log " + DockerAccessLogPath + " atsflare_json;\n"
|
||||
expectedMain := "include " + DockerRouteConfigPath + ";\naccess_log " + DockerAccessLogPath + " openflare_json;\n"
|
||||
if string(mainData) != expectedMain {
|
||||
t.Fatalf("unexpected main config include path: %s", string(mainData))
|
||||
}
|
||||
@@ -429,7 +429,7 @@ func TestManagerApplyUsesRuntimeRouteConfigPath(t *testing.T) {
|
||||
t.Fatalf("CurrentChecksum failed: %v", err)
|
||||
}
|
||||
expected := bundleChecksum(
|
||||
"include __ATSF_ROUTE_CONFIG__;\naccess_log __ATSF_ACCESS_LOG__ atsflare_json;\n",
|
||||
"include __OPENFLARE_ROUTE_CONFIG__;\naccess_log __OPENFLARE_ACCESS_LOG__ openflare_json;\n",
|
||||
"server { listen 80; }\n",
|
||||
nil,
|
||||
)
|
||||
@@ -481,14 +481,14 @@ func TestManagerApplyWritesSupportFilesAndReplacesPlaceholder(t *testing.T) {
|
||||
MainConfigPath: filepath.Join(tempDir, "nginx.conf"),
|
||||
RouteConfigPath: filepath.Join(tempDir, "routes.conf"),
|
||||
CertDir: filepath.Join(tempDir, "certs"),
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: filepath.Join(tempDir, "lua"),
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
OpenrestyObservabilityListen: "18081",
|
||||
Executor: &fakeExecutor{},
|
||||
}
|
||||
|
||||
err := manager.Apply(context.Background(), "include __ATSF_ROUTE_CONFIG__;\nserver { listen __ATSF_OBSERVABILITY_LISTEN__; }", "ssl_certificate __ATSF_CERT_DIR__/1.crt;", []protocol.SupportFile{
|
||||
err := manager.Apply(context.Background(), "include __OPENFLARE_ROUTE_CONFIG__;\nserver { listen __OPENFLARE_OBSERVABILITY_LISTEN__; }", "ssl_certificate __OPENFLARE_CERT_DIR__/1.crt;", []protocol.SupportFile{
|
||||
{Path: "1.crt", Content: "cert-data"},
|
||||
{Path: "1.key", Content: "key-data"},
|
||||
})
|
||||
@@ -500,7 +500,7 @@ func TestManagerApplyWritesSupportFilesAndReplacesPlaceholder(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read route config: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(routeData), "/etc/nginx/atsflare-certs/1.crt") {
|
||||
if !strings.Contains(string(routeData), "/etc/nginx/openflare-certs/1.crt") {
|
||||
t.Fatalf("expected placeholder replacement in route config, got %s", string(routeData))
|
||||
}
|
||||
mainData, err := os.ReadFile(manager.MainConfigPath)
|
||||
@@ -548,7 +548,7 @@ func TestManagerEnsureLuaAssetsWritesReadableFiles(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
manager := &Manager{
|
||||
LuaDir: filepath.Join(tempDir, "lua"),
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
}
|
||||
|
||||
err := manager.EnsureLuaAssets()
|
||||
@@ -586,9 +586,9 @@ func TestManagerRollbackRestoresCertFiles(t *testing.T) {
|
||||
MainConfigPath: mainPath,
|
||||
RouteConfigPath: routePath,
|
||||
CertDir: certDir,
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: filepath.Join(tempDir, "lua"),
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
Executor: &fakeExecutor{
|
||||
testErr: errors.New("openresty test failed"),
|
||||
},
|
||||
@@ -669,9 +669,9 @@ func TestManagerApplyRejectsCertFilePathTraversal(t *testing.T) {
|
||||
MainConfigPath: filepath.Join(tempDir, "nginx.conf"),
|
||||
RouteConfigPath: filepath.Join(tempDir, "routes.conf"),
|
||||
CertDir: filepath.Join(tempDir, "certs"),
|
||||
NginxCertDir: "/etc/nginx/atsflare-certs",
|
||||
NginxCertDir: "/etc/nginx/openflare-certs",
|
||||
LuaDir: filepath.Join(tempDir, "lua"),
|
||||
NginxLuaDir: "/etc/nginx/atsflare-lua",
|
||||
NginxLuaDir: "/etc/nginx/openflare-lua",
|
||||
Executor: &fakeExecutor{},
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
package nginx
|
||||
|
||||
import "atsflare-agent/internal/protocol"
|
||||
import "openflare-agent/internal/protocol"
|
||||
|
||||
const (
|
||||
openRestyObservabilityWindowTTL = 7200
|
||||
openRestyObservabilityWindowSize = 60
|
||||
)
|
||||
|
||||
const openRestyObservabilityInitLua = `local dict = ngx.shared.atsflare_observability
|
||||
const openRestyObservabilityInitLua = `local dict = ngx.shared.openflare_observability
|
||||
if not dict then
|
||||
return
|
||||
end
|
||||
@@ -15,13 +15,13 @@ end
|
||||
return
|
||||
`
|
||||
|
||||
const openRestyObservabilityLogLua = `local dict = ngx.shared.atsflare_observability
|
||||
const openRestyObservabilityLogLua = `local dict = ngx.shared.openflare_observability
|
||||
if not dict then
|
||||
return
|
||||
end
|
||||
|
||||
local request_uri = tostring(ngx.var.uri or "")
|
||||
if request_uri == "/atsflare/observability" or request_uri == "/atsflare/stub_status" then
|
||||
if request_uri == "/openflare/observability" or request_uri == "/openflare/stub_status" then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -101,7 +101,7 @@ end
|
||||
|
||||
const openRestyObservabilityReadLua = `local cjson = require "cjson.safe"
|
||||
|
||||
local dict = ngx.shared.atsflare_observability
|
||||
local dict = ngx.shared.openflare_observability
|
||||
if not dict then
|
||||
ngx.status = ngx.HTTP_SERVICE_UNAVAILABLE
|
||||
ngx.say(cjson.encode({ message = "shared dict unavailable" }))
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
package observability
|
||||
|
||||
import (
|
||||
"atsflare-agent/internal/config"
|
||||
"atsflare-agent/internal/protocol"
|
||||
"atsflare-agent/internal/state"
|
||||
"bufio"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"openflare-agent/internal/config"
|
||||
"openflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/state"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
+4
-4
@@ -1,20 +1,20 @@
|
||||
package observability
|
||||
|
||||
import (
|
||||
"atsflare-agent/internal/config"
|
||||
"atsflare-agent/internal/protocol"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"openflare-agent/internal/config"
|
||||
"openflare-agent/internal/protocol"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const openRestyObservabilityPath = "/atsflare/observability"
|
||||
const openRestyStubStatusPath = "/atsflare/stub_status"
|
||||
const openRestyObservabilityPath = "/openflare/observability"
|
||||
const openRestyStubStatusPath = "/openflare/stub_status"
|
||||
|
||||
var stubStatusActivePattern = regexp.MustCompile(`Active connections:\s+(\d+)`)
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"atsflare-agent/internal/config"
|
||||
"openflare-agent/internal/config"
|
||||
)
|
||||
|
||||
func TestCollectManagedOpenRestyMetrics(t *testing.T) {
|
||||
@@ -73,10 +73,10 @@ func TestCollectManagedOpenRestyMetricsHandlesUnavailableEndpoint(t *testing.T)
|
||||
}
|
||||
|
||||
func TestOpenRestyObservabilityPathsAreStable(t *testing.T) {
|
||||
if !strings.HasPrefix(openRestyObservabilityPath, "/atsflare/") {
|
||||
if !strings.HasPrefix(openRestyObservabilityPath, "/openflare/") {
|
||||
t.Fatalf("unexpected observability path: %s", openRestyObservabilityPath)
|
||||
}
|
||||
if !strings.HasPrefix(openRestyStubStatusPath, "/atsflare/") {
|
||||
if !strings.HasPrefix(openRestyStubStatusPath, "/openflare/") {
|
||||
t.Fatalf("unexpected stub status path: %s", openRestyStubStatusPath)
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
package observability
|
||||
|
||||
import (
|
||||
"atsflare-agent/internal/config"
|
||||
"atsflare-agent/internal/protocol"
|
||||
"atsflare-agent/internal/state"
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"openflare-agent/internal/config"
|
||||
"openflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/state"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -131,7 +131,7 @@ func managedAccessLogPath(cfg *config.Config) string {
|
||||
if cfg == nil || strings.TrimSpace(cfg.RouteConfigPath) == "" {
|
||||
return ""
|
||||
}
|
||||
return filepath.Join(filepath.Dir(cfg.RouteConfigPath), "atsflare_access.log")
|
||||
return filepath.Join(filepath.Dir(cfg.RouteConfigPath), "openflare_access.log")
|
||||
}
|
||||
|
||||
func newTrafficAggregate() *trafficAggregate {
|
||||
+11
-11
@@ -5,18 +5,18 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"atsflare-agent/internal/config"
|
||||
"atsflare-agent/internal/protocol"
|
||||
"atsflare-agent/internal/state"
|
||||
"openflare-agent/internal/config"
|
||||
"openflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/state"
|
||||
)
|
||||
|
||||
func TestBuildTrafficReportAggregatesManagedAccessLog(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
routeConfigPath := filepath.Join(tempDir, "conf.d", "atsflare_routes.conf")
|
||||
routeConfigPath := filepath.Join(tempDir, "conf.d", "openflare_routes.conf")
|
||||
if err := os.MkdirAll(filepath.Dir(routeConfigPath), 0o755); err != nil {
|
||||
t.Fatalf("MkdirAll failed: %v", err)
|
||||
}
|
||||
logPath := filepath.Join(filepath.Dir(routeConfigPath), "atsflare_access.log")
|
||||
logPath := filepath.Join(filepath.Dir(routeConfigPath), "openflare_access.log")
|
||||
content := []byte(
|
||||
"{\"ts\":\"2026-03-14T08:00:00Z\",\"host\":\"app.example.com\",\"path\":\"/\",\"remote_addr\":\"10.0.0.1\",\"status\":200}\n" +
|
||||
"{\"ts\":\"2026-03-14T08:00:05Z\",\"host\":\"app.example.com\",\"path\":\"/healthz\",\"remote_addr\":\"10.0.0.2\",\"status\":503}\n" +
|
||||
@@ -57,11 +57,11 @@ func TestBuildTrafficReportAggregatesManagedAccessLog(t *testing.T) {
|
||||
|
||||
func TestBuildTrafficReportResetsOffsetAfterTruncate(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
routeConfigPath := filepath.Join(tempDir, "conf.d", "atsflare_routes.conf")
|
||||
routeConfigPath := filepath.Join(tempDir, "conf.d", "openflare_routes.conf")
|
||||
if err := os.MkdirAll(filepath.Dir(routeConfigPath), 0o755); err != nil {
|
||||
t.Fatalf("MkdirAll failed: %v", err)
|
||||
}
|
||||
logPath := filepath.Join(filepath.Dir(routeConfigPath), "atsflare_access.log")
|
||||
logPath := filepath.Join(filepath.Dir(routeConfigPath), "openflare_access.log")
|
||||
if err := os.WriteFile(logPath, []byte("{\"ts\":\"2026-03-14T09:00:00Z\",\"host\":\"app.example.com\",\"path\":\"/\",\"remote_addr\":\"10.0.0.3\",\"status\":200}\n"), 0o644); err != nil {
|
||||
t.Fatalf("WriteFile failed: %v", err)
|
||||
}
|
||||
@@ -79,11 +79,11 @@ func TestBuildTrafficReportResetsOffsetAfterTruncate(t *testing.T) {
|
||||
|
||||
func TestBuildTrafficObservabilityReturnsAccessLogs(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
routeConfigPath := filepath.Join(tempDir, "conf.d", "atsflare_routes.conf")
|
||||
routeConfigPath := filepath.Join(tempDir, "conf.d", "openflare_routes.conf")
|
||||
if err := os.MkdirAll(filepath.Dir(routeConfigPath), 0o755); err != nil {
|
||||
t.Fatalf("MkdirAll failed: %v", err)
|
||||
}
|
||||
logPath := filepath.Join(filepath.Dir(routeConfigPath), "atsflare_access.log")
|
||||
logPath := filepath.Join(filepath.Dir(routeConfigPath), "openflare_access.log")
|
||||
content := []byte(
|
||||
"{\"ts\":\"2026-03-14T08:00:00Z\",\"host\":\"app.example.com\",\"path\":\"/login\",\"remote_addr\":\"10.0.0.1\",\"status\":200,\"request_length\":128,\"bytes_sent\":512}\n" +
|
||||
"{\"ts\":\"2026-03-14T08:00:05Z\",\"host\":\"api.example.com\",\"path\":\"/v1/ping\",\"remote_addr\":\"10.0.0.2\",\"status\":502,\"request_length\":64,\"bytes_sent\":256}\n",
|
||||
@@ -110,11 +110,11 @@ func TestBuildTrafficObservabilityReturnsAccessLogs(t *testing.T) {
|
||||
|
||||
func TestBuildTrafficReportParsesCombinedAccessLog(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
routeConfigPath := filepath.Join(tempDir, "conf.d", "atsflare_routes.conf")
|
||||
routeConfigPath := filepath.Join(tempDir, "conf.d", "openflare_routes.conf")
|
||||
if err := os.MkdirAll(filepath.Dir(routeConfigPath), 0o755); err != nil {
|
||||
t.Fatalf("MkdirAll failed: %v", err)
|
||||
}
|
||||
logPath := filepath.Join(filepath.Dir(routeConfigPath), "atsflare_access.log")
|
||||
logPath := filepath.Join(filepath.Dir(routeConfigPath), "openflare_access.log")
|
||||
content := []byte(
|
||||
"10.0.0.1 - - [14/Mar/2026:08:00:00 +0000] \"GET / HTTP/1.1\" 200 123 \"-\" \"curl/8.0\"\n" +
|
||||
"10.0.0.2 - - [14/Mar/2026:08:00:05 +0000] \"GET /healthz HTTP/1.1\" 502 64 \"-\" \"curl/8.0\"\n" +
|
||||
+1
-1
@@ -8,7 +8,7 @@ import (
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"atsflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/protocol"
|
||||
)
|
||||
|
||||
const observabilityBufferWindowSeconds = 60
|
||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"atsflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/protocol"
|
||||
)
|
||||
|
||||
func TestObservabilityBufferStoreUpsertReplayAndAck(t *testing.T) {
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"atsflare-agent/internal/protocol"
|
||||
"atsflare-agent/internal/state"
|
||||
"openflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/state"
|
||||
)
|
||||
|
||||
const (
|
||||
+3
-3
@@ -7,9 +7,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"atsflare-agent/internal/nginx"
|
||||
"atsflare-agent/internal/protocol"
|
||||
"atsflare-agent/internal/state"
|
||||
"openflare-agent/internal/nginx"
|
||||
"openflare-agent/internal/protocol"
|
||||
"openflare-agent/internal/state"
|
||||
)
|
||||
|
||||
type fakeExecutor struct {
|
||||
+1
-1
@@ -24,4 +24,4 @@ func replaceAndRestart(execPath string, tmpPath string) error {
|
||||
return fmt.Errorf("exec restart: %w", err)
|
||||
}
|
||||
return fmt.Errorf("unreachable after exec")
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -50,4 +50,4 @@ func buildWindowsCommandLine(execPath string, args []string) string {
|
||||
|
||||
func quoteWindowsArg(value string) string {
|
||||
return `"` + strings.ReplaceAll(value, `"`, `""`) + `"`
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -13,8 +13,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"atsflare-agent/internal/agent"
|
||||
"atsflare-agent/internal/config"
|
||||
"openflare-agent/internal/agent"
|
||||
"openflare-agent/internal/config"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
@@ -224,7 +224,7 @@ func (s *Service) downloadAndRestart(ctx context.Context, url string, targetPath
|
||||
}
|
||||
|
||||
func assetNameForGOOSGOARCH(goos string, goarch string) string {
|
||||
name := fmt.Sprintf("atsflare-agent-%s-%s", goos, goarch)
|
||||
name := fmt.Sprintf("openflare-agent-%s-%s", goos, goarch)
|
||||
if goos == "windows" {
|
||||
return name + ".exe"
|
||||
}
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
package updater
|
||||
|
||||
import (
|
||||
"atsflare-agent/internal/agent"
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"openflare-agent/internal/agent"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -19,7 +19,7 @@ func TestGetLatestPreviewRelease(t *testing.T) {
|
||||
service := &Service{
|
||||
httpClient: &http.Client{
|
||||
Transport: roundTripFunc(func(req *http.Request) (*http.Response, error) {
|
||||
if req.URL.String() != "https://api.github.com/repos/Rain-kl/ATSFlare/releases?per_page=20" {
|
||||
if req.URL.String() != "https://api.github.com/repos/Rain-kl/OpenFlare/releases?per_page=20" {
|
||||
t.Fatalf("unexpected request url: %s", req.URL.String())
|
||||
}
|
||||
return &http.Response{
|
||||
@@ -34,7 +34,7 @@ func TestGetLatestPreviewRelease(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
release, err := service.getRelease(context.Background(), "Rain-kl/ATSFlare", agent.UpdateOptions{Channel: "preview"})
|
||||
release, err := service.getRelease(context.Background(), "Rain-kl/OpenFlare", agent.UpdateOptions{Channel: "preview"})
|
||||
if err != nil {
|
||||
t.Fatalf("expected preview release query to succeed: %v", err)
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func TestGetReleaseByTag(t *testing.T) {
|
||||
service := &Service{
|
||||
httpClient: &http.Client{
|
||||
Transport: roundTripFunc(func(req *http.Request) (*http.Response, error) {
|
||||
if req.URL.String() != "https://api.github.com/repos/Rain-kl/ATSFlare/releases/tags/v1.1.0-rc.1" {
|
||||
if req.URL.String() != "https://api.github.com/repos/Rain-kl/OpenFlare/releases/tags/v1.1.0-rc.1" {
|
||||
t.Fatalf("unexpected request url: %s", req.URL.String())
|
||||
}
|
||||
return &http.Response{
|
||||
@@ -59,7 +59,7 @@ func TestGetReleaseByTag(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
release, err := service.getRelease(context.Background(), "Rain-kl/ATSFlare", agent.UpdateOptions{Channel: "preview", TagName: "v1.1.0-rc.1", Force: true})
|
||||
release, err := service.getRelease(context.Background(), "Rain-kl/OpenFlare", agent.UpdateOptions{Channel: "preview", TagName: "v1.1.0-rc.1", Force: true})
|
||||
if err != nil {
|
||||
t.Fatalf("expected tag release query to succeed: %v", err)
|
||||
}
|
||||
@@ -23,7 +23,7 @@ WORKDIR /build
|
||||
COPY . .
|
||||
COPY --from=builder /build/build ./web/build
|
||||
RUN go mod download
|
||||
RUN go build -trimpath -ldflags "-s -w -X 'atsflare/common.Version=$VERSION'" -o atsflare
|
||||
RUN go build -trimpath -ldflags "-s -w -X 'openflare/common.Version=$VERSION'" -o openflare
|
||||
|
||||
FROM alpine
|
||||
|
||||
@@ -32,7 +32,7 @@ RUN apk update \
|
||||
&& apk add --no-cache ca-certificates tzdata \
|
||||
&& update-ca-certificates 2>/dev/null || true
|
||||
ENV PORT=3000
|
||||
COPY --from=builder2 /build/atsflare /
|
||||
COPY --from=builder2 /build/openflare /
|
||||
EXPOSE 3000
|
||||
WORKDIR /data
|
||||
ENTRYPOINT ["/atsflare"]
|
||||
ENTRYPOINT ["/openflare"]
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
var StartTime = time.Now().Unix() // unit: second
|
||||
var Version = "dev" // release builds inject the tag version via ldflags
|
||||
var SystemName = "ATSFlare"
|
||||
var SystemName = "OpenFlare"
|
||||
var ServerAddress = "http://localhost:3000"
|
||||
var Footer = ""
|
||||
var HomePageLink = ""
|
||||
@@ -17,7 +17,7 @@ var HomePageLink = ""
|
||||
// Any options with "Secret", "Token" in its key won't be return by GetOptions
|
||||
|
||||
var SessionSecret = uuid.New().String()
|
||||
var SQLitePath = "atsflare.db"
|
||||
var SQLitePath = "openflare.db"
|
||||
|
||||
var OptionMap map[string]string
|
||||
var OptionMapRWMutex sync.RWMutex
|
||||
@@ -52,7 +52,7 @@ var NodeOfflineThreshold = 2 * time.Minute
|
||||
|
||||
// V3 operational settings (hot-reloadable via Option table)
|
||||
var AgentHeartbeatInterval = 10000 // milliseconds
|
||||
var AgentUpdateRepo = "Rain-kl/ATSFlare"
|
||||
var AgentUpdateRepo = "Rain-kl/OpenFlare"
|
||||
var GeoIPProvider = "ipinfo"
|
||||
|
||||
// V5 OpenResty performance settings (hot-reloadable via Option table)
|
||||
@@ -89,7 +89,7 @@ var OpenRestyCacheKeyTemplate = "$scheme$proxy_host$request_uri"
|
||||
var OpenRestyCacheLockEnabled = true
|
||||
var OpenRestyCacheLockTimeout = "5s"
|
||||
var OpenRestyCacheUseStale = "error timeout updating http_500 http_502 http_503 http_504"
|
||||
var OpenRestyMainConfigTemplate = `# This file is generated by ATSFlare. Do not edit manually.
|
||||
var OpenRestyMainConfigTemplate = `# This file is generated by OpenFlare. Do not edit manually.
|
||||
worker_processes {{OpenRestyWorkerProcesses}};
|
||||
worker_rlimit_nofile {{OpenRestyWorkerRlimitNofile}};
|
||||
pid logs/nginx.pid;
|
||||
@@ -101,8 +101,8 @@ events {
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
log_format atsflare_json escape=json '{"ts":"$time_iso8601","host":"$host","path":"$request_uri","remote_addr":"$remote_addr","status":$status,"request_time":$request_time,"bytes_sent":$body_bytes_sent,"request_length":$request_length}';
|
||||
access_log {{OpenRestyAccessLogPath}} atsflare_json;
|
||||
log_format openflare_json escape=json '{"ts":"$time_iso8601","host":"$host","path":"$request_uri","remote_addr":"$remote_addr","status":$status,"request_time":$request_time,"bytes_sent":$body_bytes_sent,"request_length":$request_length}';
|
||||
access_log {{OpenRestyAccessLogPath}} openflare_json;
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
@@ -20,10 +20,10 @@ var (
|
||||
var UploadPath = "upload"
|
||||
|
||||
func printHelp() {
|
||||
fmt.Println("ATSFlare " + Version + " - Internal OpenResty Control Plane.")
|
||||
fmt.Println("OpenFlare " + Version + " - Internal OpenResty Control Plane.")
|
||||
fmt.Println("Copyright (C) 2023 JustSong. All rights reserved.")
|
||||
fmt.Println("GitHub: https://github.com/Rain-kl/ATSFlare")
|
||||
fmt.Println("Usage: atsflare [--port <port>] [--log-dir <log directory>] [--version] [--help]")
|
||||
fmt.Println("GitHub: https://github.com/Rain-kl/OpenFlare")
|
||||
fmt.Println("Usage: openflare [--port <port>] [--log-dir <log directory>] [--version] [--help]")
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -12,16 +12,16 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type logLevel int
|
||||
|
||||
const (
|
||||
logLevelDebug logLevel = iota
|
||||
logLevelInfo
|
||||
logLevelWarn
|
||||
logLevelError
|
||||
)
|
||||
|
||||
|
||||
type logLevel int
|
||||
|
||||
const (
|
||||
logLevelDebug logLevel = iota
|
||||
logLevelInfo
|
||||
logLevelWarn
|
||||
logLevelError
|
||||
)
|
||||
|
||||
var currentLogLevel = logLevelInfo
|
||||
var currentLogLevelName = "info"
|
||||
var commonLogWriter io.Writer = os.Stdout
|
||||
@@ -108,13 +108,13 @@ func (h *levelRouterHandler) WithGroup(name string) slog.Handler {
|
||||
errorHandler: h.errorHandler.WithGroup(name),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func configureGinWriters() {
|
||||
if shouldLog(logLevelDebug) {
|
||||
gin.DefaultWriter = commonLogWriter
|
||||
} else {
|
||||
gin.DefaultWriter = io.Discard
|
||||
}
|
||||
} else {
|
||||
gin.DefaultWriter = io.Discard
|
||||
}
|
||||
gin.DefaultErrorWriter = errorLogWriter
|
||||
}
|
||||
|
||||
@@ -142,34 +142,34 @@ func ensureLogger() *slog.Logger {
|
||||
slog.SetDefault(defaultLogger)
|
||||
return defaultLogger
|
||||
}
|
||||
|
||||
func SetLogLevel(level string) {
|
||||
normalized := strings.TrimSpace(strings.ToLower(level))
|
||||
switch normalized {
|
||||
case "debug":
|
||||
currentLogLevel = logLevelDebug
|
||||
currentLogLevelName = "debug"
|
||||
case "warn", "warning":
|
||||
currentLogLevel = logLevelWarn
|
||||
currentLogLevelName = "warn"
|
||||
case "error":
|
||||
currentLogLevel = logLevelError
|
||||
currentLogLevelName = "error"
|
||||
default:
|
||||
currentLogLevel = logLevelInfo
|
||||
currentLogLevelName = "info"
|
||||
}
|
||||
configureGinWriters()
|
||||
}
|
||||
|
||||
func GetLogLevel() string {
|
||||
return currentLogLevelName
|
||||
}
|
||||
|
||||
func shouldLog(level logLevel) bool {
|
||||
return level >= currentLogLevel
|
||||
}
|
||||
|
||||
|
||||
func SetLogLevel(level string) {
|
||||
normalized := strings.TrimSpace(strings.ToLower(level))
|
||||
switch normalized {
|
||||
case "debug":
|
||||
currentLogLevel = logLevelDebug
|
||||
currentLogLevelName = "debug"
|
||||
case "warn", "warning":
|
||||
currentLogLevel = logLevelWarn
|
||||
currentLogLevelName = "warn"
|
||||
case "error":
|
||||
currentLogLevel = logLevelError
|
||||
currentLogLevelName = "error"
|
||||
default:
|
||||
currentLogLevel = logLevelInfo
|
||||
currentLogLevelName = "info"
|
||||
}
|
||||
configureGinWriters()
|
||||
}
|
||||
|
||||
func GetLogLevel() string {
|
||||
return currentLogLevelName
|
||||
}
|
||||
|
||||
func shouldLog(level logLevel) bool {
|
||||
return level >= currentLogLevel
|
||||
}
|
||||
|
||||
func SetupGinLog() {
|
||||
if *LogDir != "" {
|
||||
commonLogPath := filepath.Join(*LogDir, "common.log")
|
||||
@@ -1,7 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/service"
|
||||
"openflare/service"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -1,8 +1,8 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/model"
|
||||
"atsflare/service"
|
||||
"openflare/model"
|
||||
"openflare/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/service"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/service"
|
||||
"openflare/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -1,11 +1,11 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"atsflare/model"
|
||||
"atsflare/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/common"
|
||||
"openflare/model"
|
||||
"openflare/utils"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -1,7 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/service"
|
||||
"openflare/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -1,8 +1,6 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"atsflare/model"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -11,6 +9,8 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"openflare/common"
|
||||
"openflare/model"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
+1
-1
@@ -1,10 +1,10 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/service"
|
||||
"encoding/json"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/service"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -1,15 +1,15 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"atsflare/model"
|
||||
"atsflare/utils/mail"
|
||||
"atsflare/utils/security"
|
||||
"atsflare/utils/validation"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/common"
|
||||
"openflare/model"
|
||||
"openflare/utils/mail"
|
||||
"openflare/utils/security"
|
||||
"openflare/utils/validation"
|
||||
)
|
||||
|
||||
// GetStatus godoc
|
||||
@@ -1,7 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/service"
|
||||
"openflare/service"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -1,15 +1,15 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"atsflare/model"
|
||||
"atsflare/service"
|
||||
"atsflare/utils"
|
||||
"atsflare/utils/geoip"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/common"
|
||||
"openflare/model"
|
||||
"openflare/service"
|
||||
"openflare/utils"
|
||||
"openflare/utils/geoip"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -1,10 +1,10 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/service"
|
||||
"encoding/json"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/service"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
+1
-1
@@ -1,10 +1,10 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/service"
|
||||
"encoding/json"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/service"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/service"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"openflare/service"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"atsflare/model"
|
||||
"atsflare/utils/security"
|
||||
"atsflare/utils/validation"
|
||||
"encoding/json"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"net/http"
|
||||
"openflare/common"
|
||||
"openflare/model"
|
||||
"openflare/utils/security"
|
||||
"openflare/utils/validation"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -1,13 +1,13 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"atsflare/model"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/common"
|
||||
"openflare/model"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@@ -1585,8 +1585,8 @@ var SwaggerInfo = &swag.Spec{
|
||||
Host: "",
|
||||
BasePath: "/",
|
||||
Schemes: []string{"http", "https"},
|
||||
Title: "ATSFlare Server API",
|
||||
Description: "ATSFlare Server 管理端与 Agent API 文档。",
|
||||
Title: "OpenFlare Server API",
|
||||
Description: "OpenFlare Server 管理端与 Agent API 文档。",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
}
|
||||
@@ -5,8 +5,8 @@
|
||||
],
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "ATSFlare Server 管理端与 Agent API 文档。",
|
||||
"title": "ATSFlare Server API",
|
||||
"description": "OpenFlare Server 管理端与 Agent API 文档。",
|
||||
"title": "OpenFlare Server API",
|
||||
"contact": {},
|
||||
"version": "3.0"
|
||||
},
|
||||
@@ -98,8 +98,8 @@ definitions:
|
||||
type: object
|
||||
info:
|
||||
contact: {}
|
||||
description: ATSFlare Server 管理端与 Agent API 文档。
|
||||
title: ATSFlare Server API
|
||||
description: OpenFlare Server 管理端与 Agent API 文档。
|
||||
title: OpenFlare Server API
|
||||
version: "3.0"
|
||||
paths:
|
||||
/api/agent/apply-logs:
|
||||
@@ -1,4 +1,4 @@
|
||||
module atsflare
|
||||
module openflare
|
||||
|
||||
// +heroku goVersion go1.18
|
||||
go 1.24.0
|
||||
@@ -1,12 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
_ "atsflare/docs"
|
||||
"atsflare/middleware"
|
||||
"atsflare/model"
|
||||
"atsflare/router"
|
||||
"atsflare/utils/geoip"
|
||||
"embed"
|
||||
"fmt"
|
||||
"github.com/gin-contrib/sessions"
|
||||
@@ -14,6 +8,12 @@ import (
|
||||
"github.com/gin-contrib/sessions/redis"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log/slog"
|
||||
"openflare/common"
|
||||
_ "openflare/docs"
|
||||
"openflare/middleware"
|
||||
"openflare/model"
|
||||
"openflare/router"
|
||||
"openflare/utils/geoip"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
@@ -24,9 +24,9 @@ var buildFS embed.FS
|
||||
//go:embed web/build/index.html
|
||||
var indexPage []byte
|
||||
|
||||
// @title ATSFlare Server API
|
||||
// @title OpenFlare Server API
|
||||
// @version 3.0
|
||||
// @description ATSFlare Server 管理端与 Agent API 文档。
|
||||
// @description OpenFlare Server 管理端与 Agent API 文档。
|
||||
// @BasePath /
|
||||
// @schemes http https
|
||||
// @securityDefinitions.apikey BearerAuth
|
||||
@@ -39,7 +39,7 @@ var indexPage []byte
|
||||
// @description Agent API 使用节点专属 Agent Token 或全局 Discovery Token
|
||||
func main() {
|
||||
common.SetupGinLog()
|
||||
slog.Info("ATSFlare started", "version", common.Version)
|
||||
slog.Info("OpenFlare started", "version", common.Version)
|
||||
if os.Getenv("GIN_MODE") != "debug" {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"atsflare/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/service"
|
||||
)
|
||||
|
||||
func AgentAuth() func(c *gin.Context) {
|
||||
@@ -1,11 +1,11 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"atsflare/model"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"openflare/common"
|
||||
"openflare/model"
|
||||
)
|
||||
|
||||
func authHelper(c *gin.Context, minRole int) {
|
||||
@@ -7,6 +7,6 @@ import (
|
||||
|
||||
func CORS() gin.HandlerFunc {
|
||||
config := cors.DefaultConfig()
|
||||
config.AllowOrigins = []string{"https://atsflare.vercel.app", "http://localhost:3000"}
|
||||
config.AllowOrigins = []string{"https://openflare.vercel.app", "http://localhost:3000"}
|
||||
return cors.New(config)
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"atsflare/utils/ratelimit"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"openflare/common"
|
||||
"openflare/utils/ratelimit"
|
||||
"time"
|
||||
)
|
||||
|
||||
+1
-1
@@ -1,13 +1,13 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"encoding/json"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"openflare/common"
|
||||
)
|
||||
|
||||
type turnstileCheckResponse struct {
|
||||
@@ -1,8 +1,8 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"gorm.io/gorm"
|
||||
"openflare/common"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
@@ -1,12 +1,12 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"atsflare/utils/security"
|
||||
"github.com/glebarez/sqlite"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"log/slog"
|
||||
"openflare/common"
|
||||
"openflare/utils/security"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"atsflare/common"
|
||||
"atsflare/utils/geoip"
|
||||
"openflare/common"
|
||||
"openflare/utils/geoip"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user