mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
feat(webconsole): keep_websocket_session option (#21782)
This commit is contained in:
@@ -36,6 +36,8 @@ type WebConsoleOptions struct {
|
||||
|
||||
EnableWatermark bool `help:"enable water mark" default:"false"`
|
||||
EnableCommandRecording bool `help:"enable command recording" default:"false"`
|
||||
|
||||
KeepWebsocketSession bool `help:"keep websocket session" default:"false"`
|
||||
}
|
||||
|
||||
func OnOptionsChange(oldO, newO interface{}) bool {
|
||||
|
||||
@@ -278,7 +278,9 @@ func (s *WebsocketServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
delSftpClient(s.Session.Id)
|
||||
s.sftp.Close()
|
||||
s.conn.Close()
|
||||
s.Session.Close()
|
||||
if !options.Options.KeepWebsocketSession {
|
||||
s.Session.Close()
|
||||
}
|
||||
keepAliveDone <- struct{}{}
|
||||
}()
|
||||
|
||||
|
||||
@@ -92,8 +92,10 @@ func (man *SSessionManager) Get(accessToken string) (*SSession, bool) {
|
||||
s := obj.(*SSession)
|
||||
protocol := s.GetProtocol()
|
||||
if protocol != SPICE && time.Since(s.AccessedAt) < AccessInterval {
|
||||
log.Warningf("Protol: %q, Token: %s, Session: %s can't be accessed during %s, last accessed at: %s", s.GetProtocol(), accessToken, s.Id, AccessInterval, s.AccessedAt)
|
||||
return nil, false
|
||||
if !(protocol == WS && o.Options.KeepWebsocketSession) {
|
||||
log.Warningf("Protol: %q, Token: %s, Session: %s can't be accessed during %s, last accessed at: %s", s.GetProtocol(), accessToken, s.Id, AccessInterval, s.AccessedAt)
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
s.AccessedAt = time.Now()
|
||||
return s, true
|
||||
|
||||
Reference in New Issue
Block a user