mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-21 23:20:24 +00:00
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:
parent
1b21c19a78
commit
68a4bbd10c
2 changed files with 5 additions and 3 deletions
|
@ -787,10 +787,12 @@ 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) {
|
||||||
|
if time.Since(conn.GetLastActivity()) <= Config.idleTimeoutAsDuration {
|
||||||
toClose = false
|
toClose = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if toClose {
|
if toClose {
|
||||||
defer func(c *SSHConnection) {
|
defer func(c *SSHConnection) {
|
||||||
err := c.Close()
|
err := c.Close()
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue