be sure to close an SSH connection if all channels are idle

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2022-04-01 08:05:07 +02:00
parent 1b21c19a78
commit 68a4bbd10c
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB
2 changed files with 5 additions and 3 deletions

View file

@ -787,8 +787,10 @@ func (conns *ActiveConnections) checkIdles() {
toClose := true toClose := true
for _, conn := range conns.connections { for _, conn := range conns.connections {
if strings.Contains(conn.GetID(), idToMatch) { if strings.Contains(conn.GetID(), idToMatch) {
toClose = false if time.Since(conn.GetLastActivity()) <= Config.idleTimeoutAsDuration {
break toClose = false
break
}
} }
} }
if toClose { if toClose {

View file

@ -1509,7 +1509,7 @@ func handleWebAddAdminPost(w http.ResponseWriter, r *http.Request) {
renderForbiddenPage(w, r, err.Error()) renderForbiddenPage(w, r, err.Error())
return return
} }
err = dataprovider.AddAdmin(&admin, claims.Username, util.GetIPFromRemoteAddress(r.Method)) err = dataprovider.AddAdmin(&admin, claims.Username, util.GetIPFromRemoteAddress(r.RemoteAddr))
if err != nil { if err != nil {
renderAddUpdateAdminPage(w, r, &admin, err.Error(), true) renderAddUpdateAdminPage(w, r, &admin, err.Error(), true)
return return