From bbdfb524786264b409b59d8c69c35acd3e3be633 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 9 Aug 2024 18:46:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ws=E6=9F=A5=E7=9C=8B=E5=86=85=E5=AE=B9ca?= =?UTF-8?q?t=E5=91=BD=E4=BB=A4=E7=A7=BB=E9=99=A4showTabs=EF=BC=8C=E6=8C=89?= =?UTF-8?q?=E4=B8=8B=20Ctrl+C=E8=A1=A5=E5=85=85=E5=9B=9E=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/ws/processor/shell_command.go | 4 ---- src/modules/ws/service/ws_receive.impl.go | 5 ++--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/modules/ws/processor/shell_command.go b/src/modules/ws/processor/shell_command.go index 65a18ce9..38f9f583 100644 --- a/src/modules/ws/processor/shell_command.go +++ b/src/modules/ws/processor/shell_command.go @@ -14,7 +14,6 @@ func ParseCat(reqData any) (string, error) { var data struct { FilePath string `json:"filePath"` // 文件地址 ShowNumber bool `json:"showNumber"` // 显示文件的行号,从 1 开始 - ShowTabs bool `json:"showTabs"` // 在每行的结尾显示 $ 符号 ShowAll bool `json:"showAll"` // 结合 -vET 参数,显示所有特殊字符,包括行尾符、制表符等 } if err := json.Unmarshal(msgByte, &data); err != nil { @@ -29,9 +28,6 @@ func ParseCat(reqData any) (string, error) { if data.ShowNumber { command = append(command, "-n") } - if data.ShowTabs { - command = append(command, "-T") - } if data.ShowAll { command = append(command, "-A") } diff --git a/src/modules/ws/service/ws_receive.impl.go b/src/modules/ws/service/ws_receive.impl.go index cf09f8fd..e946d9ac 100644 --- a/src/modules/ws/service/ws_receive.impl.go +++ b/src/modules/ws/service/ws_receive.impl.go @@ -154,8 +154,7 @@ func (s *WSReceiveImpl) ShellView(client *model.WSClient, reqMsg model.WSRequest case "close": s.close(client) return - case "cat": - case "tail": + case "cat", "tail": var command string if reqMsg.Type == "cat" { command, err = processor.ParseCat(reqMsg.Data) @@ -170,7 +169,7 @@ func (s *WSReceiveImpl) ShellView(client *model.WSClient, reqMsg model.WSRequest case "ctrl-c": // 模拟按下 Ctrl+C sshClientSession := client.ChildConn.(*ssh.SSHClientSession) - _, err = sshClientSession.Write("\x03") + _, err = sshClientSession.Write("\u0003\n") case "resize": // 会话窗口重置 msgByte, _ := json.Marshal(reqMsg.Data)