diff options
-rw-r--r-- | config.go | 7 | ||||
-rw-r--r-- | forge.scfg | 7 | ||||
-rw-r--r-- | lmtp_server.go | 8 |
3 files changed, 20 insertions, 2 deletions
@@ -32,8 +32,11 @@ var config struct { Execs string `scfg:"execs"` } `scfg:"hooks"` LMTP struct { - Socket string `scfg:"socket"` - MaxSize int64 `scfg:"max_size"` + Socket string `scfg:"socket"` + Domain string `scfg:"domain"` + MaxSize int64 `scfg:"max_size"` + WriteTimeout uint32 `scfg:"write_timeout"` + ReadTimeout uint32 `scfg:"read_timeout"` } `scfg:"lmtp"` Git struct { RepoDir string `scfg:"repo_dir"` @@ -83,4 +83,11 @@ lmtp { # What's the maximum acceptable message size? max_size 1000000 + + # What is our domainpart? + domain forge.example.org + + # General timeouts + read_timeout 300 + write_timeout 300 } diff --git a/lmtp_server.go b/lmtp_server.go index 8e574e4..041194e 100644 --- a/lmtp_server.go +++ b/lmtp_server.go @@ -11,6 +11,7 @@ import ( "log/slog" "net" "strings" + "time" "github.com/emersion/go-message" "github.com/emersion/go-smtp" @@ -53,7 +54,14 @@ func (*lmtpHandler) NewSession(_ *smtp.Conn) (smtp.Session, error) { } func serveLMTP(listener net.Listener) error { + // TODO: Manually construct smtp.Server smtpServer := smtp.NewServer(&lmtpHandler{}) + smtpServer.LMTP = true + smtpServer.Domain = config.LMTP.Domain + smtpServer.Addr = config.LMTP.Socket + smtpServer.WriteTimeout = time.Duration(config.LMTP.WriteTimeout) * time.Second + smtpServer.ReadTimeout = time.Duration(config.LMTP.ReadTimeout) * time.Second + smtpServer.EnableSMTPUTF8 = true return smtpServer.Serve(listener) } |