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

Method executeCSV

internal/cmd/csv.go:14–84  ·  view source on GitHub ↗

executeCSV 从CSV文件批量检测域名

(csvFile string)

Source from the content-addressed store, hash-verified

12
13// executeCSV 从CSV文件批量检测域名
14func (r *RootCmd) executeCSV(csvFile string) {
15 // 检查文件是否存在
16 if _, err := os.Stat(csvFile); os.IsNotExist(err) {
17 ui.PrintErrorWithDetails(
18 fmt.Sprintf("错误:CSV文件不存在 '%s'", csvFile),
19 "请使用 RealiTLScanner 工具扫描,得到 CSV 文件",
20 "命令:./RealiTLScanner -addr <VPS IP> -port 443 -thread 100 -timeout 5 -out file.csv",
21 "(提示:RealiTLScanner 尽量在本地运行,不要在远端)",
22 "(重要:多次运行时请更改输出文件名,如 file1.csv、file2.csv 等)",
23 )
24 return
25 }
26
27 // 读取CSV文件
28 file, err := os.Open(csvFile)
29 if err != nil {
30 ui.PrintError(fmt.Sprintf("错误:无法打开CSV文件 '%s': %v", csvFile, err))
31 return
32 }
33 defer file.Close()
34
35 // 解析CSV
36 reader := csv.NewReader(file)
37 records, err := reader.ReadAll()
38 if err != nil {
39 ui.PrintErrorWithDetails(
40 fmt.Sprintf("错误:解析CSV文件失败: %v", err),
41 "请使用 RealiTLScanner 工具扫描,得到 CSV 文件",
42 "命令:./RealiTLScanner -addr <VPS IP> -port 443 -thread 100 -timeout 5 -out file.csv",
43 "(提示:RealiTLScanner 尽量在本地运行,不要在远端)",
44 "(重要:多次运行时请更改输出文件名,如 file1.csv、file2.csv 等)",
45 )
46 return
47 }
48
49 if len(records) < 2 {
50 ui.PrintErrorWithDetails(
51 "错误:CSV文件格式错误或为空",
52 "请使用 RealiTLScanner 工具扫描,得到 CSV 文件",
53 "命令:./RealiTLScanner -addr <VPS IP> -port 443 -thread 100 -timeout 5 -out file.csv",
54 "(提示:RealiTLScanner 尽量在本地运行,不要在远端)",
55 "(重要:多次运行时请更改输出文件名,如 file1.csv、file2.csv 等)",
56 )
57 return
58 }
59
60 // 提取域名(从CERT_DOMAIN列)
61 domains := extractDomainsFromCSV(records)
62 if len(domains) == 0 {
63 ui.PrintErrorWithDetails(
64 "错误:未找到有效的域名",
65 "请使用 RealiTLScanner 工具扫描,得到 CSV 文件",
66 "命令:./RealiTLScanner -addr <VPS IP> -port 443 -thread 100 -timeout 5 -out file.csv",
67 "(提示:RealiTLScanner 尽量在本地运行,不要在远端)",
68 "(重要:多次运行时请更改输出文件名,如 file1.csv、file2.csv 等)",
69 )
70 return
71 }

Callers 1

ExecuteMethod · 0.95

Calls 6

PrintErrorWithDetailsFunction · 0.92
PrintErrorFunction · 0.92
PrintTimestampedMessageFunction · 0.92
PrintAdvertisementFunction · 0.92
extractDomainsFromCSVFunction · 0.85
CheckDomainsMethod · 0.45

Tested by

no test coverage detected