fix: ws查看内容cat命令移除showTabs,按下 Ctrl+C补充回车

This commit is contained in:
TsMask
2024-08-09 18:46:45 +08:00
parent a5c88369fb
commit bbdfb52478
2 changed files with 2 additions and 7 deletions

View File

@@ -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")
}

View File

@@ -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)