maddy/internal/module/dummy.go
fox.cpp bf188e454f
Move most code from the repo root into subdirectories
The intention is to keep to repo root clean while the list of packages
is slowly growing.

Additionally, a bunch of small (~30 LoC) files in the repo root is
merged into a single maddy.go file, for the same reason.

Most of the internal code is moved into the internal/ directory. Go
toolchain will make it impossible to import these packages from external
applications.

Some packages are renamed and moved into the pkg/ directory in the root.
According to https://github.com/golang-standards/project-layout this is
the de-facto standard to place "library code that's ok to use by
external applications" in.

To clearly define the purpose of top-level directories, README.md files
are added to each.
2019-12-06 01:35:12 +03:00

58 lines
1.2 KiB
Go

package module
import (
"github.com/emersion/go-message/textproto"
"github.com/foxcpp/maddy/internal/buffer"
"github.com/foxcpp/maddy/internal/config"
)
// Dummy is a struct that implements AuthProvider and DeliveryTarget
// interfaces but does nothing. Useful for testing.
//
// It is always registered under the 'dummy' name and can be used in both tests
// and the actual server code (but the latter is kinda pointless).
type Dummy struct{ instName string }
func (d *Dummy) CheckPlain(_, _ string) bool {
return true
}
func (d *Dummy) Name() string {
return "dummy"
}
func (d *Dummy) InstanceName() string {
return d.instName
}
func (d *Dummy) Init(_ *config.Map) error {
return nil
}
func (d *Dummy) Start(msgMeta *MsgMetadata, mailFrom string) (Delivery, error) {
return dummyDelivery{}, nil
}
type dummyDelivery struct{}
func (dd dummyDelivery) AddRcpt(to string) error {
return nil
}
func (dd dummyDelivery) Body(header textproto.Header, body buffer.Buffer) error {
return nil
}
func (dd dummyDelivery) Abort() error {
return nil
}
func (dd dummyDelivery) Commit() error {
return nil
}
func init() {
Register("dummy", func(_, instName string, _, _ []string) (Module, error) {
return &Dummy{instName: instName}, nil
})
}