mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 18:17:03 +00:00
Inversion of Control for smtpd.Server
Allow more control over how Server is instaniated so that it can be unit tested.
This commit is contained in:
@@ -94,6 +94,9 @@ func main() {
|
|||||||
fmt.Fprintf(pidf, "%v\n", os.Getpid())
|
fmt.Fprintf(pidf, "%v\n", os.Getpid())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Grab our datastore
|
||||||
|
ds := smtpd.DefaultFileDataStore()
|
||||||
|
|
||||||
// Start HTTP server
|
// Start HTTP server
|
||||||
go web.Start()
|
go web.Start()
|
||||||
|
|
||||||
@@ -102,7 +105,7 @@ func main() {
|
|||||||
go pop3Server.Start()
|
go pop3Server.Start()
|
||||||
|
|
||||||
// Startup SMTP server, block until it exits
|
// Startup SMTP server, block until it exits
|
||||||
smtpServer = smtpd.New()
|
smtpServer = smtpd.NewSmtpServer(config.GetSmtpConfig(), ds)
|
||||||
smtpServer.Start()
|
smtpServer.Start()
|
||||||
|
|
||||||
// Wait for active connections to finish
|
// Wait for active connections to finish
|
||||||
|
|||||||
@@ -46,9 +46,7 @@ var expErrorsHist = new(expvar.String)
|
|||||||
var expWarnsHist = new(expvar.String)
|
var expWarnsHist = new(expvar.String)
|
||||||
|
|
||||||
// Init a new Server object
|
// Init a new Server object
|
||||||
func New() *Server {
|
func NewSmtpServer(cfg config.SmtpConfig, ds DataStore) *Server {
|
||||||
ds := DefaultFileDataStore()
|
|
||||||
cfg := config.GetSmtpConfig()
|
|
||||||
return &Server{dataStore: ds, domain: cfg.Domain, maxRecips: cfg.MaxRecipients,
|
return &Server{dataStore: ds, domain: cfg.Domain, maxRecips: cfg.MaxRecipients,
|
||||||
maxIdleSeconds: cfg.MaxIdleSeconds, maxMessageBytes: cfg.MaxMessageBytes,
|
maxIdleSeconds: cfg.MaxIdleSeconds, maxMessageBytes: cfg.MaxMessageBytes,
|
||||||
storeMessages: cfg.StoreMessages, domainNoStore: strings.ToLower(cfg.DomainNoStore),
|
storeMessages: cfg.StoreMessages, domainNoStore: strings.ToLower(cfg.DomainNoStore),
|
||||||
|
|||||||
Reference in New Issue
Block a user