From 5511fc83cd6affa75f613447891971c54515e6e3 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Sun, 19 May 2019 22:30:32 -0700 Subject: [PATCH] Better error handling (no panic) for client connrefused Server logs error w/o exiting if missing hkexsh.passwd file Signed-off-by: Russ Magee --- hkexauth.go | 3 +-- hkexsh/hkexsh.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hkexauth.go b/hkexauth.go index 438c36e..170a616 100644 --- a/hkexauth.go +++ b/hkexauth.go @@ -37,8 +37,7 @@ func AuthUserByPasswd(username string, auth string, fname string) (valid bool, a b, e := ioutil.ReadFile(fname) // nolint: gosec if e != nil { valid = false - log.Println("ERROR: Cannot read hkexsh.passwd file!") - log.Fatal(e) + log.Printf("ERROR: Cannot read %s!\n", fname) } r := csv.NewReader(bytes.NewReader(b)) diff --git a/hkexsh/hkexsh.go b/hkexsh/hkexsh.go index 6891e63..a0462a5 100755 --- a/hkexsh/hkexsh.go +++ b/hkexsh/hkexsh.go @@ -781,7 +781,7 @@ func main() { conn, err := hkexnet.Dial("tcp", server, cipherAlg, hmacAlg, kexAlg) if err != nil { fmt.Println(err) - panic(err) + os.Exit(3) } defer conn.Close() // nolint: errcheck // From this point on, conn is a secure encrypted channel