Documentation
¶
Overview ¶
Package remotesess 实现 XOps v2 基于 *ssh.Session 的远端命令与交互式 Shell 会话适配器 (ports.RemoteSession,ADR-009 / ADR-015)。
核心安全与并发不变量:
- 构造期预绑定 StdinPipe / StdoutPipe / StderrPipe,绝不给 ssh.Session.Stdin/Stdout/Stderr 赋值, 彻底规避 golang.org/x/crypto/ssh 内部孤儿拷贝协程泄漏;
- 所有 env / pty-req / exec / shell 控制请求、输入输出流泵与 Wait 均受上游 lifeNursery 统一监督, 全包 0 裸 go 语句与零行内 nolint 豁免;
- 输出泵在达到 CommandPlan.MaxOutputBytes 或 dst.Write 失败后继续排空至 EOF,防 SSH 窗口反压死锁。
Index ¶
- type Session
- func (s *Session) Close() error
- func (s *Session) ResizePTY(ctx context.Context, size ports.TerminalSize) error
- func (s *Session) Signal(ctx context.Context, signal string) error
- func (s *Session) Start(ctx context.Context, cmd execution.CommandPlan, streams ports.ExecStreams) error
- func (s *Session) StartShell(ctx context.Context, streams ports.ExecStreams) error
- func (s *Session) StderrPipe() (io.Reader, error)
- func (s *Session) StdinPipe() (io.WriteCloser, error)
- func (s *Session) StdoutPipe() (io.Reader, error)
- func (s *Session) Wait(ctx context.Context) (execution.ExecutionOutcome, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session 封装单条 *ssh.Session,实现 ports.RemoteSession;零值恒失败关闭。
func (*Session) ResizePTY ¶
ResizePTY 在 lifeNursery 监督下向远端会话发送 RFC 4254 window-change 窗口尺寸更新请求(防黑洞阻塞)。
func (*Session) Signal ¶
Signal 在 lifeNursery 监督下向远端进程发送规范化 POSIX 信号(如 "INT"、"TERM"、"KILL",兼容可选 "SIG" 前缀)。
func (*Session) Start ¶
func (s *Session) Start(ctx context.Context, cmd execution.CommandPlan, streams ports.ExecStreams) error
Start 在远端会话通道上渲染并启动不可变 CommandPlan(含可选 PTY、环境变量、脚本 stdin 投递与输出上限截断)。
func (*Session) StartShell ¶
StartShell 在远端会话通道上启动交互式 Shell(可选 PTY 与环境变量统一由 streams 承载)。
func (*Session) StderrPipe ¶
StderrPipe 在 Start/StartShell 前借出远端标准错误读取管道(与非空 ExecStreams.Stderr 互斥)。 底层由独立 lifeNursery 监督的 io.Pipe 桥接:该流到达 EOF 时立即独立关闭写端(解耦 stdout 与 Wait), 且在 Session.Close 时 O(1) 关闭写端以解除半开 TCP 黑洞下的读取阻塞(ADR-015)。
func (*Session) StdinPipe ¶
func (s *Session) StdinPipe() (io.WriteCloser, error)
StdinPipe 在 Start/StartShell 前借出远端标准输入写入管道(与非空 ExecStreams.Stdin 及 PlanKindScript 互斥)。
func (*Session) StdoutPipe ¶
StdoutPipe 在 Start/StartShell 前借出远端标准输出读取管道(与非空 ExecStreams.Stdout 互斥)。 底层由独立 lifeNursery 监督的 io.Pipe 桥接:该流到达 EOF 时立即独立关闭写端(解耦 stderr 与 Wait), 且在 Session.Close 时 O(1) 关闭写端以解除半开 TCP 黑洞下的读取阻塞(ADR-015)。