diff --git a/README.md b/README.md index d53b55f..74d6198 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ go build -o dns-server main.go ### 主要配置项 - `ListenPort`: DNS服务器监听端口,默认53 -- `HTTPPort`: HTTP控制台监听端口,默认8080 +- `HTTPPort`: HTTP控制台监听端口,默认8081 - `StatsFile`: 统计数据保存文件,默认`data/stats.json` - `SaveInterval`: 自动保存间隔(秒),默认300 - `MaxQueryLogs`: 最大保存日志数量,默认1000 @@ -237,46 +237,86 @@ http://localhost:8081 #### 1. DNS查询 ``` -GET /api/query?domain=example.com +GET /api/query?domain=example.com # 查询域名屏蔽状态 +GET /api/domains/{domain} # RESTful风格域名查询 ``` #### 2. 屏蔽规则管理 ``` -GET /api/shield/rules -POST /api/shield/rules -DELETE /api/shield/rules/:id +GET /api/shield # 获取Shield配置 +POST /api/shield # 添加屏蔽规则 +GET /api/shield/localrules # 获取本地规则 +GET /api/shield/remoterules # 获取远程规则 +GET /api/shield/hosts # 获取hosts列表 +POST /api/shield/hosts # 添加hosts条目 +DELETE /api/shield/hosts # 删除hosts条目 +GET /api/shield/blacklists # 获取黑名单列表 +POST /api/shield/blacklists # 添加黑名单 +PUT /api/shield/blacklists/:name # 更新黑名单 +DELETE /api/shield/blacklists/:name # 删除黑名单 ``` -#### 3. Hosts管理 +#### 3. 统计信息 ``` -GET /api/hosts -POST /api/hosts -DELETE /api/hosts/:id +GET /api/stats # 获取系统统计信息 +GET /api/top-blocked # 获取最常屏蔽域名 +GET /api/top-resolved # 获取最常解析域名 +GET /api/top-clients # 获取TOP客户端 +GET /api/top-domains # 获取TOP域名 +GET /api/recent-blocked # 获取最近屏蔽域名 +GET /api/hourly-stats # 获取24小时统计 +GET /api/daily-stats # 获取每日统计 +GET /api/monthly-stats # 获取每月统计 +GET /api/query/type # 获取查询类型统计 ``` #### 4. 查询日志 ``` -GET /api/logs/stats -GET /api/logs/query -GET /api/logs/count +GET /api/logs/stats # 获取日志统计 +GET /api/logs/query # 查询日志 +GET /api/logs/count # 获取日志总数 ``` -#### 5. WebSocket +#### 5. 系统管理 ``` -ws://localhost:8080/ws/stats +GET /api/status # 获取系统状态 +GET /api/config # 获取系统配置 +POST /api/config # 更新系统配置 +POST /api/config/restart # 重启服务 ``` -#### 6. 域名信息管理 +#### 6. 认证管理 ``` -GET /api/domain-info # 获取域名信息列表 -POST /api/domain-info/update # 更新所有域名信息 -POST /api/domain-info/update/{type} # 更新指定类型的域名信息 -GET /api/domain-info/query?domain=xxx # 查询单个域名的详细信息 +POST /api/login # 用户登录 +POST /api/logout # 用户注销 +POST /api/change-password # 修改密码 +``` + +#### 7. 威胁管理 + +``` +GET /api/threat?domain=example.com # 查询威胁域名信息 +POST /api/threat/batch # 批量查询威胁域名 +GET /api/alert # 获取威胁告警列表 +POST /api/alert/resolve # 解决威胁告警 +``` + +#### 8. 域名信息管理 + +``` +GET /api/domain-info # 获取域名信息列表 +POST /api/domain/info # 查询域名详细信息 +``` + +#### 9. WebSocket + +``` +ws://localhost:8081/ws/stats # 实时统计数据 ``` ## 开发说明 @@ -330,6 +370,20 @@ MIT License ## 更新日志 +### v1.0.2 (2026-04-12) + +- 更新API文档,添加完整的API端点列表 +- 更新swagger.json文件,提升版本至2.2.0 +- 完善威胁管理和域名信息管理API +- 优化系统统计和日志查询功能 + +### v1.0.1 (2025-11-30) + +- 修复搜索和过滤功能 +- 优化查询日志显示 +- 修复样式间隔问题 +- 添加查询日志刷新按钮 + ### v1.0.0 (2025-11-30) - 初始版本 @@ -340,13 +394,6 @@ MIT License - 实现WebSocket实时更新 - 实现查询日志持久化 -### v1.0.1 (2025-11-30) - -- 修复搜索和过滤功能 -- 优化查询日志显示 -- 修复样式间隔问题 -- 添加查询日志刷新按钮 - ## 致谢 感谢所有为该项目做出贡献的开源项目和开发者! diff --git a/config/config.go b/config/config.go index 6e9cf02..6ee1805 100644 --- a/config/config.go +++ b/config/config.go @@ -177,7 +177,7 @@ func LoadConfig(path string) (*Config, error) { DomainSpecificDNS: parseDomainSpecificDNS(cfg.Section("dns")), }, HTTP: HTTPConfig{ - Port: cfg.Section("http").Key("port").MustInt(8080), + Port: cfg.Section("http").Key("port").MustInt(8081), Host: cfg.Section("http").Key("host").MustString("0.0.0.0"), EnableAPI: cfg.Section("http").Key("enableAPI").MustBool(true), Username: cfg.Section("http").Key("username").MustString("admin"), diff --git a/static/api/swagger.json b/static/api/swagger.json index ee0ed8c..86fccb0 100644 --- a/static/api/swagger.json +++ b/static/api/swagger.json @@ -2,15 +2,15 @@ "openapi": "3.0.3", "info": { "title": "DNS Server API", - "description": "DNS 服务器完整 API 文档,包括统计信息、Shield 管理、威胁查询等功能。", - "version": "2.1.0", + "description": "DNS 服务器完整 API 文档,包括统计信息、Shield 管理、威胁查询、域名信息管理等功能。", + "version": "2.2.0", "contact": { "name": "DNS Server 支持", - "email": "support@dnsserver.com" + "email": "wxf26054@live.cn" }, "license": { - "name": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + "name": "MIT License", + "url": "https://opensource.org/licenses/MIT" } }, "servers": [