1.1.1修复

This commit is contained in:
Alex Yang
2025-12-19 12:44:57 +08:00
parent b576996ede
commit 1f3f5708a3
72 changed files with 3476 additions and 83 deletions

View File

@@ -0,0 +1,38 @@
## 修复API不可用问题
### 问题分析
1. **配置文件中API被禁用**:在`config.json`中,`http.enableAPI`设置为`false`
2. **缺少默认启用配置**:在`config/config.go``LoadConfig`函数中,没有为`EnableAPI`设置默认值
3. **API路由条件注册**:在`http/server.go`所有API端点都在`if s.config.EnableAPI`条件下注册
### 解决方案
#### 1. 修改配置文件启用API
`config.json`中的`http.enableAPI`值从`false`改为`true`立即启用API功能。
#### 2. 设置API默认启用
`config/config.go``LoadConfig`函数中添加默认值设置确保API在配置文件未指定时自动启用
```go
if !config.HTTP.EnableAPI {
config.HTTP.EnableAPI = true
}
```
### 实施步骤
1. 编辑`config.json`文件,将`http.enableAPI`设置为`true`
2. 修改`config/config.go`,在`LoadConfig`函数中添加API默认启用逻辑
3. 重启服务使配置生效
### 预期结果
- API端点将可用包括
- `/api/stats` - 统计信息
- `/api/shield` - 屏蔽规则管理
- `/api/shield/localrules` - 本地规则
- `/api/shield/remoterules` - 远程规则
- `/api/query` - DNS查询
- 以及其他统计和管理端点
- Swagger UI页面可通过`/api`访问
### 文件修改清单
1. `config.json` - 启用API
2. `config/config.go` - 添加API默认启用配置