terminal

package
v0.0.0-...-2fa33bc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	ReplayDir string
	// contains filtered or unexported fields
}

Handler implements terminal and replay endpoints.

func (*Handler) DisconnectWebShell

func (h *Handler) DisconnectWebShell(id string) bool

func (*Handler) DisconnectWebShellHTTP

func (h *Handler) DisconnectWebShellHTTP(w http.ResponseWriter, r *http.Request)

DisconnectWebShellHTTP forcibly closes one WebShell session.

@Summary 断开终端会话 @Description 强制关闭指定 ID 的 WebShell 会话;会话不存在时返回 404。 @Tags 终端 @Param id path string true "会话 ID" @Success 204 @Failure 403 {string} string "跨源请求被拒绝" @Failure 404 {string} string "会话不存在" @Router /api/v1/terminal/sessions/{id} [delete]

func (*Handler) GetTerminalReplay

func (h *Handler) GetTerminalReplay(w http.ResponseWriter, r *http.Request)

GetTerminalReplay streams a finalized asciinema v2 cast as NDJSON.

@Summary 读取终端录像 @Description 按录像 ID 查库获取录像日期和文件路径,返回解压后的 asciinema v2 录像,第一行为 JSON 头,后续每行是带时间戳的终端输出或尺寸事件。 @Tags 终端 @Produce application/x-ndjson @Param id path string true "录像 UUID" @Success 200 {string} string "asciinema v2 NDJSON" @Failure 403 {string} string "跨源请求被拒绝" @Failure 404 {string} string "录像不存在" @Failure 500 {string} string "无法读取录像" @Router /api/v1/terminal/replays/{id} [get]

func (*Handler) ImportReplays

func (h *Handler) ImportReplays() error

ImportReplays indexes finalized recordings missing from the database. The database, not the filesystem, serves list requests.

func (*Handler) ListTerminalReplays

func (h *Handler) ListTerminalReplays(w http.ResponseWriter, r *http.Request)

ListTerminalReplays lists finalized WebShell recordings, newest first.

@Summary 列出终端录像 @Description 按录像日期倒序列出已完成的 WebShell 录像。 @Tags 终端 @Produce json @Param limit query int false "每页数量(1 至 100)" default(50) @Param offset query int false "跳过的条数" default(0) @Success 200 {object} iproto.ReplayList @Failure 400 {string} string "分页参数无效" @Failure 403 {string} string "跨源请求被拒绝" @Failure 500 {string} string "无法读取录像" @Router /api/v1/terminal/replays [get]

func (*Handler) ListWebShellSessions

func (h *Handler) ListWebShellSessions() []iproto.WebShellSession

func (*Handler) ListWebShellSessionsHTTP

func (h *Handler) ListWebShellSessionsHTTP(w http.ResponseWriter, r *http.Request)

ListWebShellSessionsHTTP returns the live session list as JSON.

Subscribe to terminal-sessions on /api/v1/ws for live updates.

@Summary 列出在线终端会话 @Description 返回当前所有已连接的交互式 WebShell 会话。 @Tags 终端 @Produce json @Success 200 {array} iproto.WebShellSession @Failure 403 {string} string "跨源请求被拒绝" @Router /api/v1/terminal/sessions [get]

func (*Handler) OpenTerminal

func (h *Handler) OpenTerminal(w http.ResponseWriter, r *http.Request)

OpenTerminal upgrades a WebShell connection. Istio handles authentication and authorization. @Summary 连接 WebShell @Description 通过 WebSocket 连接终端。可用查询参数 cols、rows(各 1 至 1000)指定初始尺寸,缺省或无效时为 80x24。普通二进制帧传输终端数据,客户端使用 JSON 文本帧(cols、rows)调整尺寸。服务端宣布 {"zmodem":true},ZMODEM 帧会经过 PTY 交给 Shell 中的 rz/sz 程序;协议流由终端审计过滤器识别并从录像文本中剔除。 @Tags 终端 @Param cols query int false "初始列数(1 至 1000)" @Param rows query int false "初始行数(1 至 1000)" @Success 101 "WebSocket 升级成功" @Failure 400 {string} string "WebSocket 握手参数无效" @Failure 403 {string} string "WebSocket Origin 校验失败" @Failure 426 {string} string "需要 WebSocket 升级请求" @Router /api/v1/terminal [get]

func (*Handler) RegisterStream

func (h *Handler) RegisterStream(reg *httpx.StreamRegistry)

RegisterStream adds the terminal admin surface to the shared WebSocket:

主题 terminal-sessions  在线会话列表,连接时一次、此后每次增删一次
主题 terminal-watch     某个会话的实时输出(只读,无输入通道)
主题 terminal-replay    某份录像的 NDJSON 文本,按块推送
方法 terminal.disconnect 强制断开一个会话
方法 replay.list        录像列表

The interactive shell is deliberately absent: it carries raw binary frames and owns its socket (/api/v1/terminal). Everything here is small JSON, so it rides the same connection as the orchestration feeds.

func (*Handler) WatchWebShell

func (h *Handler) WatchWebShell(w http.ResponseWriter, r *http.Request)

WatchWebShell streams output only. The observer has no input channel.

The shared WebSocket carries the same cast lines per frame (topic terminal-watch); this endpoint is the plain-HTTP equivalent for clients that would rather read a line stream than speak the multiplexed protocol.

@Summary 观看终端会话 @Description 以 NDJSON 实时推送指定会话的 asciinema v2 录像行;只读,没有输入通道。首行固定为空行,随后每行是一个录像事件,空闲时每 15 秒发一个空行保活。 @Tags 终端 @Produce application/x-ndjson @Param id path string true "会话 ID" @Success 200 {string} string "asciinema v2 NDJSON" @Failure 403 {string} string "跨源请求被拒绝" @Failure 404 {string} string "会话不存在" @Failure 503 {string} string "会话已结束或观看人数已满" @Router /api/v1/terminal/sessions/{id}/watch [get]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL