From e860b60d20e71ca555840b7086f71807db3c9da9 Mon Sep 17 00:00:00 2001 From: "valentin.daviot" Date: Mon, 5 Nov 2018 11:09:44 +0100 Subject: [PATCH] session status and duration displaying properly --- ssh.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ssh.go b/ssh.go index d68e915d..97d963f6 100644 --- a/ssh.go +++ b/ssh.go @@ -163,19 +163,19 @@ func channelHandler(srv *ssh.Server, conn *gossh.ServerConn, newChan gossh.NewCh if err != nil { log.Printf("Error: %v", err) } - }() - now := time.Now() - sessUpdate := Session{ - Status: SessionStatusClosed, - ErrMsg: fmt.Sprintf("%v", err), - StoppedAt: &now, - } - switch sessUpdate.ErrMsg { - case "lch closed the connection", "rch closed the connection": - sessUpdate.ErrMsg = "" - } - actx.db.Model(&sess).Updates(&sessUpdate) + now := time.Now() + sessUpdate := Session{ + Status: SessionStatusClosed, + ErrMsg: fmt.Sprintf("%v", err), + StoppedAt: &now, + } + switch sessUpdate.ErrMsg { + case "lch closed the connection", "rch closed the connection": + sessUpdate.ErrMsg = "" + } + actx.db.Model(&sess).Updates(&sessUpdate) + }() case BastionSchemeTelnet: tmpSrv := ssh.Server{ // PtyCallback: srv.PtyCallback,