1//go:build ignore2// +build ignore34/*5Maddy Mail Server - Composable all-in-one email server.6Copyright © 2019-2020 Max Mazurov <fox.cpp@disroot.org>, Maddy Mail Server contributors78This program is free software: you can redistribute it and/or modify9it under the terms of the GNU General Public License as published by10the Free Software Foundation, either version 3 of the License, or11(at your option) any later version.1213This program is distributed in the hope that it will be useful,14but WITHOUT ANY WARRANTY; without even the implied warranty of15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16GNU General Public License for more details.1718You should have received a copy of the GNU General Public License19along with this program. If not, see <https://www.gnu.org/licenses/>.20*/2122/*23This is example of a minimal stateful check module implementation.24See HACKING.md in the repo root for implementation recommendations.25*/2627package directory_name_here2829import (30 "context"3132 "github.com/emersion/go-message/textproto"33 "github.com/foxcpp/maddy/framework/buffer"34 "github.com/foxcpp/maddy/framework/config"35 "github.com/foxcpp/maddy/framework/log"36 "github.com/foxcpp/maddy/framework/module"37 "github.com/foxcpp/maddy/internal/target"38)3940const modName = "check_things"4142type Check struct {43 instName string44 log log.Logger45}4647func New(modName, instName string, aliases, inlineArgs []string) (module.Module, error) {48 return &Check{49 instName: instName,50 }, nil51}5253func (c *Check) Name() string {54 return modName55}5657func (c *Check) InstanceName() string {58 return c.instName59}6061func (c *Check) Init(cfg *config.Map) error {62 return nil63}6465type state struct {66 c *Check67 msgMeta *module.MsgMetadata68 log log.Logger69}7071func (c *Check) CheckStateForMsg(ctx context.Context, msgMeta *module.MsgMetadata) (module.CheckState, error) {72 return &state{73 c: c,74 msgMeta: msgMeta,75 log: target.DeliveryLogger(c.log, msgMeta),76 }, nil77}7879func (s *state) CheckConnection(ctx context.Context) module.CheckResult {80 return module.CheckResult{}81}8283func (s *state) CheckSender(ctx context.Context, addr string) module.CheckResult {84 return module.CheckResult{}85}8687func (s *state) CheckRcpt(ctx context.Context, addr string) module.CheckResult {88 return module.CheckResult{}89}9091func (s *state) CheckBody(ctx context.Context, hdr textproto.Header, body buffer.Buffer) module.CheckResult {92 return module.CheckResult{}93}9495func (s *state) Close() error {96 return nil97}9899func init() {100 module.Register(modName, New)101}