MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / runAction

Method runAction

internal/iplibrary/action_script.go:45–67  ·  view source on GitHub ↗
(action string, listType IPListType, item *pb.IPItem)

Source from the content-addressed store, hash-verified

43}
44
45func (this *ScriptAction) runAction(action string, listType IPListType, item *pb.IPItem) error {
46 // TODO 智能支持 .sh 脚本文件
47 var cmd = executils.NewTimeoutCmd(30*time.Second, this.config.Path)
48 cmd.WithEnv([]string{
49 "ACTION=" + action,
50 "TYPE=" + item.Type,
51 "IP_FROM=" + item.IpFrom,
52 "IP_TO=" + item.IpTo,
53 "EXPIRED_AT=" + fmt.Sprintf("%d", item.ExpiredAt),
54 "LIST_TYPE=" + listType,
55 })
56 if len(this.config.Cwd) > 0 {
57 cmd.WithDir(this.config.Cwd)
58 } else {
59 cmd.WithDir(filepath.Dir(this.config.Path))
60 }
61 cmd.WithStderr()
62 err := cmd.Run()
63 if err != nil {
64 return fmt.Errorf("%w, output: %s", err, cmd.Stderr())
65 }
66 return nil
67}

Callers 2

AddItemMethod · 0.95
DeleteItemMethod · 0.95

Calls 6

WithEnvMethod · 0.80
WithDirMethod · 0.80
WithStderrMethod · 0.80
ErrorfMethod · 0.80
StderrMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected