Documentation ¶
Index ¶
- func FailActionDirective(m *config.Map, node config.Node) (interface{}, error)
- func ParseRejectDirective(args []string) (*exterrors.SMTPError, error)
- func RegisterStatelessCheck(name string, defaultFailAction FailAction, connCheck FuncConnCheck, ...)
- type FailAction
- type FuncBodyCheck
- type FuncConnCheck
- type FuncRcptCheck
- type FuncSenderCheck
- type StatelessCheckContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FailActionDirective ¶
func RegisterStatelessCheck ¶
func RegisterStatelessCheck(name string, defaultFailAction FailAction, connCheck FuncConnCheck, senderCheck FuncSenderCheck, rcptCheck FuncRcptCheck, bodyCheck FuncBodyCheck)
RegisterStatelessCheck is helper function to create stateless message check modules that run one simple check during one stage.
It creates the module and its instance with the specified name that implement module.Check interface and runs passed functions when corresponding module.CheckState methods are called.
Note about CheckResult that is returned by the functions: StatelessCheck supports different action types based on the user configuration, but the particular check code doesn't need to know about it. It should assume that it is always "Reject" and hence it should populate Reason field of the result object with the relevant error description.
Types ¶
type FailAction ¶
FailAction specifies actions that messages pipeline should take based on the result of the check.
Its check module responsibility to apply FailAction on the CheckResult it returns. It is intended to be used as follows:
Add the configuration directive to allow user to specify the action:
cfg.Custom("SOME_action", false, false, func() (interface{}, error) { return check.FailAction{Quarantine: true}, nil }, check.FailActionDirective, &yourModule.SOMEAction)
return in func literal is the default value, you might want to adjust it.
Call yourModule.SOMEAction.Apply on CheckResult containing only the Reason field:
func (yourModule YourModule) CheckConnection() module.CheckResult { return yourModule.SOMEAction.Apply(module.CheckResult{ Reason: ..., }) }
func ParseActionDirective ¶
func ParseActionDirective(args []string) (FailAction, error)
func (FailAction) Apply ¶
func (cfa FailAction) Apply(originalRes module.CheckResult) module.CheckResult
Apply merges the result of check execution with action configuration specified in the check configuration.
type FuncBodyCheck ¶
type FuncBodyCheck func(checkContext StatelessCheckContext, header textproto.Header, body buffer.Buffer) module.CheckResult
type FuncConnCheck ¶
type FuncConnCheck func(checkContext StatelessCheckContext) module.CheckResult
type FuncRcptCheck ¶
type FuncRcptCheck func(checkContext StatelessCheckContext, rcptTo string) module.CheckResult
type FuncSenderCheck ¶
type FuncSenderCheck func(checkContext StatelessCheckContext, mailFrom string) module.CheckResult
type StatelessCheckContext ¶
type StatelessCheckContext struct { // Embedded context.Context value, used for tracing, cancellation and // timeouts. context.Context // Resolver that should be used by the check for DNS queries. Resolver dns.Resolver MsgMeta *module.MsgMetadata // Logger that should be used by the check for logging, note that it is // already wrapped to append Msg ID to all messages so check code // should not do the same. Logger log.Logger }