probe

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 10 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

Overview

Package probe 实现 XOps v2 的规范化两阶段远端 Shell 探测适配器(ports.ShellProbePort,P4-T1)。

核心安全与协议不变量:

  • 本包不进入明文机密白名单,全包零行内 nolint 豁免、0 裸 go 语句与 0 path/filepath 导入;
  • 阶段 1 探测远端外层合法启动方言(posix / cmd / powershell)与规范 OS 族;
  • 阶段 2 在已确认的合法启动方言上枚举并校验可用解释器集合(bash / sh / zsh / powershell / pwsh / cmd), 产出经 execution.LaunchProfile 兼容性矩阵验证的不可变 ports.ShellProbeResult;
  • 严格失败关闭(Fail-Closed):未知/不支持的外层 Shell(如 fish/csh/受限菜单)、输出截断、 重复或畸形帧、缺失结束帧、传输错误或上下文取消均立即返回错误,绝不盲猜回退。

Index

Constants

This section is empty.

Variables

ErrProbeFailed 标识两阶段远端 Shell 探测无法确认合法启动方言或可用解释器(Fail-Closed)。

Functions

This section is empty.

Types

type Config

type Config struct {
	// CommandTimeout 可选覆盖单次探测命令的超时时长(<= 0 时默认 5s)。
	CommandTimeout time.Duration
	// MaxOutputBytes 可选覆盖单次探测命令的输出字节上限(0 时默认 16 KiB,超过 1 MiB 拒绝)。
	MaxOutputBytes uint64
	// ServerVersionHint 可选提供远端 SSH 版本串(如含 "OpenSSH_for_Windows" 时优先探测 cmd/powershell)。
	ServerVersionHint string
	// Stage1Only 为 true 时仅执行阶段 1 方言探测并返回 ProbeStage=1 + InterpreterServer;默认执行完整两阶段探测。
	Stage1Only bool
}

Config 描述 Prober 的显式运行期配置(零全局状态与隐式环境变量)。

type Prober

type Prober struct {
	// contains filtered or unexported fields
}

Prober 实现 ports.ShellProbePort,通过两阶段帧协议确定性识别远端启动方言与推荐解释器;零值恒失败关闭。

func NewProber

func NewProber(cfg Config) (*Prober, error)

NewProber 校验配置并构造不可变 Prober 实例。

func (*Prober) ProbeShell

func (p *Prober) ProbeShell(
	ctx context.Context,

	opener ports.SessionOpener,
) (ports.ShellProbeResult, error)

ProbeShell 通过借用的 opener 执行规范化两阶段远端 Shell 探测,实现 ports.ShellProbePort:

  • 阶段 1 按序探测合法启动方言(posix / cmd / powershell),遇传输/取消/截断立即失败关闭;
  • 阶段 2 在阶段 1 确认的方言上枚举并校验可用解释器,产出一律经 execution.LaunchProfile 校验的不可变快照。

Jump to

Keyboard shortcuts

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