-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
38 lines (31 loc) · 1.29 KB
/
main.go
File metadata and controls
38 lines (31 loc) · 1.29 KB
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
package main
import (
"github.com/alecthomas/kong"
log "github.com/sirupsen/logrus"
"os"
"tarpit-analyzer/cli"
"tarpit-analyzer/cli/modules"
"tarpit-analyzer/helper"
)
var cliStruct struct {
Debug bool `short:"d" default:"false" help:"Enable debug mode."`
Target string `short:"t" help:"filename where output should be saved" type:"path"`
StartDate string `default:"unset" help:"Only consider data starting at <yyyy-mm-dd>"`
EndDate string `default:"unset" help:"Only consider data ending at <yyyy-mm-dd>"`
Import modules.ImportCmd `cmd:"" help:"ImportCmd logs from different tarpit apps."`
Resolve modules.ResolveCmd `cmd:"" help:"Resolve all IP's which haven't a corresponding GeoLocation value."`
Analyze modules.AnalyzeCmd `cmd:"" help:"Analyze file."`
Export modules.ExportCmd `cmd:"" help:"Export to different formats"`
}
func main() {
file, errLog := os.OpenFile("logrus.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if errLog == nil {
log.SetOutput(file)
} else {
log.Info("Failed to log to file, using default stderr")
}
log.AddHook(helper.NewConsoleHook(false))
ctx := kong.Parse(&cliStruct)
err := ctx.Run(&cli.Context{Debug: cliStruct.Debug, Target: cliStruct.Target, StartDate: cliStruct.StartDate, EndDate: cliStruct.EndDate})
ctx.FatalIfErrorf(err)
}