1/*2Maddy Mail Server - Composable all-in-one email server.3Copyright © 2019-2020 Max Mazurov <fox.cpp@disroot.org>, Maddy Mail Server contributors45This program is free software: you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation, either version 3 of the License, or8(at your option) any later version.910This program is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13GNU General Public License for more details.1415You should have received a copy of the GNU General Public License16along with this program. If not, see <https://www.gnu.org/licenses/>.17*/1819package msgpipeline2021import (22 "github.com/foxcpp/maddy/framework/config"23 modconfig "github.com/foxcpp/maddy/framework/config/module"24 "github.com/foxcpp/maddy/framework/module"25)2627// CheckGroup is a module container for a group of Check implementations.28//29// It allows to share a set of filter configurations between using named30// configuration blocks (module instances) system.31//32// It is registered globally under the name 'checks'. The object does not33// implement any standard module interfaces besides module.Module and is34// specific to the message pipeline.35type CheckGroup struct {36 instName string37 L []module.Check38}3940func (cg *CheckGroup) Init(cfg *config.Map) error {41 for _, node := range cfg.Block.Children {42 chk, err := modconfig.MessageCheck(cfg.Globals, append([]string{node.Name}, node.Args...), node)43 if err != nil {44 return err45 }4647 cg.L = append(cg.L, chk)48 }4950 return nil51}5253func (CheckGroup) Name() string {54 return "checks"55}5657func (cg CheckGroup) InstanceName() string {58 return cg.instName59}6061func init() {62 module.Register("checks", func(_, instName string, _, _ []string) (module.Module, error) {63 return &CheckGroup{64 instName: instName,65 }, nil66 })67}