-
Notifications
You must be signed in to change notification settings - Fork 43
/
traffic.go
40 lines (37 loc) · 1010 Bytes
/
traffic.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
package yakcmds
import (
"github.com/urfave/cli"
"github.com/yaklang/yaklang/common/chaosmaker/rule"
"github.com/yaklang/yaklang/common/consts"
"github.com/yaklang/yaklang/common/utils"
)
var TrafficUtilCommands = []*cli.Command{
// chaosmaker
{
Name: "import-chaosmaker-json",
Usage: "Import ChaosMaker Rules from JSON File",
Flags: []cli.Flag{
cli.StringFlag{Name: "file,f"},
},
Action: func(c *cli.Context) error {
file := utils.GetFirstExistedFile(c.String("file"))
if file == "" {
return utils.Errorf("file not found: %v", c.String("file"))
}
return rule.ImportRulesFromFile(consts.GetGormProfileDatabase(), file)
},
},
{
Name: "export-chaosmaker-json",
Usage: "Export ChaosMaker Rules to JSON File",
Flags: []cli.Flag{
cli.StringFlag{Name: "file,f"},
},
Action: func(c *cli.Context) error {
return rule.ExportRulesToFile(consts.GetGormProfileDatabase(), c.String("file"))
},
},
&chaosMakerCommand,
&suricataLoaderCommand,
&pcapCommand,
}