修改Swagger API文档

This commit is contained in:
Alex Yang
2025-11-30 00:52:10 +08:00
parent c34f1ed682
commit e800ad1774
25 changed files with 602 additions and 1646841 deletions
-5
View File
@@ -1,5 +0,0 @@
# DNS Server Hosts File
# Generated by DNS Server
127.0.0.1 localhost
::1 localhost
@@ -1 +0,0 @@
<!doctype html><html lang="en"><head><title>Example Domain</title><meta name="viewport" content="width=device-width, initial-scale=1"><style>body{background:#eee;width:60vw;margin:15vh auto;font-family:system-ui,sans-serif}h1{font-size:1.5em}div{opacity:0.8}a:link,a:visited{color:#348}</style><body><div><h1>Example Domain</h1><p>This domain is for use in documentation examples without needing permission. Avoid use in operations.<p><a href="https://iana.org/domains/example">Learn more</a></div></body></html>
-1
View File
@@ -1 +0,0 @@
||example.org^
-5
View File
@@ -1,5 +0,0 @@
{
"blockedDomainsCount": {},
"resolvedDomainsCount": {},
"lastSaved": "2025-11-29T23:50:20.5773272+08:00"
}
-6008
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
-1079
View File
File diff suppressed because it is too large Load Diff
-105448
View File
File diff suppressed because it is too large Load Diff
@@ -1 +0,0 @@
<!doctype html><html lang="en"><head><title>Example Domain</title><meta name="viewport" content="width=device-width, initial-scale=1"><style>body{background:#eee;width:60vw;margin:15vh auto;font-family:system-ui,sans-serif}h1{font-size:1.5em}div{opacity:0.8}a:link,a:visited{color:#348}</style><body><div><h1>Example Domain</h1><p>This domain is for use in documentation examples without needing permission. Avoid use in operations.<p><a href="https://iana.org/domains/example">Learn more</a></div></body></html>
+594 -262
View File
File diff suppressed because it is too large Load Diff
-1727
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -7,6 +7,7 @@ import (
"strings"
)
// testRuleMatching 测试DNS规则匹配功能
func main() {
// 定义命令行参数
rulePtr := flag.String("rule", "||cntvwb.cn^", "规则字符串")
@@ -22,10 +23,10 @@ func main() {
cmd := exec.Command("curl", "-s", fmt.Sprintf("http://localhost:8080/api/shield/check?domain=%s&rule=%s", *testDomainPtr, *rulePtr))
output, err := cmd.CombinedOutput()
if err != nil {
// 如果直接的API测试失败,尝试另一种方法:添加规则然后测试
// 如果直接的API测试失败,尝试另一种方法
fmt.Printf("直接测试失败: %v, %s\n", err, string(output))
fmt.Println("尝试添加规则并测试...")
testWithAddRule(*rulePtr, *testDomainPtr)
testAddRuleAndCheck(*rulePtr, *testDomainPtr)
return
}
@@ -42,21 +43,18 @@ func main() {
}
}
func testWithAddRule(rule, domain string) {
// testAddRuleAndCheck 测试添加规则和检查域名是否被阻止
func testAddRuleAndCheck(rule, domain string) {
// 尝试通过API添加规则
fmt.Printf("添加规则: %s\n", rule)
cmd := exec.Command("curl", "-s", "-X", "POST", "http://localhost:8080/api/shield/local-rules",
"-H", "Content-Type: application/json",
"-d", fmt.Sprintf(`{"rule":"%s"}`, rule))
cmd := exec.Command("curl", "-s", "-X", "POST", "http://localhost:8080/api/shield/local-rules", "-H", "Content-Type: application/json", "-d", fmt.Sprintf(`{\"rule\":\"%s\"}`, rule))
output, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf("添加规则失败: %v, %s\n", err, string(output))
// 尝试重新加载规则
fmt.Println("尝试重新加载规则...")
cmd = exec.Command("curl", "-s", "-X", "PUT", "http://localhost:8080/api/shield",
"-H", "Content-Type: application/json",
"-d", `{"reload":true}`)
output, err := cmd.CombinedOutput()
cmd = exec.Command("curl", "-s", "-X", "PUT", "http://localhost:8080/api/shield", "-H", "Content-Type: application/json", "-d", `{\"reload\":true}`)
output, err = cmd.CombinedOutput()
if err != nil {
fmt.Printf("重新加载规则失败: %v, %s\n", err, string(output))
} else {