From 0cf6c4a9a28485ea85e85f79bbbf4522abe9eed8 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 7 Sep 2025 17:44:34 +0800 Subject: Fix LMTP server not getting the server config --- forged/internal/unsorted/lmtp_server.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/forged/internal/unsorted/lmtp_server.go b/forged/internal/unsorted/lmtp_server.go index 1e94894..a006679 100644 --- a/forged/internal/unsorted/lmtp_server.go +++ b/forged/internal/unsorted/lmtp_server.go @@ -20,14 +20,14 @@ import ( "go.lindenii.runxiyu.org/forge/forged/internal/misc" ) -type lmtpHandler struct{} +type lmtpHandler struct{s *Server} type lmtpSession struct { from string to []string ctx context.Context cancel context.CancelFunc - s Server + s *Server } func (session *lmtpSession) Reset() { @@ -54,17 +54,18 @@ func (session *lmtpSession) Rcpt(to string, _ *smtp.RcptOptions) error { return nil } -func (*lmtpHandler) NewSession(_ *smtp.Conn) (smtp.Session, error) { +func (h *lmtpHandler) NewSession(_ *smtp.Conn) (smtp.Session, error) { ctx, cancel := context.WithCancel(context.Background()) session := &lmtpSession{ ctx: ctx, cancel: cancel, + s: h.s, } return session, nil } func (s *Server) serveLMTP(listener net.Listener) error { - smtpServer := smtp.NewServer(&lmtpHandler{}) + smtpServer := smtp.NewServer(&lmtpHandler{s: s}) smtpServer.LMTP = true smtpServer.Domain = s.config.LMTP.Domain smtpServer.Addr = s.config.LMTP.Socket @@ -85,6 +86,7 @@ func (session *lmtpSession) Data(r io.Reader) error { n int64 ) + fmt.Printf("%#v\n", session.s) n, err = io.CopyN(&buf, r, session.s.config.LMTP.MaxSize) switch { case n == session.s.config.LMTP.MaxSize: -- cgit v1.2.3