aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-01 13:36:30 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-01 13:36:30 +0800
commit7c8e3f9dcfee3826dcf04aa3cb99453ba01331d7 (patch)
tree3819e089a29b463da5a1c47a5065cb873e7dc491
parentBasic debugging LMTP handler (diff)
downloadforge-7c8e3f9dcfee3826dcf04aa3cb99453ba01331d7.tar.gz
forge-7c8e3f9dcfee3826dcf04aa3cb99453ba01331d7.tar.zst
forge-7c8e3f9dcfee3826dcf04aa3cb99453ba01331d7.zip
LMTP configuration update
-rw-r--r--config.go7
-rw-r--r--forge.scfg7
-rw-r--r--lmtp_server.go8
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)
}