Documentation
¶
Overview ¶
Package sessapi 为 core/internal/usecase/session 提供强类型请求规格、不可变结果快照与策略投影值对象:
- RequestTTYMode 及其文本编解码与值语义方法;
- ServiceConfig 及全部会话、提权、探测、持久 PTY、转发、ControlMaster 与本地命令请求结构体;
- PTYReadResult、PTYStatus、ForwardInfo、ForwardStatus、ControlMasterInfo、ControlMasterStatus、 SSHPolicyPlan、ForwardActivationFailure 与 SSHForwardsActivationResult 等 //xops:opaque 失败关闭类型及其构造器。
本包属 LayerCoreUsecase 无环内部子包,由父包 core/internal/usecase/session 通过类型别名与薄封装零成本重导出, 严禁反向导入父包 core/internal/usecase/session,零 init()、零可变包级 var、零 //nolint:。
Index ¶
- type ActivateSSHForwardsRequest
- type ControlMasterInfo
- func (i ControlMasterInfo) Done() <-chan struct{}
- func (i ControlMasterInfo) EffectiveMaster() option.ControlMasterMode
- func (i ControlMasterInfo) EffectivePersist() option.ControlPersistSpec
- func (i ControlMasterInfo) Handle() algebraic.Option[plan.ManagedHandle[plan.KindMux]]
- func (i ControlMasterInfo) IsValid() bool
- func (i ControlMasterInfo) IsZero() bool
- func (i ControlMasterInfo) MasterPID() uint32
- func (i ControlMasterInfo) ReusedExisting() bool
- func (i ControlMasterInfo) SocketPath() pathalg.LocalSourcePath
- func (i ControlMasterInfo) Wait(ctx context.Context) error
- type ControlMasterRequest
- type ControlMasterStatus
- func (st ControlMasterStatus) Active() bool
- func (st ControlMasterStatus) EffectiveMaster() option.ControlMasterMode
- func (st ControlMasterStatus) EffectivePersist() option.ControlPersistSpec
- func (st ControlMasterStatus) Err() error
- func (st ControlMasterStatus) HandleStatus() pool.HandleStatus
- func (st ControlMasterStatus) IsValid() bool
- func (st ControlMasterStatus) IsZero() bool
- func (st ControlMasterStatus) SocketPath() pathalg.LocalSourcePath
- type ExecRequest
- type ExecSpillResult
- type ExplicitSSHSessionRequest
- type ForwardActivationFailure
- type ForwardInfo
- func (i ForwardInfo) BoundAddr() string
- func (i ForwardInfo) Done() <-chan struct{}
- func (i ForwardInfo) Handle() plan.ManagedHandle[plan.KindTunnel]
- func (i ForwardInfo) IsValid() bool
- func (i ForwardInfo) IsZero() bool
- func (i ForwardInfo) Spec() ports.ForwardSpec
- func (i ForwardInfo) Wait(ctx context.Context) error
- type ForwardStatus
- type InteractiveRequest
- type LocalCommandRequest
- type LocalShellCommandRequest
- type MuxControlRequest
- type MuxRequest
- type OpenPTYRequest
- type PTYReadRequest
- type PTYReadResult
- type PTYStatus
- func (st PTYStatus) Active() bool
- func (st PTYStatus) BufferedBytes() int
- func (st PTYStatus) DroppedBytes() uint64
- func (st PTYStatus) EOF() bool
- func (st PTYStatus) HandleStatus() pool.HandleStatus
- func (st PTYStatus) IsValid() bool
- func (st PTYStatus) IsZero() bool
- func (st PTYStatus) Size() ports.TerminalSize
- func (st PTYStatus) Term() string
- type PrivilegeExecRequest
- type ProbeShellRequest
- type RemoteSpillResult
- type RemoteSpillSpec
- type RequestTTYMode
- type SSHForwardsActivationResult
- type SSHPolicyPlan
- func (p SSHPolicyPlan) AutoSpawnControlMaster() bool
- func (p SSHPolicyPlan) EscapeChar() option.EscapeCharSpec
- func (p SSHPolicyPlan) ExitOnForwardFailure() bool
- func (p SSHPolicyPlan) ForkAfterAuth() bool
- func (p SSHPolicyPlan) Forwards() []ports.ForwardSpec
- func (p SSHPolicyPlan) IsValid() bool
- func (p SSHPolicyPlan) IsZero() bool
- func (p SSHPolicyPlan) RemoteCommand() algebraic.Option[string]
- func (p SSHPolicyPlan) RequestTTY() RequestTTYMode
- func (p SSHPolicyPlan) SessionType() option.SessionTypeMode
- func (p SSHPolicyPlan) SetEnv() map[string]string
- func (p SSHPolicyPlan) StdinNull() bool
- type ServiceConfig
- type StartForwardRequest
- type StdioForwardRequest
- type SubsystemRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivateSSHForwardsRequest ¶
type ActivateSSHForwardsRequest struct {
ExplicitCLI bool
Plan plan.SealedConnectionPlan
Policy option.EffectivePolicy
NodeID string
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
}
ActivateSSHForwardsRequest 描述显式 CLI ssh 路径下按 EffectivePolicy 门控激活持久化转发与 TUN 的输入。 必须显式设置 ExplicitCLI=true(零值严格失败关闭),确保 ProbeShell/MCP/SFTP 等非 CLI 路径绝不隐式触发。
type ControlMasterInfo ¶
type ControlMasterInfo struct {
// contains filtered or unexported fields
}
ControlMasterInfo 封装 ControlMaster 启动或复用已有主进程的不可变结果;零值恒无效并失败关闭。
func NewManagedControlMasterInfo ¶
func NewManagedControlMasterInfo( handle plan.ManagedHandle[plan.KindMux], socketPath pathalg.LocalSourcePath, effMaster option.ControlMasterMode, effPersist option.ControlPersistSpec, doneCh <-chan struct{}, waitErr func() error, ) ControlMasterInfo
NewManagedControlMasterInfo 构造受本进程连接池托管的新建 ControlMasterInfo。
func NewReusedControlMasterInfo ¶
func NewReusedControlMasterInfo( socketPath pathalg.LocalSourcePath, masterPID uint32, effMaster option.ControlMasterMode, effPersist option.ControlPersistSpec, doneCh <-chan struct{}, ) ControlMasterInfo
NewReusedControlMasterInfo 构造复用外部已有活跃主进程时的 ControlMasterInfo。
func (ControlMasterInfo) Done ¶
func (i ControlMasterInfo) Done() <-chan struct{}
Done 返回只读完成信号通道:受管主进程退出并完成监听清理后关闭;复用外部主进程时返回已关闭通道;零值/无效返回 nil。
func (ControlMasterInfo) EffectiveMaster ¶
func (i ControlMasterInfo) EffectiveMaster() option.ControlMasterMode
func (ControlMasterInfo) EffectivePersist ¶
func (i ControlMasterInfo) EffectivePersist() option.ControlPersistSpec
func (ControlMasterInfo) Handle ¶
func (i ControlMasterInfo) Handle() algebraic.Option[plan.ManagedHandle[plan.KindMux]]
func (ControlMasterInfo) IsValid ¶
func (i ControlMasterInfo) IsValid() bool
ControlMasterInfo 零值安全只读访问器与响应式停机等待方法(供 entry/muxdaemon 零轮询阻塞等待)。
func (ControlMasterInfo) IsZero ¶
func (i ControlMasterInfo) IsZero() bool
func (ControlMasterInfo) MasterPID ¶
func (i ControlMasterInfo) MasterPID() uint32
func (ControlMasterInfo) ReusedExisting ¶
func (i ControlMasterInfo) ReusedExisting() bool
func (ControlMasterInfo) SocketPath ¶
func (i ControlMasterInfo) SocketPath() pathalg.LocalSourcePath
func (ControlMasterInfo) Wait ¶
func (i ControlMasterInfo) Wait(ctx context.Context) error
Wait 阻塞等待 ControlMaster 退出或 ctx 取消:
- 零值/无效时严格失败关闭返回 sessplan.ErrInvalidRequest;ctx == nil 返回 sessplan.ErrNilContext;
- 复用已有外部主进程时直接按 ctx 状态返回 nil / ctx.Err();
- 正常 -O exit / -O stop 与 ControlPersist 空闲到期(ErrMuxPersistExpired)映射为 nil,其余传输故障原样透传(即使句柄已自动回收)。
type ControlMasterRequest ¶
type ControlMasterRequest struct {
Plan plan.SealedConnectionPlan
NodeID string
Policy algebraic.Option[option.EffectivePolicy]
ForwardAgent algebraic.Option[option.ForwardAgentSpec]
IdentityAgent algebraic.Option[option.IdentityAgentSpec]
ExplicitForwardAgent bool
ForwardBindOptions algebraic.Option[ports.ForwardBindOptions]
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
ControlMasterRequest 描述启动或附着 ControlMaster(-M / ControlPersist)的强类型输入(P3-T2 / ADR-019 v2.2 S3-Q1)。 所有多路复用门控严格从 Plan 末跳的 ControlPolicy.EffectiveMaster() / EffectivePersist() 与单实例策略投影求值。
type ControlMasterStatus ¶
type ControlMasterStatus struct {
// contains filtered or unexported fields
}
ControlMasterStatus 表示受管 ControlMaster 句柄的不可变只读状态快照;零值恒无效并失败关闭。
func NewControlMasterStatus ¶
func NewControlMasterStatus( hs pool.HandleStatus, socketPath pathalg.LocalSourcePath, effMaster option.ControlMasterMode, effPersist option.ControlPersistSpec, active bool, err error, ) ControlMasterStatus
NewControlMasterStatus 基于连接池句柄状态与 ControlMaster 运行态构造有效的 ControlMasterStatus。
func (ControlMasterStatus) Active ¶
func (st ControlMasterStatus) Active() bool
func (ControlMasterStatus) EffectiveMaster ¶
func (st ControlMasterStatus) EffectiveMaster() option.ControlMasterMode
func (ControlMasterStatus) EffectivePersist ¶
func (st ControlMasterStatus) EffectivePersist() option.ControlPersistSpec
func (ControlMasterStatus) Err ¶
func (st ControlMasterStatus) Err() error
func (ControlMasterStatus) HandleStatus ¶
func (st ControlMasterStatus) HandleStatus() pool.HandleStatus
func (ControlMasterStatus) IsValid ¶
func (st ControlMasterStatus) IsValid() bool
func (ControlMasterStatus) IsZero ¶
func (st ControlMasterStatus) IsZero() bool
func (ControlMasterStatus) SocketPath ¶
func (st ControlMasterStatus) SocketPath() pathalg.LocalSourcePath
type ExecRequest ¶
type ExecRequest struct {
Plan plan.SealedConnectionPlan
Command execution.CommandPlan
NodeExecution algebraic.Option[execution.LaunchProfile] // 可选节点默认启动配置(6 级执行继承链 Node 层)
ExecutionOverride algebraic.Option[execution.LaunchProfile] // 可选显式 CLI/步骤启动配置覆盖(6 级执行继承链最高层)
NodeID, Term string
Stdin io.Reader
Stdout, Stderr io.Writer
RequestTTY RequestTTYMode
ForwardAgent algebraic.Option[option.ForwardAgentSpec]
IdentityAgent algebraic.Option[option.IdentityAgentSpec]
ExplicitForwardAgent bool
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
ExecRequest 描述单次远端命令执行用例的强类型输入。
type ExecSpillResult ¶
type ExecSpillResult struct {
Outcome execution.ExecutionOutcome
Spill RemoteSpillResult
}
ExecSpillResult 聚合单次远端命令(含提权)的执行结果与同租约远端落盘结果。
type ExplicitSSHSessionRequest ¶
type ExplicitSSHSessionRequest struct {
ExplicitCLI bool
Plan plan.SealedConnectionPlan
Policy option.EffectivePolicy
ExplicitCommand algebraic.Option[execution.CommandPlan]
Subsystem string // 可选:SessionType=subsystem 时的显式子系统名称(为空时回退提取命令参数或 RemoteCommand)
NodeExecution algebraic.Option[execution.LaunchProfile]
ExecutionOverride algebraic.Option[execution.LaunchProfile]
NodeID, Term string
Stdin io.Reader
Stdout, Stderr io.Writer
RequestTTY RequestTTYMode
EscapeHelpText string // 可选:CLI 边界经 internal/i18n 预渲染的本地化 ~? 帮助文本
ExplicitForwardAgent bool // 可选:调用方是否在 CLI 显式请求开启 ForwardAgent(区分配置继承与显式请求)
ExecutePostAuthLocalCommand bool // 可选:在 SSH 认证与建连成功后、打开会话通道/OnStarted 前受控执行 LocalCommand
OnStarted func() error // 可选:远端通道与命令启动成功后、阻塞等待退出前回调(用于脱离时序编排)
PrivilegePolicy algebraic.Option[inventory.PrivilegePolicy]
PrivilegeTargetUser algebraic.Option[option.Username]
PasswordRef algebraic.Option[secret.Ref]
PromptMode ports.PrivilegePromptMode
PrivilegeTimeout algebraic.Option[algebraic.Duration]
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
ExplicitSSHSessionRequest 描述显式 CLI ssh 路径下结合 EffectivePolicy 执行远端会话、子系统(-s)或持久化 remote_command 的输入。 必须显式设置 ExplicitCLI=true(零值严格失败关闭),确保 ProbeShell/MCP/SFTP 等非 CLI 路径绝不隐式触发 remote_command。
type ForwardActivationFailure ¶
type ForwardActivationFailure struct {
// contains filtered or unexported fields
}
ForwardActivationFailure 表示 ExitOnForwardFailure==false 模式下单条转发运行期绑定失败的不可变诊断记录;零值恒无效。
func NewForwardActivationFailure ¶
func NewForwardActivationFailure(spec ports.ForwardSpec, err error) ForwardActivationFailure
NewForwardActivationFailure 构造单条转发运行期绑定失败的不可变诊断记录。
func (ForwardActivationFailure) Err ¶
func (f ForwardActivationFailure) Err() error
Err 返回运行期绑定或监听失败原因;零值返回 nil。
func (ForwardActivationFailure) IsValid ¶
func (f ForwardActivationFailure) IsValid() bool
IsValid 报告 ForwardActivationFailure 是否有效。
func (ForwardActivationFailure) IsZero ¶
func (f ForwardActivationFailure) IsZero() bool
IsZero 报告 ForwardActivationFailure 是否处于零值无效态。
func (ForwardActivationFailure) Spec ¶
func (f ForwardActivationFailure) Spec() ports.ForwardSpec
Spec 返回失败转发对应的规格快照;零值返回零值 ForwardSpec。
type ForwardInfo ¶
type ForwardInfo struct {
// contains filtered or unexported fields
}
ForwardInfo 封装成功启动的受管长驻转发句柄与绑定地址元信息;零值恒无效并失败关闭。
func NewForwardInfo ¶
func NewForwardInfo(handle plan.ManagedHandle[plan.KindTunnel], spec ports.ForwardSpec, boundAddr string, doneCh <-chan struct{}, waitErr func() error) ForwardInfo
NewForwardInfo 构造有效的受管转发结果快照(供父包 session 在 //xops:opaque 边界外构造)。
func (ForwardInfo) BoundAddr ¶
func (i ForwardInfo) BoundAddr() string
func (ForwardInfo) Done ¶
func (i ForwardInfo) Done() <-chan struct{}
Done 返回只读完成信号通道:受管转发终止并释放本地监听/资源后关闭;零值/无效返回 nil。
func (ForwardInfo) Handle ¶
func (i ForwardInfo) Handle() plan.ManagedHandle[plan.KindTunnel]
func (ForwardInfo) IsValid ¶
func (i ForwardInfo) IsValid() bool
ForwardInfo 零值安全只读访问器与响应式停机等待方法(供 entry/cli -N 前台隧道零轮询阻塞等待)。
func (ForwardInfo) IsZero ¶
func (i ForwardInfo) IsZero() bool
func (ForwardInfo) Spec ¶
func (i ForwardInfo) Spec() ports.ForwardSpec
type ForwardStatus ¶
type ForwardStatus struct {
// contains filtered or unexported fields
}
ForwardStatus 表示受管隧道转发句柄的不可变只读状态快照;零值恒无效并失败关闭。
func NewForwardStatus ¶
func NewForwardStatus(hs pool.HandleStatus, spec ports.ForwardSpec, boundAddr string, active bool, err error) ForwardStatus
NewForwardStatus 基于连接池句柄状态与受管转发运行态构造有效的 ForwardStatus。
func (ForwardStatus) Active ¶
func (st ForwardStatus) Active() bool
func (ForwardStatus) BoundAddr ¶
func (st ForwardStatus) BoundAddr() string
func (ForwardStatus) Err ¶
func (st ForwardStatus) Err() error
func (ForwardStatus) HandleStatus ¶
func (st ForwardStatus) HandleStatus() pool.HandleStatus
func (ForwardStatus) IsValid ¶
func (st ForwardStatus) IsValid() bool
func (ForwardStatus) IsZero ¶
func (st ForwardStatus) IsZero() bool
func (ForwardStatus) Spec ¶
func (st ForwardStatus) Spec() ports.ForwardSpec
type InteractiveRequest ¶
type InteractiveRequest struct {
Plan plan.SealedConnectionPlan
NodeID, Term string
Stdin io.Reader
Stdout, Stderr io.Writer
RequestTTY RequestTTYMode
EscapeChar algebraic.Option[option.EscapeCharSpec]
EscapeHelpText string // 可选:CLI 边界预渲染的本地化 ~? 帮助文本
ForwardAgent algebraic.Option[option.ForwardAgentSpec]
IdentityAgent algebraic.Option[option.IdentityAgentSpec]
ExplicitForwardAgent bool
PrivilegePolicy algebraic.Option[inventory.PrivilegePolicy]
PrivilegeTargetUser algebraic.Option[option.Username]
PasswordRef algebraic.Option[secret.Ref]
PromptMode ports.PrivilegePromptMode
PrivilegeTimeout algebraic.Option[algebraic.Duration]
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
InteractiveRequest 描述交互式远端 Shell 会话用例的强类型输入。 可选提权字段保持零值向后兼容:未设置 PrivilegePolicy(或为 PrivilegePolicyNone)时走非提权路径。
type LocalCommandRequest ¶
type LocalCommandRequest struct {
ExplicitCLI bool
Plan plan.SealedConnectionPlan
Policy option.EffectivePolicy
NodeID string
TunnelDevice string // 可选:已建立的本地 TUN 网卡名;无 TUN 时为空或 "NONE"
OnAuthorized func(authCtx context.Context) (string, error) // 可选:在 outer gate 获批后、阶段 2 展开前执行的连建/TUN 回调(如 pool.WithLease),返回实得 TUN 设备名
ResolveExecPath func(name string) (string, error) // 可选:当 argv[0] 非绝对路径时用于阶段 1 冻结绝对可执行路径(防 PATH TOCTOU)
Timeout algebraic.Option[algebraic.Duration] // 可选:本机子进程超时
MaxOutputBytes algebraic.Option[uint64] // 可选:本机子进程输出截断上限(默认 1 MiB)
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
LocalCommandRequest 描述显式 CLI ssh 路径下受控零 Shell 执行 LocalCommand 的强类型输入(ADR-019 C2): 必须显式设置 ExplicitCLI=true(零值失败关闭),并满足 Policy.PermitLocalCommand()==true 且 Policy.LocalCommand().IsSome()。
type LocalShellCommandRequest ¶
type LocalShellCommandRequest struct {
ExplicitCLI bool
Command string // 原始命令行(经词法分词并拒绝未加引号 Shell 元字符)
WorkDir algebraic.Option[pathalg.LocalDir] // 可选:工作目录(如 sftpshell 当前 lpwd)
NodeID string // 可选:审计关联标识(空时默认 "local")
ResolveExecPath func(name string) (string, error) // 可选:将非绝对 argv[0] 冻结为绝对可执行路径(防 PATH TOCTOU)
Timeout algebraic.Option[algebraic.Duration] // 可选:本机子进程超时
MaxOutputBytes algebraic.Option[uint64] // 可选:本机子进程输出截断上限(默认 1 MiB)
Risk algebraic.Option[security.RiskLevel] // 可选:附加风险等级(恒经 RiskDangerous.Join 抬升)
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
LocalShellCommandRequest 描述显式 CLI/sftpshell 边界下受门控本机零 Shell 命令执行(!/lexec)的强类型输入(ADR-020)。 必须显式设置 ExplicitCLI=true(零值严格失败关闭),且要求 ServiceConfig.Process != nil(MCP 物理置 nil 阻断)。
type MuxControlRequest ¶
type MuxControlRequest struct {
Target MuxRequest
Action ports.MuxControlAction
Forward algebraic.Option[ports.ForwardSpec]
Forwards []ports.ForwardSpec
ExitOnForwardFailure bool
}
MuxControlRequest 描述向 ControlMaster 发送 `-O` 控制动作(check/forward/cancel/exit/stop/conninfo/channels)的强类型输入。 渐进兼容:单条转发可经 Forward 传入,批量多条转发经 Forwards 传入(二者互斥,不可同时非空)。
type MuxRequest ¶
type MuxRequest struct {
Plan plan.SealedConnectionPlan
NodeID string
SocketPath algebraic.Option[pathalg.LocalSourcePath]
ForwardAgent algebraic.Option[inventory.AgentSpec] // 可选:WithMuxConn 复用兼容性核验所请求的 Agent 转发目标
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
MuxRequest 描述面向 ControlMaster 套接字执行探测(ProbeMux)、只读观测(QueryMuxConnInfo/QueryMuxChannels)、 stdio 透传(WithMuxProxy/RunMuxProxy)或共享连接复用(WithMuxConn)的通用强类型输入。
type OpenPTYRequest ¶
type OpenPTYRequest struct {
Plan plan.SealedConnectionPlan
NodeID, Term string
Size algebraic.Option[ports.TerminalSize]
MaxBufferBytes int
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
OpenPTYRequest 描述在连接池世代 SlotMap 上创建跨请求持久 PTY 会话的强类型输入(ADR-009 / P3-T2)。
type PTYReadRequest ¶
type PTYReadRequest struct {
Handle plan.ManagedHandle[plan.KindPTY]
MaxBytes int // 0 默认 64 KiB
Wait bool // true 时事件驱动等待新输出、EOF 或取消/吊销
}
PTYReadRequest 描述从指定世代 PTY 句柄读取缓冲输出的请求参数。
type PTYReadResult ¶
type PTYReadResult struct {
// contains filtered or unexported fields
}
PTYReadResult 封装单次 ReadPTY 的不可变输出快照;零值恒无效并失败关闭。
func NewPTYReadResult ¶
func NewPTYReadResult(data []byte, eof bool, droppedBytes uint64) PTYReadResult
NewPTYReadResult 构造有效的 PTYReadResult 输出快照(data 由调用方移交所有权,访问器返回防御性拷贝)。
func (PTYReadResult) Data ¶
func (r PTYReadResult) Data() []byte
func (PTYReadResult) DroppedBytes ¶
func (r PTYReadResult) DroppedBytes() uint64
func (PTYReadResult) EOF ¶
func (r PTYReadResult) EOF() bool
func (PTYReadResult) IsValid ¶
func (r PTYReadResult) IsValid() bool
func (PTYReadResult) IsZero ¶
func (r PTYReadResult) IsZero() bool
type PTYStatus ¶
type PTYStatus struct {
// contains filtered or unexported fields
}
PTYStatus 表示持久 PTY 句柄的不可变只读状态快照;零值恒无效并失败关闭。
func NewPTYStatus ¶
func NewPTYStatus(hs pool.HandleStatus, term string, size ports.TerminalSize, bufferedBytes int, droppedBytes uint64, eof, active bool) PTYStatus
NewPTYStatus 基于连接池句柄状态与 PTY 运行态快照构造有效的 PTYStatus。
func (PTYStatus) BufferedBytes ¶
func (PTYStatus) DroppedBytes ¶
func (PTYStatus) HandleStatus ¶
func (st PTYStatus) HandleStatus() pool.HandleStatus
func (PTYStatus) Size ¶
func (st PTYStatus) Size() ports.TerminalSize
type PrivilegeExecRequest ¶
type PrivilegeExecRequest struct {
Plan plan.SealedConnectionPlan
Privilege ports.PrivilegeRequest
Policy algebraic.Option[inventory.PrivilegePolicy]
Command algebraic.Option[execution.CommandPlan]
TargetUser algebraic.Option[option.Username]
Timeout algebraic.Option[algebraic.Duration]
NodeExecution algebraic.Option[execution.LaunchProfile]
ExecutionOverride algebraic.Option[execution.LaunchProfile]
NodeID, Term string
PasswordRef algebraic.Option[secret.Ref]
PromptMode ports.PrivilegePromptMode
Paths, RecursivePaths []string
LexicalScope algebraic.Option[security.ScopeSnapshot]
Canonicalize gate.CanonicalizeFunc
Stdin io.Reader
Stdout, Stderr io.Writer
ExtraEnv map[string]string
ForwardAgent algebraic.Option[inventory.AgentSpec]
OnStarted func() error
RequestTTY RequestTTYMode
EscapeChar algebraic.Option[option.EscapeCharSpec] // 可选:Raw-TTY 提权单命令转义字符策略(None 时默认 ~)
EscapeHelpText string // 可选:CLI 边界经 internal/i18n 预渲染的本地化 ~? 帮助文本
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
PrivilegeExecRequest 描述远端提权执行(sudo/su/doas 及节点持久化 PrivilegePolicy)用例的强类型输入 (ADR-008 / ADR-011 / ADR-018 / M1-T4)。 支持两种入口:
- 直接传入具体三态 PrivilegeRequest(优先生效);
- Privilege 留零值并传入 Policy(Node.privilege,支持 none/sudo/su/doas/auto + NonInteractive + su/doas PromptPattern)与 Command。
提权口令严禁以明文字节传递,仅允许经 Vault PasswordRef 或交互 PromptMode 在同步闭包内借用传递。
type ProbeShellRequest ¶
type ProbeShellRequest struct {
Plan plan.SealedConnectionPlan
NodeID string
Timeout algebraic.Option[algebraic.Duration]
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
ProbeShellRequest 描述远端 2 阶段默认 Shell 方言与解释器探测用例的强类型输入(P3-T2)。
type RemoteSpillResult ¶
type RemoteSpillResult struct {
ArtifactID string
SpillPath algebraic.Option[pathalg.RemotePath]
Spilled bool
SpillBytes uint64
SpillError error
}
RemoteSpillResult 描述同租约远端落盘结果;任何后置落盘 I/O 失败均记录于非致命 SpillError,绝不丢弃 ExecutionOutcome。
type RemoteSpillSpec ¶
type RemoteSpillSpec struct {
Enabled bool // 是否启用远端 ~/.cache/xops-mcp 原子落盘
MaxInlineBytes uint64 // 内联阈值(输出超过该字节数时触发后置落盘;0 默认 16 KiB)
MaxSpillBytes uint64 // 单次远端落盘字节硬上限(0 默认 10 MiB,上限 10 MiB)
ArtifactID string // 可选:调用方显式指定的确定性制品标识(空时确定性派生,严禁门控前抽熵)
}
RemoteSpillSpec 描述命令输出超阈值时的同租约远端原子落盘规格(ADR-020 v1.2); 零值或 Enabled==false 表示不启用远端落盘。
type RequestTTYMode ¶
type RequestTTYMode uint8
RequestTTYMode 标识 SSH 伪终端分配策略(对应 OpenSSH RequestTTY auto/yes/no/force 与 -t/-tt/-T); 零值 RequestTTYUnset 失败关闭于文本编解码,运行期按操作类型取确定性默认策略(交互 Shell=auto,单命令=no)。
const ( RequestTTYUnset RequestTTYMode = RequestTTYMode(sessplan.TTYUnset) // 未显式设置(零值) RequestTTYAuto RequestTTYMode = RequestTTYMode(sessplan.TTYAuto) // 自动:交互 Shell 且本机为 TTY 时分配 PTY RequestTTYYes RequestTTYMode = RequestTTYMode(sessplan.TTYYes) // 本机为 TTY 时分配 PTY(对应 -t) RequestTTYNo RequestTTYMode = RequestTTYMode(sessplan.TTYNo) // 禁止分配 PTY(对应 -T) RequestTTYForce RequestTTYMode = RequestTTYMode(sessplan.TTYForce) // 强制分配远端 PTY,即使本机非 TTY(对应 -tt) )
func ParseRequestTTYMode ¶
func ParseRequestTTYMode(raw string) (RequestTTYMode, error)
ParseRequestTTYMode 严格解析 RequestTTY 文本(auto/yes/no/force)。
func RequestTTYModeFrom ¶
func RequestTTYModeFrom(m sessplan.TTYMode) RequestTTYMode
RequestTTYModeFrom 将内部规划层 sessplan.TTYMode 投影为同值 RequestTTYMode(供父包 session 在 //xops:opaque 边界外构造)。
func (RequestTTYMode) AppendText ¶
func (m RequestTTYMode) AppendText(b []byte) ([]byte, error)
func (RequestTTYMode) IsValid ¶
func (m RequestTTYMode) IsValid() bool
IsValid / IsZero / String / TextAppender / TextMarshaler / TextUnmarshaler 实现 RequestTTYMode 值语义。
func (RequestTTYMode) IsZero ¶
func (m RequestTTYMode) IsZero() bool
func (RequestTTYMode) MarshalText ¶
func (m RequestTTYMode) MarshalText() ([]byte, error)
func (RequestTTYMode) String ¶
func (m RequestTTYMode) String() string
func (*RequestTTYMode) UnmarshalText ¶
func (m *RequestTTYMode) UnmarshalText(text []byte) error
type SSHForwardsActivationResult ¶
type SSHForwardsActivationResult struct {
// contains filtered or unexported fields
}
SSHForwardsActivationResult 封装显式 CLI ssh 批量激活持久化转发的不可变结果(已启动句柄与运行期失败清单);零值恒无效。
func NewSSHForwardsActivationResult ¶
func NewSSHForwardsActivationResult(started []ForwardInfo, failed []ForwardActivationFailure) SSHForwardsActivationResult
NewSSHForwardsActivationResult 构造有效的显式 CLI ssh 转发批量激活结果。
func (SSHForwardsActivationResult) Failed ¶
func (r SSHForwardsActivationResult) Failed() []ForwardActivationFailure
Failed 返回 ExitOnForwardFailure==false 模式下记录的运行期绑定失败明细切片副本。
func (SSHForwardsActivationResult) IsValid ¶
func (r SSHForwardsActivationResult) IsValid() bool
IsValid 报告 SSHForwardsActivationResult 是否经 ActivateSSHPolicyForwards 合法返回。
func (SSHForwardsActivationResult) IsZero ¶
func (r SSHForwardsActivationResult) IsZero() bool
IsZero 报告 SSHForwardsActivationResult 是否处于零值无效态。
func (SSHForwardsActivationResult) Started ¶
func (r SSHForwardsActivationResult) Started() []ForwardInfo
Started 返回成功启动的受管转发句柄切片副本。
type SSHPolicyPlan ¶
type SSHPolicyPlan struct {
// contains filtered or unexported fields
}
SSHPolicyPlan 封装从 option.EffectivePolicy 投影得到的不可变显式 CLI ssh 激活规划; 零值恒无效并严格失败关闭。
func PlanSSHPolicyActivation ¶
func PlanSSHPolicyActivation(policy option.EffectivePolicy, hasExplicitCommand bool) (SSHPolicyPlan, error)
PlanSSHPolicyActivation 将持久化 EffectivePolicy 投影为显式 CLI ssh 转发/TUN/会话与后台化激活规划; 投影 ForkAfterAuth 与仅限显式 CLI 的 AutoSpawnControlMaster(ADR-019 D1),仅对无效策略失败关闭。
func (SSHPolicyPlan) AutoSpawnControlMaster ¶
func (p SSHPolicyPlan) AutoSpawnControlMaster() bool
AutoSpawnControlMaster 报告显式 CLI ssh 路径在无存活主进程时是否应自动拉起持久化后台 ControlMaster (ControlPath 启用、ControlMaster ∈ {auto, autoask, yes, ask} 且 ControlPersist 启用)。
func (SSHPolicyPlan) EscapeChar ¶
func (p SSHPolicyPlan) EscapeChar() option.EscapeCharSpec
EscapeChar 返回经四层策略折叠后投影的会话转义字符策略;零值无效规划安全返回零值 EscapeCharSpec。 交互 PTY 会话在直连与 muxstream 模式下经 sessrt.EscapeFilter 解释 5 组序列,在原生 OpenSSH Master 下透传至协议层(ADR-019 C1)。
func (SSHPolicyPlan) ExitOnForwardFailure ¶
func (p SSHPolicyPlan) ExitOnForwardFailure() bool
func (SSHPolicyPlan) ForkAfterAuth ¶
func (p SSHPolicyPlan) ForkAfterAuth() bool
ForkAfterAuth 报告生效策略是否启用认证后后台脱离(-f / ForkAfterAuthentication=yes,仅限显式 CLI 路径交由后台守护处理)。
func (SSHPolicyPlan) Forwards ¶
func (p SSHPolicyPlan) Forwards() []ports.ForwardSpec
func (SSHPolicyPlan) IsValid ¶
func (p SSHPolicyPlan) IsValid() bool
SSHPolicyPlan 零值安全只读访问器(切片与映射均返回防御性拷贝)。
func (SSHPolicyPlan) IsZero ¶
func (p SSHPolicyPlan) IsZero() bool
func (SSHPolicyPlan) RemoteCommand ¶
func (p SSHPolicyPlan) RemoteCommand() algebraic.Option[string]
func (SSHPolicyPlan) RequestTTY ¶
func (p SSHPolicyPlan) RequestTTY() RequestTTYMode
func (SSHPolicyPlan) SessionType ¶
func (p SSHPolicyPlan) SessionType() option.SessionTypeMode
func (SSHPolicyPlan) SetEnv ¶
func (p SSHPolicyPlan) SetEnv() map[string]string
func (SSHPolicyPlan) StdinNull ¶
func (p SSHPolicyPlan) StdinNull() bool
type ServiceConfig ¶
type ServiceConfig struct {
Gate gate.Authorizer // 必填:能力门控授权器(ADR-008:严禁 nil)
Pool *pool.Pool // 必填:双通道纯内存 Actor 连接池(ADR-009)
Clock ports.Clock // 必填:时钟端口(事件时间戳、ControlPersist 与耗时统计)
DefaultExecution algebraic.Option[execution.LaunchProfile] // 可选:全局默认执行启动配置(6 级执行继承链 Global 层)
Env ports.EnvPort // 可选:只读环境变量与本机身份端口
Process ports.ProcessPort // 可选:本机零 Shell 受控子进程端口(ADR-019 C2 LocalCommand)
Terminal ports.TerminalPort // 可选:本机原始终端端口
Escalator ports.PrivilegeEscalationPort // 可选:远端提权(sudo/su/doas)端口
Vault ports.SecretVault // 可选:全作用域凭据库端口
Interaction ports.InteractionPort // 可选:人工交互端口
ShellProbe ports.ShellProbePort // 可选:2 阶段远端 Shell 探测端口
Forwarder ports.ForwarderPort // 可选:-L/-R/-D/StreamLocal/TUN 唯一受管转发端口(ADR-019 A1)
TUNDevice ports.TUNDevicePort // 渐进兼容保留字段:所有 TUN 隧道已统一经 Forwarder 路由(零直通旁路)
MuxSocket ports.MuxSocketPort // 可选:ControlMaster AF_UNIX 控制面端口
DiagnosticSink ports.DiagnosticSink // 可选:面向 -v/-vv/-vvv 的轻量脱敏诊断通道(严禁持锁调用)
DisallowForwardAgent bool // 可选:物理禁止 SSH Agent 转发(零值 false;MCP/受限视图置 true)
DisallowNativeMux bool // 可选:禁止经本 Service 启动的 ControlMaster 受理入站原生 OpenSSH Mux 请求(MCP 视图置 true)
ForcedMuxForwardBindOptions algebraic.Option[ports.ForwardBindOptions] // 可选:强制覆写单实例 ControlMaster 的 ForwardBindOptions 上限(MCP 视图锁 GatewayPortsNo + StreamLocalBindUnlink=false)
}
ServiceConfig 定义会话执行用例服务 Service 的显式出站依赖配置。
type StartForwardRequest ¶
type StartForwardRequest struct {
Plan plan.SealedConnectionPlan
Spec ports.ForwardSpec
BindOptions algebraic.Option[ports.ForwardBindOptions]
NodeID string
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
StartForwardRequest 描述启动 SSH 端口转发(-L/-R/-D)、StreamLocal(TCP↔Unix 双向/混合)或 TUN 隧道的强类型输入(P3-T2)。
type StdioForwardRequest ¶
type StdioForwardRequest struct {
Plan plan.SealedConnectionPlan
TargetTemplate string
NodeID string
Stdin io.Reader
Stdout io.Writer
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
StdioForwardRequest 描述 OpenSSH `-W host:port` 标准输入输出隧道转发用例的强类型输入(ADR-019 A3)。 TargetTemplate 在目标解析完成后按目标跳板展开 %h/%p 并经 netaddr.ParseHostPort 强校验。
type SubsystemRequest ¶
type SubsystemRequest struct {
Plan plan.SealedConnectionPlan
Subsystem string
NodeID, Term string
ExtraEnv map[string]string
Stdin io.Reader
Stdout, Stderr io.Writer
RequestTTY RequestTTYMode
EscapeChar algebraic.Option[option.EscapeCharSpec]
EscapeHelpText string
ForwardAgent algebraic.Option[option.ForwardAgentSpec]
IdentityAgent algebraic.Option[option.IdentityAgentSpec]
ExplicitForwardAgent bool
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
SubsystemRequest 描述经 RFC 4254 subsystem 请求启动远端 SSH 子系统(-s / SessionType=subsystem)的强类型输入(ADR-019 C1)。