diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -18,27 +18,31 @@ func main() { err := load_config(*config_path) if err != nil { - panic(err) + clog.Fatal(1, "Configuration file not found at "+*config_path) } listener, err := net.Listen(config.MX.Net, config.MX.Addr) if err != nil { - panic(err) + clog.Fatal(1, "MX: Cannot listen: "+err.Error()) } defer listener.Close() + clog.Info("MX: Listening via " + config.MX.Net + " on " + config.MX.Addr) for { conn, err := listener.Accept() if err != nil { - panic(err) + 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 && !errors.Is(err, io.EOF) { - clog.Error("connection handler returned error", "err", err) + clog.Error("MX: Connection handler for " + conn.RemoteAddr().String() + " returned error: " + err.Error()) + } else { + clog.Error("MX: Connection handler for " + conn.RemoteAddr().String() + " returned error: " + err.Error()) } }() } |