mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
config: Replace robfig with envconfig for #86
- Initial envconfig system is working, not bulletproof. - Added sane defaults for required parameters.
This commit is contained in:
@@ -412,9 +412,9 @@ func (ss *Session) greet() {
|
||||
ss.send(fmt.Sprintf("220 %v Inbucket SMTP ready", ss.server.domain))
|
||||
}
|
||||
|
||||
// Calculate the next read or write deadline based on maxIdleSeconds
|
||||
// Calculate the next read or write deadline based on maxIdle
|
||||
func (ss *Session) nextDeadline() time.Time {
|
||||
return time.Now().Add(time.Duration(ss.server.maxIdleSeconds) * time.Second)
|
||||
return time.Now().Add(ss.server.maxIdle)
|
||||
}
|
||||
|
||||
// Send requested message, store errors in Session.sendError
|
||||
|
||||
@@ -361,13 +361,12 @@ func (m *mockConn) SetWriteDeadline(t time.Time) error { return nil }
|
||||
|
||||
func setupSMTPServer(ds storage.Store) (s *Server, buf *bytes.Buffer, teardown func()) {
|
||||
// Test Server Config
|
||||
cfg := config.SMTPConfig{
|
||||
IP4address: net.IPv4(127, 0, 0, 1),
|
||||
IP4port: 2500,
|
||||
cfg := config.SMTP{
|
||||
Addr: "127.0.0.1:2500",
|
||||
Domain: "inbucket.local",
|
||||
DomainNoStore: "bitbucket.local",
|
||||
MaxRecipients: 5,
|
||||
MaxIdleSeconds: 5,
|
||||
MaxIdle: 5,
|
||||
MaxMessageBytes: 5000,
|
||||
StoreMessages: true,
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"container/list"
|
||||
"context"
|
||||
"expvar"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -43,7 +42,7 @@ type Server struct {
|
||||
domain string
|
||||
domainNoStore string
|
||||
maxRecips int
|
||||
maxIdleSeconds int
|
||||
maxIdle time.Duration
|
||||
maxMessageBytes int
|
||||
storeMessages bool
|
||||
|
||||
@@ -80,17 +79,17 @@ var (
|
||||
|
||||
// NewServer creates a new Server instance with the specificed config
|
||||
func NewServer(
|
||||
cfg config.SMTPConfig,
|
||||
cfg config.SMTP,
|
||||
globalShutdown chan bool,
|
||||
manager message.Manager,
|
||||
apolicy *policy.Addressing,
|
||||
) *Server {
|
||||
return &Server{
|
||||
host: fmt.Sprintf("%v:%v", cfg.IP4address, cfg.IP4port),
|
||||
host: cfg.Addr,
|
||||
domain: cfg.Domain,
|
||||
domainNoStore: strings.ToLower(cfg.DomainNoStore),
|
||||
maxRecips: cfg.MaxRecipients,
|
||||
maxIdleSeconds: cfg.MaxIdleSeconds,
|
||||
maxIdle: cfg.MaxIdle,
|
||||
maxMessageBytes: cfg.MaxMessageBytes,
|
||||
storeMessages: cfg.StoreMessages,
|
||||
globalShutdown: globalShutdown,
|
||||
|
||||
Reference in New Issue
Block a user