-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (43 loc) · 866 Bytes
/
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
package main
import (
"fmt"
"os"
"strings"
)
const (
usageFmt = "Usage: %s [ -D ] script.js file.pcap [ outdir ] \n"
)
func main() {
os.Exit(run())
}
func run() (exitCode int) {
args := os.Args[1:]
if len(args) > 0 && args[0] == "-D" { // debug mode
debugFlag = true
args = args[1:]
}
if len(args) < 2 {
fmt.Fprintf(os.Stderr, usageFmt, os.Args[0])
exitCode = 1
return
}
scriptFile := args[0]
pcapFile := args[1]
outdir := "."
if len(args) > 2 {
outdir = args[2]
}
outdir = strings.TrimSpace(outdir)
if outdir == "" || outdir == "/" {
outdir = "."
}
debug("scriptFile =", scriptFile)
debug("pcapFile =", pcapFile)
debug("outdir =", outdir)
err := process(scriptFile, pcapFile, outdir)
if err != nil {
fmt.Fprintln(os.Stderr, err)
exitCode = 2
}
return
}