From 00f3cb9fb48cfb9768b695bd0d9eb8367ad84782 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 2 Jan 2025 19:30:51 +0000 Subject: Deliver to inbox --- main.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 8d6b797..052deec 100644 --- a/main.go +++ b/main.go @@ -3,21 +3,18 @@ package main import ( "bufio" "net" - "os" + "flag" + "errors" + "io" "go.lindenii.runxiyu.org/lindenii-common/clog" - "go.lindenii.runxiyu.org/lindenii-common/scfg" ) const VERSION = "lindenii-maild v0.0.0" func main() { - config_file, err := os.Open("maild.scfg") - if err != nil { - panic(err) - } - - err = scfg.NewDecoder(bufio.NewReader(config_file)).Decode(&config) + config_path := flag.String("config", "maild.scfg", "path to configuration file") + err := load_config(*config_path) if err != nil { panic(err) } @@ -36,7 +33,7 @@ func main() { go func() { err := handle_incoming_server_connection(bufio.NewReader(conn), bufio.NewWriter(conn)) - if err != nil { + if err != nil && !errors.Is(err, io.EOF) { clog.Error("connection handler returned error", "err", err) } }() -- cgit v1.2.3