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 { var data struct {
FilePath string `json:"filePath"` // 文件地址 FilePath string `json:"filePath"` // 文件地址
ShowNumber bool `json:"showNumber"` // 显示文件的行号,从 1 开始 ShowNumber bool `json:"showNumber"` // 显示文件的行号,从 1 开始
ShowTabs bool `json:"showTabs"` // 在每行的结尾显示 $ 符号
ShowAll bool `json:"showAll"` // 结合 -vET 参数,显示所有特殊字符,包括行尾符、制表符等 ShowAll bool `json:"showAll"` // 结合 -vET 参数,显示所有特殊字符,包括行尾符、制表符等
} }
if err := json.Unmarshal(msgByte, &data); err != nil { if err := json.Unmarshal(msgByte, &data); err != nil {
@@ -29,9 +28,6 @@ func ParseCat(reqData any) (string, error) {
if data.ShowNumber { if data.ShowNumber {
command = append(command, "-n") command = append(command, "-n")
} }
if data.ShowTabs {
command = append(command, "-T")
}
if data.ShowAll { if data.ShowAll {
command = append(command, "-A") command = append(command, "-A")
} }

View File

@@ -154,8 +154,7 @@ func (s *WSReceiveImpl) ShellView(client *model.WSClient, reqMsg model.WSRequest
case "close": case "close":
s.close(client) s.close(client)
return return
case "cat": case "cat", "tail":
case "tail":
var command string var command string
if reqMsg.Type == "cat" { if reqMsg.Type == "cat" {
command, err = processor.ParseCat(reqMsg.Data) command, err = processor.ParseCat(reqMsg.Data)
@@ -170,7 +169,7 @@ func (s *WSReceiveImpl) ShellView(client *model.WSClient, reqMsg model.WSRequest
case "ctrl-c": case "ctrl-c":
// 模拟按下 Ctrl+C // 模拟按下 Ctrl+C
sshClientSession := client.ChildConn.(*ssh.SSHClientSession) sshClientSession := client.ChildConn.(*ssh.SSHClientSession)
_, err = sshClientSession.Write("\x03") _, err = sshClientSession.Write("\u0003\n")
case "resize": case "resize":
// 会话窗口重置 // 会话窗口重置
msgByte, _ := json.Marshal(reqMsg.Data) msgByte, _ := json.Marshal(reqMsg.Data)