Better error handling (no panic) for client connrefused

Server logs error w/o exiting if missing hkexsh.passwd file

Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
Russ Magee 2019-05-19 22:30:32 -07:00
parent cbf3c77342
commit 5511fc83cd
2 changed files with 2 additions and 3 deletions

View File

@ -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))

View File

@ -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