aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-01-13 15:29:39 +0800
committerRunxi Yu <me@runxiyu.org>2025-01-13 15:31:55 +0800
commitf86cbd83d86473f405ec60a7a78cf28c64150f31 (patch)
tree986d5e3ec86eb1a13baad39d3f7e1c73f2e29830 /main.go
parentFix config file error message (diff)
downloadmaild-f86cbd83d86473f405ec60a7a78cf28c64150f31.tar.gz
maild-f86cbd83d86473f405ec60a7a78cf28c64150f31.tar.zst
maild-f86cbd83d86473f405ec60a7a78cf28c64150f31.zip
Refactor mx stuff
Diffstat (limited to '')
-rw-r--r--main.go33
1 files changed, 3 insertions, 30 deletions
diff --git a/main.go b/main.go
index 4a4f242..51540f9 100644
--- a/main.go
+++ b/main.go
@@ -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{}{}
}