fix: 添加Web SSH禁用提示信息

This commit is contained in:
Akizon77
2025-05-16 20:54:54 +08:00
parent 7ce7ee18d3
commit 12dbaf2be5

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/gorilla/websocket"
"github.com/komari-monitor/komari-agent/cmd/flags"
)
// Terminal 接口定义平台特定的终端操作
@@ -25,6 +26,11 @@ type terminalImpl struct {
// StartTerminal 启动终端并处理 WebSocket 通信
func StartTerminal(conn *websocket.Conn) {
if flags.DisableWebSsh {
conn.WriteMessage(websocket.TextMessage, []byte("\n\nWeb SSH is disabled. Enable it by running without the --disable-web-ssh flag."))
conn.Close()
return
}
impl, err := newTerminalImpl()
if err != nil {
conn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("Error: %v\r\n", err)))