MCPcopy Create free account
hub / github.com/V2RaySSR/RealityChecker / executeCheck

Method executeCheck

internal/cmd/check.go:15–46  ·  view source on GitHub ↗

executeCheck 执行单域名检测

(domain string)

Source from the content-addressed store, hash-verified

13
14// executeCheck 执行单域名检测
15func (r *RootCmd) executeCheck(domain string) {
16 // 验证域名格式
17 domain = strings.TrimSpace(domain)
18 if !isValidDomain(domain) {
19 ui.PrintErrorWithDetails(
20 fmt.Sprintf("错误:域名格式无效 '%s'", domain),
21 "提示:请检查域名格式,例如:apple.com, google.com",
22 "域名要求:",
23 " - 只能包含字母、数字、连字符和点",
24 " - 不能以点开头或结尾",
25 " - 不能包含连续的点",
26 " - 长度不超过253个字符",
27 )
28 return
29 }
30
31 ui.PrintTimestampedMessage("开始检测域名: %s", domain)
32
33 result, err := r.engine.CheckDomain(r.ctx, domain)
34 if err != nil {
35 fmt.Printf("检测失败: %v\n", err)
36 return
37 }
38
39 // 使用格式化器输出结果
40 cfg, _ := config.LoadConfig("")
41 formatter := report.NewFormatter(cfg)
42 fmt.Printf("\n%s", formatter.FormatSingleResult(result))
43
44 // 显示广告
45 ui.PrintAdvertisement()
46}
47
48// isValidDomain 验证域名格式是否有效
49func isValidDomain(domain string) bool {

Callers 1

ExecuteMethod · 0.95

Calls 8

FormatSingleResultMethod · 0.95
PrintErrorWithDetailsFunction · 0.92
PrintTimestampedMessageFunction · 0.92
LoadConfigFunction · 0.92
NewFormatterFunction · 0.92
PrintAdvertisementFunction · 0.92
isValidDomainFunction · 0.85
CheckDomainMethod · 0.80

Tested by

no test coverage detected