详细了解绮梦DNS的API接口
/api/shield
{"rules": [
{"id": 1, "pattern": "example.com", "type": "domain", "count": 10},
{"id": 2, "pattern": ".*\\.test\\.com", "type": "regex", "count": 5}
]}
/api/shield
{"pattern": "example.com", "type": "domain"}
{"success": true, "message": "规则添加成功"}
/api/shield/:id
{"success": true, "message": "规则删除成功"}
/api/hosts
{"rules": [
{"id": 1, "ip": "127.0.0.1", "domain": "localhost"},
{"id": 2, "ip": "192.168.1.1", "domain": "router.local"}
]}
/api/query?domain=example.com
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| domain | string | 是 | 要查询的域名 |
| type | string | 否 | 查询类型,默认A |
{"domain": "example.com", "type": "A", "result": "allowed", "ip": "93.184.216.34", "blockRule": ""}
/api/logs/query
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| limit | int | 否 | 返回记录数,默认30 |
| offset | int | 否 | 偏移量,默认0 |
| sortField | string | 否 | 排序字段,默认time |
| sortDirection | string | 否 | 排序方向,asc或desc,默认desc |
[{"id": 1, "time": "2025-11-30T12:00:00Z", "domain": "example.com", "type": "A", "result": "allowed", "rule": ""}, {"id": 2, "time": "2025-11-30T11:59:00Z", "domain": "test.com", "type": "AAAA", "result": "blocked", "rule": "test.com"}]
/api/logs/stats
{"total": 1000, "allowed": 800, "blocked": 200, "today": 100, "trend": [10, 15, 20, 25, 30, 35, 40]}
/api/stats
{"totalQueries": 1000, "blockedQueries": 200, "allowedQueries": 800, "queryTypes": {"A": 600, "AAAA": 200, "CNAME": 100, "MX": 50, "NS": 50}}
WebSocket连接用于实时推送统计数据和系统状态。
ws://localhost:8080/ws
{"type": "stats", "data": {"total": 1000, "allowed": 800, "blocked": 200}}