From 7c8e3f9dcfee3826dcf04aa3cb99453ba01331d7 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 1 Apr 2025 13:36:30 +0800 Subject: LMTP configuration update --- config.go | 7 +++++-- forge.scfg | 7 +++++++ lmtp_server.go | 8 ++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index 7870a63..17ad3e7 100644 --- a/config.go +++ b/config.go @@ -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"` diff --git a/forge.scfg b/forge.scfg index b2a34cd..e788531 100644 --- a/forge.scfg +++ b/forge.scfg @@ -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) } -- cgit v1.2.3