Skip to content

Commit

Permalink
Merge pull request #1449 from jumpserver/pr@dev@remove_k8s_tab
Browse files Browse the repository at this point in the history
perf: Remove k8s connect
  • Loading branch information
feng626 authored Sep 2, 2024
2 parents 084f62e + 3f6093e commit 9edb067
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/httpd/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const (
TerminalK8SData = "TERMINAL_K8S_DATA"
TerminalK8SBinary = "TERMINAL_K8S_BINARY"
TerminalK8SResize = "TERMINAL_K8S_RESIZE"
K8SClose = "K8S_CLOSE"
)

type WindowSize struct {
Expand Down
16 changes: 14 additions & 2 deletions pkg/httpd/tty.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
}

Expand Down

0 comments on commit 9edb067

Please sign in to comment.