-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
58 lines (48 loc) · 1.26 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"flag"
"fmt"
"os"
"runtime"
)
var (
dirPath string
statsTypes string
suffix string
overwrite bool
yes bool
workers int
)
func init() {
flag.StringVar(&dirPath, "dir", ".", "Directory to search for .pcap or .pcapng files")
flag.StringVar(&statsTypes, "stats", "", "Statistics types (space-separated) or path to file containing types")
flag.StringVar(&suffix, "suffix", ".stats-total.txt", "Suffix for resulting statistics files")
flag.BoolVar(&overwrite, "overwrite", false, "Overwrite existing statistics files")
flag.BoolVar(&yes, "yes", false, "Process files without asking for confirmation")
flag.IntVar(&workers, "workers", runtime.NumCPU(), "Number of files to process in parallel")
}
func main() {
flag.Parse()
files, err := findPcapFiles(dirPath, overwrite, suffix)
if err != nil {
fmt.Printf("Error finding files: %v\n", err)
os.Exit(1)
}
if len(files) == 0 {
fmt.Println("No pcap or pcapng files need processing.")
return
}
displayFiles(files)
if !yes {
if !confirm("Do you want to proceed? (y/n): ") {
fmt.Println("Aborted.")
return
}
}
args, err := buildArgs(statsTypes)
if err != nil {
fmt.Printf("Error building arguments: %v\n", err)
os.Exit(1)
}
processFiles(files, args)
}