diff --git a/pkg/httpd/message.go b/pkg/httpd/message.go index acee60b5..3599f290 100644 --- a/pkg/httpd/message.go +++ b/pkg/httpd/message.go @@ -62,6 +62,7 @@ const ( TerminalK8SData = "TERMINAL_K8S_DATA" TerminalK8SBinary = "TERMINAL_K8S_BINARY" TerminalK8SResize = "TERMINAL_K8S_RESIZE" + K8SClose = "K8S_CLOSE" ) type WindowSize struct { diff --git a/pkg/httpd/tty.go b/pkg/httpd/tty.go index e1794fa7..a34a31e4 100644 --- a/pkg/httpd/tty.go +++ b/pkg/httpd/tty.go @@ -108,6 +108,15 @@ func (h *tty) sendCloseMessage() { h.ws.SendMessage(&closedMsg) } +func (h *tty) sendK8SCloseMessage(KubernetesId string) { + closedMsg := Message{ + Id: h.ws.Uuid, + Type: K8SClose, + KubernetesId: KubernetesId, + } + h.ws.SendMessage(&closedMsg) +} + func (h *tty) sendSessionMessage(data string) { msg := Message{ Id: h.ws.Uuid, @@ -453,9 +462,12 @@ func (h *tty) proxy(wg *sync.WaitGroup, client *Client) { srv.Proxy() } - if params.TargetType != srvconn.ProtocolK8s { - h.sendCloseMessage() + if params.TargetType == srvconn.ProtocolK8s { + delete(h.K8sClients, client.KubernetesId) + h.sendK8SCloseMessage(client.KubernetesId) + return } + h.sendCloseMessage() logger.Info("Ws tty proxy end") }