diff options
author | Runxi Yu <me@runxiyu.org> | 2025-01-13 15:29:39 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-01-13 15:31:55 +0800 |
commit | f86cbd83d86473f405ec60a7a78cf28c64150f31 (patch) | |
tree | 986d5e3ec86eb1a13baad39d3f7e1c73f2e29830 /main.go | |
parent | Fix config file error message (diff) | |
download | maild-f86cbd83d86473f405ec60a7a78cf28c64150f31.tar.gz maild-f86cbd83d86473f405ec60a7a78cf28c64150f31.tar.zst maild-f86cbd83d86473f405ec60a7a78cf28c64150f31.zip |
Refactor mx stuff
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 33 |
1 files changed, 3 insertions, 30 deletions
@@ -1,9 +1,7 @@ package main import ( - "context" "flag" - "net" "go.lindenii.runxiyu.org/lindenii-common/clog" ) @@ -19,33 +17,8 @@ func main() { clog.Fatal(1, "Error while loading configuration file: "+err.Error()) } - listener, err := net.Listen(config.MX.Net, config.MX.Addr) - if err != nil { - clog.Fatal(1, "MX: Cannot listen: "+err.Error()) - } - defer listener.Close() - clog.Info("MX: Listening via " + config.MX.Net + " on " + config.MX.Addr) + go serve_mx() - for { - conn, err := listener.Accept() - if err != nil { - clog.Error("MX: Cannot accept connection: " + err.Error()) - } - clog.Info("MX: Accepted connection from " + conn.RemoteAddr().String()) - - go func() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - err := handle_mx_recv_conn(ctx, conn) - if err != nil { - if err == err_connection_handler_eof { - clog.Info("MX: Connection for " + conn.RemoteAddr().String() + " closed with EOF") - } else { - clog.Error("MX: Connection handler for " + conn.RemoteAddr().String() + " returned error: " + err.Error()) - } - } else { - clog.Info("MX: Connection for " + conn.RemoteAddr().String() + " closed gracefully") - } - }() - } + deadlock := make(chan struct{}) + deadlock <- struct{}{} } |