MCPcopy Create free account
hub / github.com/foxcpp/maddy / Configure

Method Configure

internal/check/command/command.go:96–141  ·  view source on GitHub ↗
(inlineArgs []string, cfg *config.Map)

Source from the content-addressed store, hash-verified

94}
95
96func (c *Check) Configure(inlineArgs []string, cfg *config.Map) error {
97 if len(inlineArgs) == 0 {
98 return errors.New("command: at least one argument is required (command name)")
99 }
100
101 c.cmd = inlineArgs[0]
102 c.cmdArgs = inlineArgs[1:]
103
104 // Check whether the inline argument command is usable.
105 if _, err := exec.LookPath(c.cmd); err != nil {
106 return fmt.Errorf("command: %w", err)
107 }
108
109 cfg.Enum("run_on", false, false,
110 []string{StageConnection, StageSender, StageRcpt, StageBody}, StageBody,
111 (*string)(&c.stage))
112
113 cfg.AllowUnknown()
114 unknown, err := cfg.Process()
115 if err != nil {
116 return err
117 }
118
119 for _, node := range unknown {
120 switch node.Name {
121 case "code":
122 if len(node.Args) < 2 {
123 return config.NodeErr(node, "at least two arguments are required: <code> <action>")
124 }
125 exitCode, err := strconv.Atoi(node.Args[0])
126 if err != nil {
127 return config.NodeErr(node, "%v", err)
128 }
129 action, err := modconfig.ParseActionDirective(node.Args[1:])
130 if err != nil {
131 return config.NodeErr(node, "%v", err)
132 }
133
134 c.actions[exitCode] = action
135 default:
136 return config.NodeErr(node, "unexpected directive: %v", node.Name)
137 }
138 }
139
140 return nil
141}
142
143type state struct {
144 c *Check

Callers

nothing calls this directly

Implementers 10

Checkinternal/testutils/check.go
Checkinternal/check/skeleton.go
statelessCheckinternal/check/stateless_check.go
Checkinternal/check/spf/spf.go
DNSBLinternal/check/dnsbl/dnsbl.go
Checkinternal/check/rspamd/rspamd.go
Checkinternal/check/command/command.go
Checkinternal/check/dkim/dkim.go
Checkinternal/check/milter/milter.go
Checkinternal/check/authorize_sender/author

Calls 4

NodeErrFunction · 0.92
EnumMethod · 0.80
AllowUnknownMethod · 0.80
ProcessMethod · 0.80

Tested by

no test coverage detected