1
0
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:
James Hillyerd
2018-03-21 20:44:47 -07:00
parent be940dd2bc
commit 845cbedc0d
20 changed files with 190 additions and 399 deletions

View File

@@ -536,7 +536,7 @@ func (ses *Session) enterState(state State) {
// Calculate the next read or write deadline based on maxIdleSeconds
func (ses *Session) nextDeadline() time.Time {
return time.Now().Add(time.Duration(ses.server.maxIdleSeconds) * time.Second)
return time.Now().Add(ses.server.maxIdle)
}
// Send requested message, store errors in Session.sendError

View File

@@ -2,7 +2,6 @@ package pop3
import (
"context"
"fmt"
"net"
"sync"
"time"
@@ -16,7 +15,7 @@ import (
type Server struct {
host string
domain string
maxIdleSeconds int
maxIdle time.Duration
dataStore storage.Store
listener net.Listener
globalShutdown chan bool
@@ -24,12 +23,12 @@ type Server struct {
}
// New creates a new Server struct
func New(cfg config.POP3Config, shutdownChan chan bool, ds storage.Store) *Server {
func New(cfg config.POP3, shutdownChan chan bool, ds storage.Store) *Server {
return &Server{
host: fmt.Sprintf("%v:%v", cfg.IP4address, cfg.IP4port),
host: cfg.Addr,
domain: cfg.Domain,
dataStore: ds,
maxIdleSeconds: cfg.MaxIdleSeconds,
maxIdle: cfg.MaxIdle,
globalShutdown: shutdownChan,
waitgroup: new(sync.WaitGroup),
}