From 7c8e3f9dcfee3826dcf04aa3cb99453ba01331d7 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 01 Apr 2025 13:36:30 +0800 Subject: [PATCH] LMTP configuration update --- config.go | 7 +++++-- forge.scfg | 7 +++++++ lmtp_server.go | 8 ++++++++ diff --git a/config.go b/config.go index 7870a63e26d8990cf3abc5aba15bb8a2afff9603..17ad3e75858fddf0c67737095d37c9d89e6e0db7 100644 --- a/config.go +++ b/config.go @@ -32,8 +32,11 @@ Socket string `scfg:"socket"` 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 b2a34cd80076f68f31ffcd7586f955cfdf67b11b..e7885312ea36e191e55498d88d8afdbec47d3926 100644 --- a/forge.scfg +++ b/forge.scfg @@ -83,4 +83,11 @@ socket /var/run/lindenii/forge/lmtp.sock # 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 8e574e47d1feb555a7fb0543b70a9b8230d64e64..041194ef48e39299c10a49c6aca7a52d2618b263 100644 --- a/lmtp_server.go +++ b/lmtp_server.go @@ -11,6 +11,7 @@ "io" "log/slog" "net" "strings" + "time" "github.com/emersion/go-message" "github.com/emersion/go-smtp" @@ -53,7 +54,14 @@ return session, nil } 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) } -- 2.48.1