{"modulePath":"github.com/foxcpp/maddy","version":"v0.9.8","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package modconfig\n\nPackage modconfig provides matchers for config.Map that query modules registry and parse inline module definitions.\n\nThey should be used instead of manual querying when there is need to reference a module instance in the configuration.\n\nSee ModuleFromNode documentation for explanation of what is 'args' for some functions (DeliveryTarget).\n\n## Functions\n\n```go\nfunc DeliveryDirective(m *config.Map, node config.Node) (interface{}, error)\n```\nDeliveryDirective is a callback for use in config.Map.Custom.\n\nIt does all work necessary to create a module instance from the config directive with the following structure:\n\n\tdirective_name mod_name [inst_name] [{\n\t  inline_mod_config\n\t}]\n\nNote that if used configuration structure lacks directive\\_name before mod\\_name - this function should not be used (call DeliveryTarget directly).\n\n```go\nfunc DeliveryTarget(globals map[string]interface{}, args []string, block config.Node) (module.DeliveryTarget, error)\n```\n\n```go\nfunc FailActionDirective(_ *config.Map, node config.Node) (interface{}, error)\n```\n\n```go\nfunc GroupFromNode(defaultModule string, args []string, inlineCfg config.Node, globals map[string]interface{}, moduleIface interface{}) error\n```\nGroupFromNode provides a special kind of ModuleFromNode syntax that allows to omit the module name when defining inine configuration.  If it is not present, name in defaultModule is used.\n\n```go\nfunc IMAPFilter(globals map[string]interface{}, args []string, block config.Node) (module.IMAPFilter, error)\n```\n\n```go\nfunc MessageCheck(globals map[string]interface{}, args []string, block config.Node) (module.Check, error)\n```\n\n```go\nfunc ModuleFromNode(preferredNamespace string, args []string, inlineCfg config.Node, globals map[string]interface{}, moduleIface interface{}) error\n```\nModuleFromNode does all work to create or get existing module object with a certain type. It is not used by top-level module definitions, only for references from other modules configuration blocks.\n\ninlineCfg should contain configuration directives for inline declarations. args should contain values that are used to create module. It should be either module name + instance name or just module name. Further extensions may add other string arguments (currently, they can be accessed by module instances as inlineArgs argument to constructor).\n\nIt checks using reflection whether it is possible to store a module object into modObj pointer (e.g. it implements all necessary interfaces) and stores it if everything is fine. If module object doesn't implement necessary module interfaces - error is returned. If modObj is not a pointer, ModuleFromNode panics.\n\npreferredNamespace is used as an implicit prefix for module name lookups. Module with name preferredNamespace + \".\" + args\\[0] will be preferred over just args\\[0]. It can be omitted.\n\n```go\nfunc MsgModifier(globals map[string]interface{}, args []string, block config.Node) (module.Modifier, error)\n```\n\n```go\nfunc ParseRejectDirective(args []string) (*exterrors.SMTPError, error)\n```\n\n```go\nfunc StorageDirective(m *config.Map, node config.Node) (interface{}, error)\n```\n\n```go\nfunc Table(cfg *config.Map, name string, inheritGlobal, required bool, defaultVal module.Table, store *module.Table)\n```\nTable is a convenience wrapper for TableDirective.\n\n\tcfg.Bool(...)\n\tmodconfig.Table(cfg, \"auth_map\", false, false, nil, \u0026mod.authMap)\n\tcfg.Process()\n\n```go\nfunc TableDirective(m *config.Map, node config.Node) (interface{}, error)\n```\n\n## Types\n\n```go\ntype FailAction struct {\n\tQuarantine bool\n\tReject     bool\n\n\tReasonOverride *exterrors.SMTPError\n}\n```\nFailAction specifies actions that messages pipeline should take based on the result of the check.\n\nIts check module responsibility to apply FailAction on the CheckResult it returns. It is intended to be used as follows:\n\nAdd the configuration directive to allow user to specify the action:\n\n\tcfg.Custom(\"SOME_action\", false, false,\n\t\tfunc() (interface{}, error) {\n\t\t\treturn modconfig.FailAction{Quarantine: true}, nil\n\t\t}, modconfig.FailActionDirective, \u0026yourModule.SOMEAction)\n\nreturn in func literal is the default value, you might want to adjust it.\n\nCall yourModule.SOMEAction.Apply on CheckResult containing only the Reason field:\n\n\tfunc (yourModule YourModule) CheckConnection() module.CheckResult {\n\t    return yourModule.SOMEAction.Apply(module.CheckResult{\n\t        Reason: ...,\n\t    })\n\t}\n\n```go\nfunc ParseActionDirective(args []string) (FailAction, error)\n```\n\n```go\nfunc (cfa FailAction) Apply(originalRes module.CheckResult) module.CheckResult\n```\nApply merges the result of check execution with action configuration specified in the check configuration.\n\n","path":"github.com/foxcpp/maddy/framework/config/module","name":"modconfig","synopsis":"Package modconfig provides matchers for config.Map that query modules registry and parse inline module definitions.","isRedistributable":true}
