ports

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 26 Imported by: ? 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 ports 定义 XOps v2 六边形核心的全部出站端口契约(公开契约 2,ADR-002 / ADR-003)。

本包、公开只读叶包 portval 及无环内部叶包 internal/portscheck 仅允许依赖 core/domain/** 与受控标准库, 严禁引入 core/internal/**、core/osfs、core/conc、core/events、testing 或具体协议实现库; 全作用域闭包(//xops:syncclosure + //xops:borrowed)、双模态本地 FS 隔离(ScopedRootFS vs OperatorReadFS)、 失败关闭零值与严格 json/v2 编解码均由本包确立。

Index

Constants

View Source
const (
	DiagnosticLevelMin = portval.DiagnosticLevelMin
	DiagnosticLevelMax = portval.DiagnosticLevelMax
)

诊断级别边界常量由 portval 单源重导出。

View Source
const TUNUnitAny uint32 = pc.TUNUnitAny

TUNUnitAny 表示由对端动态分配 TUN/TAP 单元号(对应 OpenSSH -w any:any)。

Variables

View Source
var (
	// 通用契约与参数错误。
	ErrNilContext       = domi18n.Sentinel(domi18n.KeyPortsNilContext)
	ErrNilCallback      = domi18n.Sentinel(domi18n.KeyPortsNilCallback)
	ErrNilReceiver      = portval.ErrNilReceiver
	ErrInvalidArgument  = portval.ErrInvalidArgument
	ErrUnsupported      = domi18n.Sentinel(domi18n.KeyPortsUnsupported)
	ErrClosed           = domi18n.Sentinel(domi18n.KeyPortsClosed)
	ErrNotFound         = domi18n.Sentinel(domi18n.KeyPortsNotFound)
	ErrAlreadyExists    = domi18n.Sentinel(domi18n.KeyPortsAlreadyExists)
	ErrPermissionDenied = domi18n.Sentinel(domi18n.KeyPortsPermissionDenied)
	ErrLimitExceeded    = domi18n.Sentinel(domi18n.KeyPortsLimitExceeded)
	// 配置存储、CAS 与持久化结果错误。
	ErrRevisionConflict  = domi18n.Sentinel(domi18n.KeyPortsRevisionConflict)
	ErrCorruptData       = portval.ErrCorruptData
	ErrInvalidRevision   = portval.ErrInvalidRevision
	ErrInvalidDurability = portval.ErrInvalidDurability
	// 本地双模态文件系统与文件锁错误。
	ErrInvalidLockMode   = domi18n.Sentinel(domi18n.KeyPortsInvalidLockMode)
	ErrInvalidReadLimits = domi18n.Sentinel(domi18n.KeyPortsInvalidReadLimits)
	ErrLockBusy          = domi18n.Sentinel(domi18n.KeyPortsLockBusy)
	ErrNotRegularFile    = domi18n.Sentinel(domi18n.KeyPortsNotRegularFile)
	ErrSymlinkRejected   = domi18n.Sentinel(domi18n.KeyPortsSymlinkRejected)
	ErrHandleExpired     = domi18n.Sentinel(domi18n.KeyPortsHandleExpired)
	// 凭据库、签名器与主机密钥信任错误。
	ErrVaultLocked        = domi18n.Sentinel(domi18n.KeyPortsVaultLocked)
	ErrSecretNotFound     = domi18n.Sentinel(domi18n.KeyPortsSecretNotFound)
	ErrSecretVerifyFailed = domi18n.Sentinel(domi18n.KeyPortsSecretVerifyFailed)
	ErrHostKeyMismatch    = domi18n.Sentinel(domi18n.KeyPortsHostKeyMismatch)
	ErrHostKeyUnknown     = domi18n.Sentinel(domi18n.KeyPortsHostKeyUnknown)
	ErrHostKeyRevoked     = domi18n.Sentinel(domi18n.KeyPortsHostKeyRevoked)
	ErrSignerUnavailable  = domi18n.Sentinel(domi18n.KeyPortsSignerUnavailable)
	// 传输拨号、多路复用与远端 SFTP 错误。
	ErrDialFailed           = domi18n.Sentinel(domi18n.KeyPortsDialFailed)
	ErrAuthFailed           = domi18n.Sentinel(domi18n.KeyPortsAuthFailed)
	ErrMuxUnavailable       = domi18n.Sentinel(domi18n.KeyPortsMuxUnavailable)
	ErrRemoteAnchorMismatch = domi18n.Sentinel(domi18n.KeyPortsRemoteAnchorMismatch)
	ErrRemoteIsDir          = domi18n.Sentinel(domi18n.KeyPortsRemoteIsDir)
	// 安全审计、崩溃对账、系统与交互错误。
	ErrAuditWriteFailed         = domi18n.Sentinel(domi18n.KeyPortsAuditWriteFailed)
	ErrAuditPostWrite           = domi18n.Sentinel(domi18n.KeyPortsAuditPostWrite)
	ErrAuditHalted              = domi18n.Sentinel(domi18n.KeyPortsAuditHalted)
	ErrInvalidAuditEntry        = domi18n.Sentinel(domi18n.KeyPortsInvalidAuditEntry)
	ErrInvalidProcessInstanceID = domi18n.Sentinel(domi18n.KeyPortsInvalidProcInstID)
	ErrInteractionUnavailable   = domi18n.Sentinel(domi18n.KeyPortsInteractionUnavail)
	ErrInteractionCanceled      = domi18n.Sentinel(domi18n.KeyPortsInteractionCanceled)
	ErrEntropyShortRead         = domi18n.Sentinel(domi18n.KeyPortsEntropyShortRead)
	ErrInvalidTTYSize           = portval.ErrInvalidTTYSize
)

本包导出的规范化哨兵错误,供用例、连接池、能力门控、宿主适配器、仿真器与 TCK 统一以 errors.Is 判定 (与公开子包 portval 共享的哨兵保持同源指针同一性)。

Functions

func CanPromptSecret added in v1.3.0

func CanPromptSecret(ui InteractionPort) bool

CanPromptSecret 报告交互端口是否可用于 SSH 认证机密采集或主机密钥确认(ADR-019 B3): nil 端口严格失败关闭返回 false;若实现 SecretPromptCapable 则委托其 CanPromptSecret(),否则回退至 CanInteract()。

func ResolveTier4WithOptions added in v1.3.0

func ResolveTier4WithOptions(
	ctx context.Context,
	src OpenSSHConfigSource,
	target option.OriginalHostSpec,
	endpoint algebraic.Option[netaddr.Endpoint],
	opts Tier4ResolveOptions,
) (option.OptionLayer, error)

ResolveTier4WithOptions 优先委托 CanonicalOpenSSHConfigSource.ResolveTier4WithOptions; 若 src 尚未实现该具名可选接口则平滑回退至 OpenSSHConfigSource.ResolveTier4; 显式拦截 nil ctx(返回 ErrNilContext)与 nil src(返回 ErrInvalidArgument)。

func ServeMuxWithOptions added in v1.3.0

func ServeMuxWithOptions(
	ctx context.Context,
	mux MuxSocketPort,

	ln net.Listener,
	upstream TransportConn,
	forwarder ForwarderPort,
	opts MuxServeOptions,
) error

ServeMuxWithOptions 委托 MuxServeOptionsPort.ServeWithOptions,并在未实现该可选接口的适配器上渐进回退至 Serve; 当 opts 携带 DisallowNativeMux 或显式 ForwardBindOptions 安全约束而适配器不支持单实例策略时, 严格失败关闭返回 ErrUnsupported,绝不静默丢弃安全上限。

func UsesDirectNativeTTY added in v1.3.0

func UsesDirectNativeTTY(sess RemoteSession) bool

UsesDirectNativeTTY 报告给定远端会话在 PTY 模式下是否采用原生控制终端 FD 直通(ADR-019 C1 / D3): nil 或未实现 DirectTTYRemoteSession 时严格失败关闭返回 false。

Types

type ActiveChannelSnapshot added in v1.3.0

type ActiveChannelSnapshot = portval.ActiveChannelSnapshot

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewActiveChannelSnapshot added in v1.3.0

func NewActiveChannelSnapshot(spec ActiveChannelSnapshotSpec) (ActiveChannelSnapshot, error)

func QueryConnActiveChannels added in v1.3.0

func QueryConnActiveChannels(ctx context.Context, conn TransportConn) (ActiveChannelSnapshot, error)

QueryConnActiveChannels 委托 ActiveChannelSnapshotProvider.ActiveChannels;nil ctx 返回 ErrNilContext, nil conn 返回 ErrInvalidArgument,未实现 ActiveChannelSnapshotProvider 的连接显式返回 ErrUnsupported。

func QueryMuxChannels added in v1.3.0

func QueryMuxChannels(ctx context.Context, mux MuxSocketPort, socketPath pathalg.LocalSourcePath) (ActiveChannelSnapshot, error)

QueryMuxChannels 委托 MuxInspectPort.QueryChannels;nil ctx 返回 ErrNilContext,nil mux 返回 ErrInvalidArgument, 未实现 MuxInspectPort 的适配器显式返回 ErrUnsupported。

type ActiveChannelSnapshotProvider added in v1.3.0

type ActiveChannelSnapshotProvider interface {
	ActiveChannels(ctx context.Context) (ActiveChannelSnapshot, error)
}

ActiveChannelSnapshotProvider 是 TransportConn / 会话上下文的具名可选只读通道快照查询接口(ADR-019 C1 / D2), 供交互会话 ~# 转义与多路复用状态观测统一读取活跃会话数及转发快照,严禁匿名接口断言(noimplicit)。

type ActiveChannelSnapshotSpec added in v1.3.0

type ActiveChannelSnapshotSpec = portval.ActiveChannelSnapshotSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type ActiveForwardSnapshot added in v1.3.0

type ActiveForwardSnapshot = portval.ActiveForwardSnapshot

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewActiveForwardSnapshot added in v1.3.0

func NewActiveForwardSnapshot(spec ActiveForwardSnapshotSpec) (ActiveForwardSnapshot, error)

func NewActiveForwardSnapshotFromSpec added in v1.3.0

func NewActiveForwardSnapshotFromSpec(spec ForwardSpec, boundAddr string, activeConns uint32) (ActiveForwardSnapshot, error)

NewActiveForwardSnapshotFromSpec 由已校验 ForwardSpec、实际监听地址与活跃连接数构造不可变 ActiveForwardSnapshot。

type ActiveForwardSnapshotSpec added in v1.3.0

type ActiveForwardSnapshotSpec = portval.ActiveForwardSnapshotSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type ApprovalDecisionResponse

type ApprovalDecisionResponse = portval.ApprovalDecisionResponse

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewApprovalDecisionResponse

func NewApprovalDecisionResponse(verdict security.Verdict, envelopeDigest security.Digest, comment string) (ApprovalDecisionResponse, error)

type AuditEntry

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

AuditEntry 表示一条面向 JSONL 同步落盘的不可变安全审计记录(ADR-008);零值恒无效。

func NewAuditEntry

func NewAuditEntry(spec AuditEntrySpec) (AuditEntry, error)

NewAuditEntry 校验标识、阶段/结果/决策配对、RFC 3339 时间戳与非负可选耗时并构造 AuditEntry。

func (AuditEntry) Binding

func (e AuditEntry) Binding() security.OperationBinding

func (AuditEntry) CanonicalJSON

func (e AuditEntry) CanonicalJSON() ([]byte, error)

func (AuditEntry) Decision

func (e AuditEntry) Decision() security.DecisionKind

func (AuditEntry) Duration

func (AuditEntry) Equal

func (e AuditEntry) Equal(o AuditEntry) bool

func (AuditEntry) ErrorCode

func (e AuditEntry) ErrorCode() string

func (AuditEntry) IsValid

func (e AuditEntry) IsValid() bool

func (AuditEntry) IsZero

func (e AuditEntry) IsZero() bool

func (AuditEntry) MarshalJSONTo

func (e AuditEntry) MarshalJSONTo(x jEnc) error

func (AuditEntry) OperationID

func (e AuditEntry) OperationID() security.OperationID

func (AuditEntry) Outcome

func (e AuditEntry) Outcome() AuditOutcome

func (AuditEntry) Phase

func (e AuditEntry) Phase() AuditPhase

func (AuditEntry) ProcessID

func (e AuditEntry) ProcessID() ProcessInstanceID

func (AuditEntry) Reason

func (e AuditEntry) Reason() string

func (AuditEntry) Risk

func (e AuditEntry) Risk() security.RiskLevel

func (AuditEntry) Timestamp

func (e AuditEntry) Timestamp() time.Time

func (AuditEntry) TraceID

func (e AuditEntry) TraceID() security.TraceID

func (*AuditEntry) UnmarshalJSONFrom

func (e *AuditEntry) UnmarshalJSONFrom(c jDec) error

type AuditEntrySpec

type AuditEntrySpec struct {
	ProcessID         ProcessInstanceID
	TraceID           security.TraceID
	OperationID       security.OperationID
	Phase             AuditPhase
	Outcome           AuditOutcome
	Risk              security.RiskLevel
	Decision          security.DecisionKind
	Binding           security.OperationBinding
	Timestamp         time.Time
	Duration          algebraic.Option[algebraic.Duration]
	ErrorCode, Reason string
}

AuditEntrySpec 是构造不可变 AuditEntry 的显式入参规格(严禁 SecretBox 或裸 time.Duration)。

type AuditOutcome

type AuditOutcome uint8

AuditOutcome 标识审计记录对应的结果语义;零值 AuditOutcomeInvalid 失败关闭。

const (
	AuditOutcomeInvalid        AuditOutcome = AuditOutcome(pc.AuditOutcomeInvalidCode)        // 无效结果(零值失败关闭)
	AuditOutcomePending        AuditOutcome = AuditOutcome(pc.AuditOutcomePendingCode)        // 已授权待执行闭合(仅配对 Authorized)
	AuditOutcomeDenied         AuditOutcome = AuditOutcome(pc.AuditOutcomeDeniedCode)         // 策略或审批拒绝(仅配对 Denied)
	AuditOutcomeSucceeded      AuditOutcome = AuditOutcome(pc.AuditOutcomeSucceededCode)      // 终态:执行成功
	AuditOutcomeFailed         AuditOutcome = AuditOutcome(pc.AuditOutcomeFailedCode)         // 终态:执行失败
	AuditOutcomeCanceled       AuditOutcome = AuditOutcome(pc.AuditOutcomeCanceledCode)       // 终态:上下文取消或中断
	AuditOutcomeEscalated      AuditOutcome = AuditOutcome(pc.AuditOutcomeEscalatedCode)      // 终态:二阶段规范化作用域升级并撤销放行
	AuditOutcomeAbortedByCrash AuditOutcome = AuditOutcome(pc.AuditOutcomeAbortedByCrashCode) // 终态:崩溃恢复对账补写
	AuditOutcomeUnknown        AuditOutcome = AuditOutcome(pc.AuditOutcomeUnknownCode)        // 终态:副作用结果未知(严禁降级为 Failed)
)

func ParseAuditOutcome

func ParseAuditOutcome(s string) (AuditOutcome, error)

func (AuditOutcome) AppendText

func (o AuditOutcome) AppendText(b []byte) ([]byte, error)

func (AuditOutcome) IsValid

func (o AuditOutcome) IsValid() bool

func (AuditOutcome) IsZero

func (o AuditOutcome) IsZero() bool

func (AuditOutcome) MarshalText

func (o AuditOutcome) MarshalText() ([]byte, error)

func (AuditOutcome) String

func (o AuditOutcome) String() string

func (*AuditOutcome) UnmarshalText

func (o *AuditOutcome) UnmarshalText(t []byte) error

type AuditPhase

type AuditPhase uint8

AuditPhase 标识单条审计记录所处的操作生命周期阶段(ADR-008);零值 AuditPhaseInvalid 失败关闭。

const (
	AuditPhaseInvalid    AuditPhase = AuditPhase(pc.AuditPhaseInvalidCode)    // 无效阶段(零值失败关闭)
	AuditPhaseDenied     AuditPhase = AuditPhase(pc.AuditPhaseDeniedCode)     // 准入或审批阶段直接拒绝
	AuditPhaseAuthorized AuditPhase = AuditPhase(pc.AuditPhaseAuthorizedCode) // 能力证明签发前置落盘记录
	AuditPhaseFinalized  AuditPhase = AuditPhase(pc.AuditPhaseFinalizedCode)  // 操作终态闭合记录
)

func ParseAuditPhase

func ParseAuditPhase(s string) (AuditPhase, error)

func (AuditPhase) AppendText

func (p AuditPhase) AppendText(b []byte) ([]byte, error)

func (AuditPhase) IsValid

func (p AuditPhase) IsValid() bool

func (AuditPhase) IsZero

func (p AuditPhase) IsZero() bool

func (AuditPhase) MarshalText

func (p AuditPhase) MarshalText() ([]byte, error)

func (AuditPhase) String

func (p AuditPhase) String() string

func (*AuditPhase) UnmarshalText

func (p *AuditPhase) UnmarshalText(t []byte) error

type AuditPostWriteError

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

AuditPostWriteError 表示副作用完成后写入终态审计失败的致命故障(ADR-008);实现单值 Unwrap 与 Is(ErrAuditPostWrite)。

func NewAuditPostWriteError

func NewAuditPostWriteError(opID security.OperationID, cause error) (*AuditPostWriteError, error)

NewAuditPostWriteError 校验 operationID 有效后构造不可变 *AuditPostWriteError。

func (*AuditPostWriteError) Error

func (e *AuditPostWriteError) Error() string

func (*AuditPostWriteError) Is

func (e *AuditPostWriteError) Is(t error) bool

func (*AuditPostWriteError) IsValid

func (e *AuditPostWriteError) IsValid() bool

func (*AuditPostWriteError) LocalizableView added in v1.1.0

func (e *AuditPostWriteError) LocalizableView() domi18n.ErrorNode

LocalizableView 返回结构化错误节点视图,供边界无穿透本地化并在默认 cause==ErrAuditPostWrite 时精准折叠。

func (*AuditPostWriteError) OperationID

func (e *AuditPostWriteError) OperationID() security.OperationID

func (*AuditPostWriteError) Unwrap

func (e *AuditPostWriteError) Unwrap() error

type AuditReconciler

type AuditReconciler interface {
	ReconcileCrashedAudits(ctx context.Context, now time.Time) (CrashReconcileReport, error)
}

AuditReconciler 定义引擎启动期 O(1) 跨进程崩溃审计对账出站端口(ADR-008 / RFC §3.4)。

type AuditSink

type AuditSink interface {
	ProcessInstanceID() ProcessInstanceID
	StageOperation(ctx context.Context, opID security.OperationID) error
	UnstageOperation(ctx context.Context, opID security.OperationID) error
	Record(ctx context.Context, entry AuditEntry) error
	Close() error
}

AuditSink 定义同步 Fail-Closed 审计写入与只追加活跃操作登记出站端口(ADR-008)。

type BoundedReadHandle

type BoundedReadHandle interface {
	io.Reader
	io.ReaderAt
}

BoundedReadHandle 是同步闭包内借出的有界随机只读句柄(顺序 Reader + 并发安全 ReaderAt),退出后返回 ErrHandleExpired。

type CanonicalOpenSSHConfigSource added in v1.3.0

type CanonicalOpenSSHConfigSource interface {
	OpenSSHConfigSource
	// ResolveTier4WithOptions 按原始主机 target、可选规范化端点 endpoint 与解析轮次 opts 折叠 Tier-4 选项层。
	ResolveTier4WithOptions(ctx context.Context, target option.OriginalHostSpec, endpoint algebraic.Option[netaddr.Endpoint], opts Tier4ResolveOptions) (option.OptionLayer, error)
}

CanonicalOpenSSHConfigSource 是 OpenSSHConfigSource 的具名可选扩展接口(ADR-019 E1), 在保持既有 OpenSSHConfigSource 方法集零破坏的前提下提供带 CanonicalPass 轮次选项的 Tier-4 选项折叠。

type CanonicalResolverPort added in v1.3.0

type CanonicalResolverPort interface {
	LookupHost(ctx context.Context, host string) ([]string, error)
	// LookupCNAME 查询主机名对应的规范名称(存在 CNAME 时返回下一跳或终态规范名,无 CNAME 但存在主机记录时返回主机自身规范名)。
	// 端口输出统一去除末尾 DNS 根点 '.'(适配标准库 net.Resolver.LookupCNAME 的宿主实现须在端口边界去除末尾 '.'),
	// 使 SimCanonicalResolver、TCK 与资产规范化调用方共享唯一无歧义契约。
	LookupCNAME(ctx context.Context, host string) (string, error)
}

CanonicalResolverPort 定义只读主机名与 CNAME 解析出站端口(ADR-019 E1), 由 internal/host/sys 或 core/internal/sim 实现,用于资产解析期执行有界两轮 OpenSSH 规范化。

type Clock

type Clock interface {
	Now() time.Time
	Since(t time.Time) time.Duration
	NewTimer(d time.Duration) Timer
	Sleep(ctx context.Context, d time.Duration) error
}

Clock 定义时钟与定时等待出站端口(ADR-002 / DST 确定性基础)。

type ConfirmRequest

type ConfirmRequest = portval.ConfirmRequest

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewConfirmRequest

func NewConfirmRequest(spec ConfirmRequestSpec) (ConfirmRequest, error)

type ConfirmRequestSpec

type ConfirmRequestSpec = portval.ConfirmRequestSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type CrashReconcileReport

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

CrashReconcileReport 描述启动期 O(1) 崩溃对账的确定性汇总报告(RFC §3.4);零值恒无效。

func NewCrashReconcileReport

func NewCrashReconcileReport(spec CrashReconcileReportSpec) (CrashReconcileReport, error)

NewCrashReconcileReport 校验计数非负、一致性及全部补写 OperationID 有效后构造不可变报告。

func (CrashReconcileReport) AbortedOperations

func (r CrashReconcileReport) AbortedOperations() []security.OperationID

func (CrashReconcileReport) DeadLocksClaimed

func (r CrashReconcileReport) DeadLocksClaimed() int

func (CrashReconcileReport) Equal

func (CrashReconcileReport) IsValid

func (r CrashReconcileReport) IsValid() bool

func (CrashReconcileReport) IsZero

func (r CrashReconcileReport) IsZero() bool

func (CrashReconcileReport) LiveLocksSkipped

func (r CrashReconcileReport) LiveLocksSkipped() int

func (CrashReconcileReport) MarshalJSONTo

func (r CrashReconcileReport) MarshalJSONTo(e jEnc) error

func (CrashReconcileReport) ScannedLocks

func (r CrashReconcileReport) ScannedLocks() int

func (*CrashReconcileReport) UnmarshalJSONFrom

func (r *CrashReconcileReport) UnmarshalJSONFrom(c jDec) error

type CrashReconcileReportSpec

type CrashReconcileReportSpec struct {
	ScannedLocks, LiveLocksSkipped, DeadLocksClaimed int
	AbortedOperations                                []security.OperationID
}

CrashReconcileReportSpec 是构造不可变 CrashReconcileReport 的显式入参规格。

type DiagnosticRecord added in v1.3.0

type DiagnosticRecord = portval.DiagnosticRecord

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewDiagnosticRecord added in v1.3.0

func NewDiagnosticRecord(spec DiagnosticRecordSpec) (DiagnosticRecord, error)

type DiagnosticRecordSpec added in v1.3.0

type DiagnosticRecordSpec = portval.DiagnosticRecordSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type DiagnosticSink added in v1.3.0

type DiagnosticSink interface {
	Emit(ctx context.Context, rec DiagnosticRecord)
}

DiagnosticSink 定义面向 -v/-vv/-vvv 诊断输出的轻量可取消只写通道(ADR-019 C3), 独立于 core/events 避免扩充 Severity 枚举;调用方严禁在持有内部互斥锁期间调用 Emit,防止阻塞或死锁热路径。

type DialerPort

type DialerPort interface {
	DialHop(ctx context.Context, hop plan.HopSpec, hopDigest plan.HopDigest, parent TransportConn) (TransportConn, error)
}

DialerPort 定义协议无关的 SSH 单跳/多跳拨号出站端口(ADR-009 / ADR-015)。

type DirectTTYRemoteSession added in v1.3.0

type DirectTTYRemoteSession interface {
	UsesDirectNativeTTY() bool
}

DirectTTYRemoteSession 是 RemoteSession 的具名可选扩展接口(ADR-019 C1 / D3), 用于标识在 PTY 模式下经 OS SCM_RIGHTS 直接移交本机控制终端 FD 给原生 OpenSSH ControlMaster 的会话实现; 严禁匿名接口断言(noimplicit),调用方须经 UsesDirectNativeTTY 辅助函数判定。

type DurabilityOutcome

type DurabilityOutcome = portval.DurabilityOutcome

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewDurabilityAppliedNotDurable

func NewDurabilityAppliedNotDurable(revision algebraic.Option[Revision], detail string) (DurabilityOutcome, error)

func NewDurabilityCommitted

func NewDurabilityCommitted(revision Revision) (DurabilityOutcome, error)

func NewDurabilityNotApplied

func NewDurabilityNotApplied(detail string) (DurabilityOutcome, error)

func NewDurabilityOutcomeUnknown

func NewDurabilityOutcomeUnknown(detail string) (DurabilityOutcome, error)

type Entropy

type Entropy interface{ io.Reader }

Entropy 定义显式密码学/确定性熵源出站端口(ADR-003);所有实现必须并发安全。

type EnvPort

type EnvPort interface {
	LookupEnv(key string) (string, bool)
	Environ() map[string]string
	LookupLocalIdentity() (LocalIdentityInfo, error)
}

EnvPort 定义只读本机环境变量与本机主机/用户元信息出站端口(由 internal/host/sys 或 sim 实现,ADR-002)。

type ExecStreams

type ExecStreams struct {
	Stdin          io.Reader
	Stdout, Stderr io.Writer
	PTY            algebraic.Option[PTYRequest]
	Env            map[string]string
	ForwardAgent   algebraic.Option[inventory.AgentSpec]
	EscapeChar     algebraic.Option[option.EscapeCharSpec]
}

ExecStreams 聚合单次远端会话执行的运行期数据面流、可选 PTY、经 SendEnv 过滤后的环境变量、 可选 Agent 转发规格与可选原生转义字符规格(非持久化 DTO)。

type FormatImporter

type FormatImporter interface {
	Format() string
	Import(ctx context.Context, sourceName string, r io.Reader) (inventory.ImportBundle, error)
}

FormatImporter 定义配置导入层的格式无关扩展端口(ADR-006,如 openssh / csv,100% 零 v1 代码)。

type ForwardBindOptions added in v1.3.0

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

ForwardBindOptions 封装经校验的本地隧道转发绑定策略(GatewayPorts、StreamLocal 掩码/摘除、AddressFamily 与可选 Unix 沙箱根);零值恒无效(fail-closed)。 合法实例允许携带 GatewayPortsUnset、AddressFamilyUnset 与 Option.None 表示继承适配器默认策略,显式设值时才覆写对应维度。

func DefaultForwardBindOptions added in v1.3.0

func DefaultForwardBindOptions() ForwardBindOptions

DefaultForwardBindOptions 返回全维度不覆写的合法绑定策略(GatewayPortsUnset、Unlink=None、Mask=None、AddressFamilyUnset、ConfineUnixRoot=None), 继承 Forwarder.Config 默认策略(零值最严为 GatewayPortsNo / unlink=false / mask=0177 / af=any)。

func NewForwardBindOptions added in v1.3.0

func NewForwardBindOptions(spec ForwardBindOptionsSpec) (ForwardBindOptions, error)

NewForwardBindOptions 校验并构造不可变 ForwardBindOptions:保留 GatewayPortsUnset 与 AddressFamilyUnset(继承适配器默认) 及显式合法枚举值,拒绝未知枚举值、无效 StreamLocalBindMask、0777 掩码以及非绝对或根级 ConfineUnixRoot。

func (ForwardBindOptions) AddressFamily added in v1.3.0

func (o ForwardBindOptions) AddressFamily() option.AddressFamily

func (ForwardBindOptions) ConfineUnixRoot added in v1.3.0

func (o ForwardBindOptions) ConfineUnixRoot() algebraic.Option[pathalg.LocalDir]

func (ForwardBindOptions) Equal added in v1.3.0

func (ForwardBindOptions) GatewayPorts added in v1.3.0

func (o ForwardBindOptions) GatewayPorts() option.GatewayPortsMode

func (ForwardBindOptions) IsValid added in v1.3.0

func (o ForwardBindOptions) IsValid() bool

func (ForwardBindOptions) IsZero added in v1.3.0

func (o ForwardBindOptions) IsZero() bool

func (ForwardBindOptions) MarshalJSONTo added in v1.3.0

func (o ForwardBindOptions) MarshalJSONTo(e jEnc) error

func (ForwardBindOptions) StreamLocalBindMask added in v1.3.0

func (o ForwardBindOptions) StreamLocalBindUnlink() algebraic.Option[bool]

func (*ForwardBindOptions) UnmarshalJSONFrom added in v1.3.0

func (o *ForwardBindOptions) UnmarshalJSONFrom(c jDec) error

type ForwardBindOptionsSpec added in v1.3.0

type ForwardBindOptionsSpec struct {
	GatewayPorts          option.GatewayPortsMode                      `json:"gateway_ports,omitzero"`
	StreamLocalBindUnlink algebraic.Option[bool]                       `json:"stream_local_bind_unlink,omitzero"`
	StreamLocalBindMask   algebraic.Option[option.StreamLocalBindMask] `json:"stream_local_bind_mask,omitzero"`
	AddressFamily         option.AddressFamily                         `json:"address_family,omitzero"`
	ConfineUnixRoot       algebraic.Option[pathalg.LocalDir]           `json:"confine_unix_root,omitzero"`
}

ForwardBindOptionsSpec 是构造不可变 ForwardBindOptions 的显式入参规格。 五字段遵循对称覆写幺半群语义:GatewayPortsUnset、AddressFamilyUnset 与 Option.None 表示不覆写, 继承 Forwarder.Config 构造默认策略(其零值本身 fail-closed 为 GatewayPortsNo / unlink=false / mask=0177 / af=any); ConfineUnixRoot 非空时强制本地 AF_UNIX 绑定受限于指定非根绝对目录(防软链逃逸,ADR-019 v2.2 S3-Q4b)。

type ForwardDirection

type ForwardDirection uint8

ForwardDirection 标识 SSH 隧道转发方向类别(-L/-R/-D/TUN);零值 ForwardDirectionInvalid 失败关闭。

const (
	ForwardDirectionInvalid ForwardDirection = ForwardDirection(pc.ForwardDirInvalidCode) // 无效转发方向(零值失败关闭)
	ForwardLocal            ForwardDirection = ForwardDirection(pc.ForwardDirLocalCode)   // 本地监听 -> 远端目标转发(-L,支持 TCP 与 StreamLocal 双向/混合)
	ForwardRemote           ForwardDirection = ForwardDirection(pc.ForwardDirRemoteCode)  // 远端监听 -> 本地目标转发或反向动态 SOCKS5(-R,支持 TCP/StreamLocal 及无目标反向动态)
	ForwardDynamic          ForwardDirection = ForwardDirection(pc.ForwardDirDynamicCode) // 本地动态 SOCKS5 转发(-D,支持 TCP 与 Unix 套接字)
	ForwardTUN              ForwardDirection = ForwardDirection(pc.ForwardDirTUNCode)     // L2/L3 隧道设备转发(-w)
)

func ParseForwardDirection

func ParseForwardDirection(s string) (ForwardDirection, error)

func (ForwardDirection) AppendText

func (d ForwardDirection) AppendText(b []byte) ([]byte, error)

func (ForwardDirection) IsValid

func (d ForwardDirection) IsValid() bool

func (ForwardDirection) IsZero

func (d ForwardDirection) IsZero() bool

func (ForwardDirection) MarshalText

func (d ForwardDirection) MarshalText() ([]byte, error)

func (ForwardDirection) String

func (d ForwardDirection) String() string

func (*ForwardDirection) UnmarshalText

func (d *ForwardDirection) UnmarshalText(t []byte) error

type ForwardEndpointKind

type ForwardEndpointKind uint8

ForwardEndpointKind 标识隧道转发监听端或目标端的端点协议类别(TCP / Unix Domain Socket);零值失败关闭。

const (
	ForwardEndpointInvalid ForwardEndpointKind = ForwardEndpointKind(pc.ForwardEndInvalidCode) // 无效端点类别(零值失败关闭)
	ForwardEndpointTCP     ForwardEndpointKind = ForwardEndpointKind(pc.ForwardEndTCPCode)     // TCP host:port 端点
	ForwardEndpointUnix    ForwardEndpointKind = ForwardEndpointKind(pc.ForwardEndUnixCode)    // Unix Domain Socket (StreamLocal) 端点
)

func ParseForwardEndpointKind

func ParseForwardEndpointKind(s string) (ForwardEndpointKind, error)

func (ForwardEndpointKind) AppendText

func (k ForwardEndpointKind) AppendText(b []byte) ([]byte, error)

func (ForwardEndpointKind) IsValid

func (k ForwardEndpointKind) IsValid() bool

func (ForwardEndpointKind) IsZero

func (k ForwardEndpointKind) IsZero() bool

func (ForwardEndpointKind) MarshalText

func (k ForwardEndpointKind) MarshalText() ([]byte, error)

func (ForwardEndpointKind) String

func (k ForwardEndpointKind) String() string

func (*ForwardEndpointKind) UnmarshalText

func (k *ForwardEndpointKind) UnmarshalText(t []byte) error

type ForwardHandle

type ForwardHandle interface {
	IsValid() bool
	Spec() ForwardSpec
	BoundAddr() string
	Done() <-chan struct{}
	Err() error
	Close() error
}

ForwardHandle 表示受管长生命周期隧道转发实例(满足 pool.ManagedResource),经 pool.RegisterLeaseHandleWith 纳入世代撤销与跳板钉选。

type ForwardSpec

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

ForwardSpec 描述单条 SSH 隧道转发规则(显式区分方向、监听/目标端点类型与强类型 TUNSpec);零值恒无效。

func NewForwardSpec

func NewForwardSpec(direction ForwardDirection, bindAddr, targetAddr string) (ForwardSpec, error)

NewForwardSpec 构造默认 TCP 端点的非 TUN 转发规则(ForwardLocal 为 TCP->TCP, ForwardRemote 在 targetAddr 非空时为 TCP->TCP、为空时为 -R 反向动态 SOCKS5,ForwardDynamic 为 TCP 无目标); 涉及 StreamLocal(含 -D Unix 套接字)请使用 NewTypedForwardSpec,ForwardTUN 须经 NewForwardTUNSpec。

func NewForwardTUNSpec

func NewForwardTUNSpec(tun TUNSpec) (ForwardSpec, error)

NewForwardTUNSpec 校验强类型 TUNSpec 并构造 ForwardTUN 方向的不可变 ForwardSpec。

func NewTypedForwardSpec

func NewTypedForwardSpec(direction ForwardDirection, bindKind ForwardEndpointKind, bindAddr string, targetKind ForwardEndpointKind, targetAddr string) (ForwardSpec, error)

NewTypedForwardSpec 校验非 TUN 转发方向、显式监听/目标端点类型与地址组合并构造不可变 ForwardSpec, 完整支持 -L/-R 的 TCP↔TCP、Unix↔Unix、TCP↔Unix 组合、-R 反向动态 SOCKS5(TCP 绑定 + 无目标)以及 -D TCP/Unix 套接字。

func (ForwardSpec) BindAddr

func (f ForwardSpec) BindAddr() string

func (ForwardSpec) BindKind

func (f ForwardSpec) BindKind() ForwardEndpointKind

func (ForwardSpec) Direction

func (f ForwardSpec) Direction() ForwardDirection

func (ForwardSpec) Equal

func (f ForwardSpec) Equal(o ForwardSpec) bool

func (ForwardSpec) IsReverseDynamic added in v1.3.0

func (f ForwardSpec) IsReverseDynamic() bool

IsReverseDynamic 报告该转发规则是否为有效的 -R 反向动态 SOCKS5 转发(ForwardRemote 且无固定目标)。

func (ForwardSpec) IsValid

func (f ForwardSpec) IsValid() bool

func (ForwardSpec) IsZero

func (f ForwardSpec) IsZero() bool

func (ForwardSpec) MarshalJSONTo

func (f ForwardSpec) MarshalJSONTo(e jEnc) error

func (ForwardSpec) TUN

func (ForwardSpec) TargetAddr

func (f ForwardSpec) TargetAddr() string

func (ForwardSpec) TargetKind

func (f ForwardSpec) TargetKind() ForwardEndpointKind

func (*ForwardSpec) UnmarshalJSONFrom

func (f *ForwardSpec) UnmarshalJSONFrom(c jDec) error

type ForwarderPort

type ForwarderPort interface {
	// StartForward 按 opts 绑定策略启动受管隧道转发;transport 持留至 ForwardHandle.Close()(非 //xops:borrowed),
	// 须由 pool.RegisterLeaseHandleWith 传入池钉选视图;零值或无效 opts 须 fail-closed 返回 ErrInvalidArgument。
	StartForward(ctx context.Context, transport TunnelTransport, spec ForwardSpec, opts ForwardBindOptions) (ForwardHandle, error)
}

ForwarderPort 定义 SSH 端口转发(-L/-R/-D)、StreamLocal 与 TUN 启动出站端口(P3-T2 <-> P4-T2 sshnet/forward)。

type HostTrustCheck

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

HostTrustCheck 表示 HostTrustPort.VerifyHostKey 返回的不可变核验结论;零值恒无效并拒绝信任。

func NewHostTrustCheck

func NewHostTrustCheck(spec HostTrustCheckSpec) (HostTrustCheck, error)

NewHostTrustCheck 校验核验状态、端点、呈递公钥与可选预期指纹列表并构造不可变 HostTrustCheck。

func (HostTrustCheck) Endpoint

func (c HostTrustCheck) Endpoint() netaddr.Endpoint

func (HostTrustCheck) Equal

func (c HostTrustCheck) Equal(o HostTrustCheck) bool

func (HostTrustCheck) ExpectedFingerprints

func (c HostTrustCheck) ExpectedFingerprints() []inventory.KeyFingerprint

func (HostTrustCheck) IsTrusted

func (c HostTrustCheck) IsTrusted() bool

func (HostTrustCheck) IsValid

func (c HostTrustCheck) IsValid() bool

func (HostTrustCheck) IsZero

func (c HostTrustCheck) IsZero() bool

func (HostTrustCheck) MarshalJSONTo

func (c HostTrustCheck) MarshalJSONTo(e jEnc) error

func (HostTrustCheck) Presented

func (c HostTrustCheck) Presented() PublicKeyInfo

func (HostTrustCheck) Reason

func (c HostTrustCheck) Reason() string

func (HostTrustCheck) Status

func (c HostTrustCheck) Status() HostTrustStatus

func (*HostTrustCheck) UnmarshalJSONFrom

func (c *HostTrustCheck) UnmarshalJSONFrom(d jDec) error

type HostTrustCheckSpec

type HostTrustCheckSpec struct {
	Status               HostTrustStatus            `json:"status"`
	Endpoint             netaddr.Endpoint           `json:"endpoint"`
	Presented            PublicKeyInfo              `json:"presented"`
	ExpectedFingerprints []inventory.KeyFingerprint `json:"expected_fingerprints,omitzero"`
	Reason               string                     `json:"reason,omitzero"`
}

HostTrustCheckSpec 是构造不可变 HostTrustCheck 的显式入参规格。

type HostTrustPort

type HostTrustPort interface {
	PreferredAlgorithms(ctx context.Context, endpoint netaddr.Endpoint, knownHosts option.KnownHostsList) ([]string, error)
	VerifyHostKey(ctx context.Context, req HostTrustRequest) (HostTrustCheck, error)
	RecordHostKey(ctx context.Context, endpoint netaddr.Endpoint, key PublicKeyInfo, knownHosts option.KnownHostsList) error
}

HostTrustPort 定义主机密钥信任库(known_hosts / SSHFP)查询、校验与记录出站端口(INV-C5 / INV-E2)。

type HostTrustRequest

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

HostTrustRequest 表示面向 HostTrustPort.VerifyHostKey 的强类型核验请求(INV-E2)。

func NewHostTrustRequest

func NewHostTrustRequest(spec HostTrustRequestSpec) (HostTrustRequest, error)

NewHostTrustRequest 校验端点、远端公钥与校验模式并构造不可变 HostTrustRequest。

func (HostTrustRequest) Endpoint

func (r HostTrustRequest) Endpoint() netaddr.Endpoint

func (HostTrustRequest) IsValid

func (r HostTrustRequest) IsValid() bool

func (HostTrustRequest) IsZero

func (r HostTrustRequest) IsZero() bool

func (HostTrustRequest) KnownHosts

func (r HostTrustRequest) KnownHosts() option.KnownHostsList

func (HostTrustRequest) Mode

func (HostTrustRequest) Presented

func (r HostTrustRequest) Presented() PublicKeyInfo

type HostTrustRequestSpec

type HostTrustRequestSpec struct {
	Endpoint   netaddr.Endpoint
	Presented  PublicKeyInfo
	Mode       option.StrictHostKeyCheckingMode
	KnownHosts option.KnownHostsList
}

HostTrustRequestSpec 是构造不可变 HostTrustRequest 的显式入参规格。

type HostTrustStatus

type HostTrustStatus uint8

HostTrustStatus 表示远端主机密钥核验状态枚举;零值 HostTrustStatusInvalid 恒拒绝。

const (
	HostTrustStatusInvalid HostTrustStatus = HostTrustStatus(pc.HostTrustInvalidCode)  // 无效状态(零值失败关闭)
	HostTrustTrusted       HostTrustStatus = HostTrustStatus(pc.HostTrustTrustedCode)  // 与信任库匹配
	HostTrustUnknown       HostTrustStatus = HostTrustStatus(pc.HostTrustUnknownCode)  // 尚无端点信任记录
	HostTrustMismatch      HostTrustStatus = HostTrustStatus(pc.HostTrustMismatchCode) // 与既有记录冲突(疑似 MITM)
	HostTrustRevoked       HostTrustStatus = HostTrustStatus(pc.HostTrustRevokedCode)  // 已被显式吊销(@revoked)
)

func ParseHostTrustStatus

func ParseHostTrustStatus(s string) (HostTrustStatus, error)

func (HostTrustStatus) AppendText

func (s HostTrustStatus) AppendText(b []byte) ([]byte, error)

func (HostTrustStatus) IsValid

func (s HostTrustStatus) IsValid() bool

func (HostTrustStatus) IsZero

func (s HostTrustStatus) IsZero() bool

func (HostTrustStatus) MarshalText

func (s HostTrustStatus) MarshalText() ([]byte, error)

func (HostTrustStatus) String

func (s HostTrustStatus) String() string

func (*HostTrustStatus) UnmarshalText

func (s *HostTrustStatus) UnmarshalText(t []byte) error

type InteractionPort

type InteractionPort interface {
	CanInteract() bool
	Confirm(ctx context.Context, req ConfirmRequest) (security.Verdict, error)
	PromptApproval(ctx context.Context, envelope security.ApprovalEnvelope) (ApprovalDecisionResponse, error)
	PromptText(ctx context.Context, req TextPromptRequest) (string, error)
	// PromptSecret 以无回显方式采集用户机密输入并在同步闭包内借出 *secret.SecretBox。
	//xops:syncclosure
	//xops:borrowed
	PromptSecret(ctx context.Context, req SecretPromptRequest, fn func(box *secret.SecretBox) error) error
}

InteractionPort 定义人工确认、审批挑战、非敏感文本与全作用域闭包机密输入出站端口。 CanInteract() 严格仅代表存在真实控制 TTY(供 gate 审批、PromptApproval、Vault 解锁与 ControlMaster 确认使用)。

type InventorySnapshot

type InventorySnapshot = portval.InventorySnapshot

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewInventorySnapshot

func NewInventorySnapshot(revision Revision, graph inventory.Graph) (InventorySnapshot, error)

type InventoryStore

type InventoryStore interface {
	Load(ctx context.Context) (InventorySnapshot, error)
	CommitCAS(ctx context.Context, expected Revision, next inventory.Graph) (DurabilityOutcome, error)
}

InventoryStore 定义本地资产配置的原子加载与 CAS 持久化出站端口(INV-F1 / INV-F3)。

type JournalGenerationSnapshot

type JournalGenerationSnapshot = portval.JournalGenerationSnapshot

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewCorruptJournalGenerationSnapshot

func NewCorruptJournalGenerationSnapshot(generation uint64, cause error, partialPrefix ...fsm.TransferJournalRecord) (JournalGenerationSnapshot, error)

func NewJournalGenerationSnapshot

func NewJournalGenerationSnapshot(generation uint64, records []fsm.TransferJournalRecord) (JournalGenerationSnapshot, error)

type JournalStore

type JournalStore interface {
	Append(ctx context.Context, record fsm.TransferJournalRecord) error
	Load(ctx context.Context, transferID security.OperationID) ([]fsm.TransferJournalRecord, error)
	LoadGenerations(ctx context.Context, transferID security.OperationID) ([]JournalGenerationSnapshot, error)
	PruneGeneration(ctx context.Context, transferID security.OperationID, generation uint64) error
	ListActive(ctx context.Context) ([]security.OperationID, error)
	Delete(ctx context.Context, transferID security.OperationID) error
}

JournalStore 定义可恢复分片文件传输(最高 10 GiB)双代(active/staging)WAL/Journal 持久化出站端口(P3-T3 <-> P4-T3)。

  • Append 按 (TransferID, Generation) 分代追加;
  • Load 按 (Generation 升序, Seq 升序) 确定性返回全部保留记录,任一代损坏则返回 ErrCorruptData;
  • LoadGenerations 按 Generation 升序返回逐代隔离快照(损坏代 Corrupt()==true/Records()==nil,经 PartialRecords() 保留损坏前有效前缀);严禁盲目丢弃损坏高世代回退低世代(前缀含 CommitStarted/Committed 须停于 TransferUncertainCommit,高世代空前缀须失败关闭);
  • PruneGeneration 仅移除指定 (transferID, generation),若无剩余世代则 transferID 移出 ListActive。

type KeySignerPort

type KeySignerPort interface {
	ListPublicKeys(ctx context.Context, auth inventory.AuthMethod) ([]PublicKeyInfo, error)
	Sign(ctx context.Context, key inventory.KeyFingerprint, algorithm string, data []byte) (Signature, error)
	InspectPrivateKeyFingerprint(ctx context.Context, keyPath inventory.KeyPathSpec, passphrase algebraic.Option[secret.Ref]) (inventory.KeyFingerprint, error)
}

KeySignerPort 定义私钥解析、指纹核验与公钥签名出站端口。

type LocalDirEntry

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

LocalDirEntry 表示沙箱目录枚举返回的单个已校验目录项;零值恒无效。

func NewLocalDirEntry

func NewLocalDirEntry(name string, mode fs.FileMode, size int64) (LocalDirEntry, error)

NewLocalDirEntry 校验目录项名称分量与非负大小并构造不可变 LocalDirEntry。

func (LocalDirEntry) Equal

func (e LocalDirEntry) Equal(o LocalDirEntry) bool

func (LocalDirEntry) IsDir

func (e LocalDirEntry) IsDir() bool

func (LocalDirEntry) IsRegular

func (e LocalDirEntry) IsRegular() bool
func (e LocalDirEntry) IsSymlink() bool

func (LocalDirEntry) IsValid

func (e LocalDirEntry) IsValid() bool

func (LocalDirEntry) IsZero

func (e LocalDirEntry) IsZero() bool

func (LocalDirEntry) Mode

func (e LocalDirEntry) Mode() fs.FileMode

func (LocalDirEntry) Name

func (e LocalDirEntry) Name() string

func (LocalDirEntry) Size

func (e LocalDirEntry) Size() int64

type LocalFileInfo

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

LocalFileInfo 表示沙箱内单个本地对象的只读元信息快照;零值恒无效。

func NewLocalFileInfo

func NewLocalFileInfo(spec LocalFileInfoSpec) (LocalFileInfo, error)

NewLocalFileInfo 校验名称分量、非负大小与合法时间戳并构造不可变 LocalFileInfo。

func (LocalFileInfo) Equal

func (i LocalFileInfo) Equal(o LocalFileInfo) bool

func (LocalFileInfo) IsDir

func (i LocalFileInfo) IsDir() bool

func (LocalFileInfo) IsRegular

func (i LocalFileInfo) IsRegular() bool
func (i LocalFileInfo) IsSymlink() bool

func (LocalFileInfo) IsValid

func (i LocalFileInfo) IsValid() bool

func (LocalFileInfo) IsZero

func (i LocalFileInfo) IsZero() bool

func (LocalFileInfo) ModTime

func (i LocalFileInfo) ModTime() time.Time

func (LocalFileInfo) Mode

func (i LocalFileInfo) Mode() fs.FileMode

func (LocalFileInfo) Name

func (i LocalFileInfo) Name() string

func (LocalFileInfo) Perm

func (i LocalFileInfo) Perm() fs.FileMode

func (LocalFileInfo) Size

func (i LocalFileInfo) Size() int64

type LocalFileInfoSpec

type LocalFileInfoSpec struct {
	Name    string
	Size    int64
	Mode    fs.FileMode
	ModTime time.Time
}

LocalFileInfoSpec 是构造不可变 LocalFileInfo 的显式入参规格。

type LocalIdentityInfo

type LocalIdentityInfo = portval.LocalIdentityInfo

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewLocalIdentityInfo

func NewLocalIdentityInfo(spec LocalIdentityInfoSpec) (LocalIdentityInfo, error)

系统身份、子进程与终端尺寸值对象构造薄转发函数。

type LocalIdentityInfoSpec

type LocalIdentityInfoSpec = portval.LocalIdentityInfoSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type LockMode

type LockMode uint8

LockMode 定义句柄级本地文件锁的加锁模式(INV-A5);零值 LockModeInvalid 严格失败关闭。

const (
	LockModeInvalid LockMode = LockMode(pc.LockModeInvalidCode) // 无效锁模式(零值失败关闭)
	LockShared      LockMode = LockMode(pc.LockSharedCode)      // 共享读锁
	LockExclusive   LockMode = LockMode(pc.LockExclusiveCode)   // 独占写锁
)

func ParseLockMode

func ParseLockMode(s string) (LockMode, error)

全部 12 个失败关闭端口枚举的 Parse / IsValid / IsZero / String 与 TextCodec 统一实现。

func (LockMode) AppendText

func (m LockMode) AppendText(b []byte) ([]byte, error)

func (LockMode) IsValid

func (m LockMode) IsValid() bool

func (LockMode) IsZero

func (m LockMode) IsZero() bool

func (LockMode) MarshalText

func (m LockMode) MarshalText() ([]byte, error)

func (LockMode) String

func (m LockMode) String() string

func (*LockMode) UnmarshalText

func (m *LockMode) UnmarshalText(t []byte) error

type LockedFile

type LockedFile interface {
	io.Reader
	io.Writer
	io.Seeker
	// Truncate 截断持锁文件至指定长度;注意 Truncate(0) 不重置内核偏移,后续写入前须 Seek(0, io.SeekStart)。
	Truncate(size int64) error
	Sync() error
	Stat() (LocalFileInfo, error)
}

LockedFile 是 RootHandle.WithLockedFile / TryWithLockedFile 在同步回调内借出的持锁文件句柄。

type MuxConnInfo added in v1.3.0

type MuxConnInfo = portval.MuxConnInfo

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewMuxConnInfo added in v1.3.0

func NewMuxConnInfo(spec MuxConnInfoSpec) (MuxConnInfo, error)

多路复用主连接元信息与活跃转发/通道快照值对象构造薄转发函数。

func QueryMuxConnInfo added in v1.3.0

func QueryMuxConnInfo(ctx context.Context, mux MuxSocketPort, socketPath pathalg.LocalSourcePath) (MuxConnInfo, error)

QueryMuxConnInfo 委托 MuxInspectPort.QueryConnInfo;nil ctx 返回 ErrNilContext,nil mux 返回 ErrInvalidArgument, 未实现 MuxInspectPort 的适配器显式返回 ErrUnsupported。

type MuxConnInfoSpec added in v1.3.0

type MuxConnInfoSpec = portval.MuxConnInfoSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type MuxControlAction

type MuxControlAction uint8

MuxControlAction 标识 OpenSSH PROTOCOL.mux v4 控制面动作;零值 MuxActionInvalid 严格失败关闭。

const (
	MuxActionInvalid  MuxControlAction = MuxControlAction(pc.MuxActionInvalidCode)  // 无效控制动作(零值失败关闭)
	MuxActionCheck    MuxControlAction = MuxControlAction(pc.MuxActionCheckCode)    // 探测存活并查询 PID
	MuxActionForward  MuxControlAction = MuxControlAction(pc.MuxActionForwardCode)  // 开启端口转发
	MuxActionCancel   MuxControlAction = MuxControlAction(pc.MuxActionCancelCode)   // 取消端口转发
	MuxActionExit     MuxControlAction = MuxControlAction(pc.MuxActionExitCode)     // 优雅退出
	MuxActionStop     MuxControlAction = MuxControlAction(pc.MuxActionStopCode)     // 立即停止
	MuxActionProxy    MuxControlAction = MuxControlAction(pc.MuxActionProxyCode)    // 代理透传模式
	MuxActionConnInfo MuxControlAction = MuxControlAction(pc.MuxActionConnInfoCode) // 查询主连接只读元信息(-O conninfo)
	MuxActionChannels MuxControlAction = MuxControlAction(pc.MuxActionChannelsCode) // 查询活跃会话与转发快照(-O channels)
)

func ParseMuxControlAction

func ParseMuxControlAction(s string) (MuxControlAction, error)

func (MuxControlAction) AppendText

func (a MuxControlAction) AppendText(b []byte) ([]byte, error)

func (MuxControlAction) IsValid

func (a MuxControlAction) IsValid() bool

func (MuxControlAction) IsZero

func (a MuxControlAction) IsZero() bool

func (MuxControlAction) MarshalText

func (a MuxControlAction) MarshalText() ([]byte, error)

func (MuxControlAction) String

func (a MuxControlAction) String() string

func (*MuxControlAction) UnmarshalText

func (a *MuxControlAction) UnmarshalText(t []byte) error

type MuxControlRequest

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

MuxControlRequest 描述面向 MuxSocketPort.Control 的多路复用控制面请求;零值恒无效。

func NewMuxControlRequest

func NewMuxControlRequest(action MuxControlAction, socketPath pathalg.LocalSourcePath, forward algebraic.Option[ForwardSpec]) (MuxControlRequest, error)

NewMuxControlRequest 校验控制动作、套接字路径与可选转发规格(forward/cancel 必填)并构造请求。

func (MuxControlRequest) Action

func (MuxControlRequest) Forward

func (MuxControlRequest) IsValid

func (r MuxControlRequest) IsValid() bool

func (MuxControlRequest) IsZero

func (r MuxControlRequest) IsZero() bool

func (MuxControlRequest) SocketPath

func (r MuxControlRequest) SocketPath() pathalg.LocalSourcePath

type MuxControlResponse

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

MuxControlResponse 描述多路复用探测或控制动作的不可变结果;零值恒无效。

func NewMuxControlResponse

func NewMuxControlResponse(alive bool, masterPID uint32, detail string) (MuxControlResponse, error)

NewMuxControlResponse 校验主进程状态与诊断说明并构造不可变 MuxControlResponse。

func (MuxControlResponse) Alive

func (r MuxControlResponse) Alive() bool

func (MuxControlResponse) Detail

func (r MuxControlResponse) Detail() string

func (MuxControlResponse) Equal

func (MuxControlResponse) IsValid

func (r MuxControlResponse) IsValid() bool

func (MuxControlResponse) IsZero

func (r MuxControlResponse) IsZero() bool

func (MuxControlResponse) MarshalJSONTo

func (r MuxControlResponse) MarshalJSONTo(e jEnc) error

func (MuxControlResponse) MasterPID

func (r MuxControlResponse) MasterPID() uint32

func (*MuxControlResponse) UnmarshalJSONFrom

func (r *MuxControlResponse) UnmarshalJSONFrom(c jDec) error

type MuxInspectPort added in v1.3.0

type MuxInspectPort interface {
	QueryConnInfo(ctx context.Context, socketPath pathalg.LocalSourcePath) (MuxConnInfo, error)
	QueryChannels(ctx context.Context, socketPath pathalg.LocalSourcePath) (ActiveChannelSnapshot, error)
}

MuxInspectPort 是 MuxSocketPort 的具名可选只读查询扩展接口(ADR-019 D2), 为 -O conninfo / -O channels(及 xops mux info / channels)返回强类型不可变快照; 不支持扩展协议的旧版或原生 OpenSSH ControlMaster 须显式返回 ErrUnsupported。

type MuxServeOptions added in v1.3.0

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

MuxServeOptions 封装单个 ControlMaster 监听实例的不可变运行时策略、目标身份、-O conninfo 元数据 与动态转发绑定上限;零值恒无效(fail-closed)。

func DefaultMuxServeOptions added in v1.3.0

func DefaultMuxServeOptions() MuxServeOptions

DefaultMuxServeOptions 返回最严合法默认单实例服务选项(ForwardAgentEnabled=false、HopCount=1、有效态)。

func NewMuxServeOptions added in v1.3.0

func NewMuxServeOptions(spec MuxServeOptionsSpec) (MuxServeOptions, error)

NewMuxServeOptions 校验全部字段不变量(HopCount 0 归一为 1、禁用 ForwardAgent 时禁设 ForwardAgentBound、 可选 PlanDigest/User/Persist/ForwardBindOptions 均合法)并构造不可变 MuxServeOptions。

func (MuxServeOptions) DisallowNativeMux added in v1.3.0

func (o MuxServeOptions) DisallowNativeMux() bool

func (MuxServeOptions) Endpoint added in v1.3.0

func (o MuxServeOptions) Endpoint() netaddr.Endpoint

func (MuxServeOptions) Equal added in v1.3.0

func (o MuxServeOptions) Equal(other MuxServeOptions) bool

func (MuxServeOptions) ForwardAgentBound added in v1.3.0

func (o MuxServeOptions) ForwardAgentBound() algebraic.Option[inventory.AgentSpec]

func (MuxServeOptions) ForwardAgentEnabled added in v1.3.0

func (o MuxServeOptions) ForwardAgentEnabled() bool

func (MuxServeOptions) ForwardBindOptions added in v1.3.0

func (o MuxServeOptions) ForwardBindOptions() algebraic.Option[ForwardBindOptions]

func (MuxServeOptions) HopCount added in v1.3.0

func (o MuxServeOptions) HopCount() uint32

func (MuxServeOptions) IsValid added in v1.3.0

func (o MuxServeOptions) IsValid() bool

func (MuxServeOptions) IsZero added in v1.3.0

func (o MuxServeOptions) IsZero() bool

func (MuxServeOptions) NodeID added in v1.3.0

func (o MuxServeOptions) NodeID() string

func (MuxServeOptions) Persist added in v1.3.0

func (MuxServeOptions) PlanDigest added in v1.3.0

func (MuxServeOptions) User added in v1.3.0

type MuxServeOptionsPort added in v1.3.0

type MuxServeOptionsPort interface {
	ServeWithOptions(ctx context.Context, ln net.Listener, upstream TransportConn, forwarder ForwarderPort, opts MuxServeOptions) error
}

MuxServeOptionsPort 是 MuxSocketPort 的具名可选单实例服务策略扩展接口(ADR-019 v2.2 S3-Q1), 允许调用方为每次 ControlMaster 监听绑定独立的目标身份(NodeID/Endpoint/PlanDigest)、-O conninfo 元数据、 ForwardAgent 策略、原生入站开关与 ForwardBindOptions 上限;具体实现须在 ln 上标注参数级 //xops:borrowed 确保零逃逸。

type MuxServeOptionsSpec added in v1.3.0

type MuxServeOptionsSpec struct {
	NodeID              string
	Endpoint            netaddr.Endpoint
	PlanDigest          algebraic.Option[plan.PlanDigest]
	User                algebraic.Option[option.Username]
	HopCount            uint32
	Persist             option.ControlPersistSpec
	ForwardAgentEnabled bool
	ForwardAgentBound   algebraic.Option[inventory.AgentSpec]
	DisallowNativeMux   bool
	ForwardBindOptions  algebraic.Option[ForwardBindOptions]
}

MuxServeOptionsSpec 是构造不可变 MuxServeOptions 的显式入参规格(ADR-019 v2.2 S3-Q1)。 全部可选维度保持零值安全默认:HopCount 为 0 时归一为 1;ForwardAgentEnabled 默认 false; DisallowNativeMux 默认 false;ForwardBindOptions 为 None 时继承适配器最严默认策略。

type MuxSocketPort

type MuxSocketPort interface {
	Probe(ctx context.Context, socketPath pathalg.LocalSourcePath) (MuxControlResponse, error)
	Control(ctx context.Context, req MuxControlRequest) (MuxControlResponse, error)
	// DialMux 连接至活跃 ControlMaster 并返回绑定精确 (hopDigest, endpoint) 身份的 TransportConn。
	DialMux(ctx context.Context, socketPath pathalg.LocalSourcePath, hopDigest plan.HopDigest, endpoint netaddr.Endpoint) (TransportConn, error)
	// OpenProxy 以 PROTOCOL.mux v4 `-O proxy`(MuxActionProxy)模式打开与 ControlMaster 的双向 stdio 透传流。
	OpenProxy(ctx context.Context, socketPath pathalg.LocalSourcePath) (net.Conn, error)
	// Serve 在 ln 上以 PROTOCOL.mux v4 服务端模式响应会话、转发、探活、退出与代理请求(upstream 为非借用池钉选连接,forwarder 可选;具体实现如 P4-T2 sshnet/mux 须在 ln 参数上标注参数级 //xops:borrowed 确保零逃逸)。
	Serve(ctx context.Context, ln net.Listener, upstream TransportConn, forwarder ForwarderPort) error
	// WithListener 在独占目录锁下绑定 AF_UNIX 套接字(Accept 校验对端凭证),退出时按锁->SameFile->unlink->close->解锁释放。
	//xops:syncclosure
	//xops:borrowed
	WithListener(ctx context.Context, socketPath pathalg.LocalSourcePath, fn func(ln net.Listener) error) error
}

MuxSocketPort 定义本地 ControlMaster/ControlPersist AF_UNIX 套接字探测、控制、服务端与代理出站端口(INV-A3 / INV-C4)。

type NativeTTYFDProvider added in v1.3.0

type NativeTTYFDProvider interface {
	// WithNativeTTYFiles 在同步作用域内借出真实控制终端的文件句柄:stdin 与 stdout 恒非 nil;
	// 当宿主终端仅持有 (stdin, stdout) 两句柄(如 NewFileTerminal)或进程 stderr 已重定向至非 TTY 时,
	// stderr 允许为 nil,调用方须显式检查 stderr == nil 并回退至 stdout 或受控空设备(core/osfs.OpenNullDevice)。
	// 不支持或非交互终端须失败关闭返回 ErrUnsupported,绝不向回调传入 nil 的 stdin 或 stdout。
	//xops:syncclosure
	//xops:borrowed
	WithNativeTTYFiles(ctx context.Context, fn func(stdin, stdout, stderr *NativeTTYFile) error) error
}

NativeTTYFDProvider 是 TerminalPort / TerminalHandle 的具名可选扩展接口(ADR-019 D3), 供 Unix 原生 OpenSSH PROTOCOL.mux v4 出站 PTY 会话在同步闭包内借用真实控制 TTY(stdin/stdout/可选 stderr), 经 core/osfs.SendUnixFD 传递 SCM_RIGHTS;严禁借用句柄逃逸闭包或在回调内关闭,非真实 TTY 实现须返回 ErrUnsupported。

type NativeTTYFile added in v1.3.0

type NativeTTYFile = os.File

NativeTTYFile 是 *os.File 对应宿主真实控制终端文件对象的精确别名, 供 NativeTTYFDProvider 在同步闭包内借出真实控制 TTY 句柄并直传 core/osfs.{SendUnixFD,TerminalSizeOfFD}。

type OpenSSHConfigSource

type OpenSSHConfigSource interface {
	ListVirtualHosts(ctx context.Context) ([]OpenSSHVirtualHost, error)
	// ResolveTier4 针对显式原始主机 target 与可选规范化端点 endpoint 折叠返回单一 t4 OptionLayer;
	// endpoint 为 None 时支撑非 DNS 或通配符别名的初始展开,为 Some 时必须携带有效 Endpoint。
	ResolveTier4(ctx context.Context, target option.OriginalHostSpec, endpoint algebraic.Option[netaddr.Endpoint]) (option.OptionLayer, error)
}

OpenSSHConfigSource 定义只读 ~/.ssh/config(含递归 Include)虚拟节点源与 Tier-4 选项折叠端口(ADR-004)。

type OpenSSHVirtualHost

type OpenSSHVirtualHost = portval.OpenSSHVirtualHost

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewOpenSSHVirtualHost

func NewOpenSSHVirtualHost(spec OpenSSHVirtualHostSpec) (OpenSSHVirtualHost, error)

type OpenSSHVirtualHostSpec

type OpenSSHVirtualHostSpec = portval.OpenSSHVirtualHostSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type OperatorReadFS

type OperatorReadFS interface {
	// WithOperatorRead 按 policy 管控软链打开只读源文件并在同步闭包内借出随机只读句柄与大小。
	//xops:syncclosure
	//xops:borrowed
	WithOperatorRead(ctx context.Context, path pathalg.LocalSourcePath, policy pathalg.SymlinkPolicy, fn func(r BoundedReadHandle, size int64) error) error
}

OperatorReadFS 定义面向 CLI/Playbook 的人工显式只读源端口(ADR-007);xopsvet/archbound 物理封禁 mcpruntime 引用。

type PTYRequest

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

PTYRequest 描述远端伪终端分配请求(终端类型与窗口尺寸);零值恒无效。

func NewPTYRequest

func NewPTYRequest(term string, size TerminalSize) (PTYRequest, error)

NewPTYRequest 校验终端类型名称与窗口尺寸并构造不可变 PTYRequest。

func (PTYRequest) Equal

func (p PTYRequest) Equal(o PTYRequest) bool

func (PTYRequest) IsValid

func (p PTYRequest) IsValid() bool

func (PTYRequest) IsZero

func (p PTYRequest) IsZero() bool

func (PTYRequest) MarshalJSONTo

func (p PTYRequest) MarshalJSONTo(e jEnc) error

func (PTYRequest) Size

func (p PTYRequest) Size() TerminalSize

func (PTYRequest) Term

func (p PTYRequest) Term() string

func (*PTYRequest) UnmarshalJSONFrom

func (p *PTYRequest) UnmarshalJSONFrom(c jDec) error

type PrivateFileReader added in v1.3.0

type PrivateFileReader interface {
	// ReadVerifiedPrivateFile 以句柄级权限校验读取沙箱内常规私密文件并在同步闭包内借出 *secret.SecretBox;
	// 严格拒绝符号链接/重解析点、非常规文件、宽权限/非当前用户所有(Unix fstat uid==euid 且 mode&0o077==0;
	// Windows 同一句柄 GetSecurityInfo Owner-Only DACL)及超限体积,退出(含 panic)前无条件清零所有中间缓冲。
	//xops:syncclosure
	//xops:borrowed
	ReadVerifiedPrivateFile(dest pathalg.LocalRootedDest, limits ReadLimits, fn func(box *secret.SecretBox) error) error
}

PrivateFileReader 定义句柄级原子私密文件校验读取的可选窄接口(ADR-018): 由具备宿主权限/DACL 核验能力的 RootHandle 实现(如 core/osfs 与 core/internal/sim), 既支持零 TOCTOU 读取私密文件至借用 *secret.SecretBox,又保持既有最小化 RootHandle 故障桩零破坏。

type PrivilegeEscalationPort

type PrivilegeEscalationPort interface {
	// RunPrivileged 通过 opener 打开远端会话并按 req 执行提权命令,流向 streams 并返回封闭 ExecutionOutcome。
	RunPrivileged(ctx context.Context, opener SessionOpener, req PrivilegeRequest, password *secret.SecretBox, streams ExecStreams) (execution.ExecutionOutcome, error)
}

PrivilegeEscalationPort 定义远端提权执行(sudo/su/doas)出站端口(P3-T2 <-> P4-T1 sshnet/priv)。 仅 sshnet/priv 与 sim 列入明文消费白名单;RunPrivileged 无回调参数,password 由 secretbox Rule 1 与具体实现上的参数级 //xops:borrowed 共同强制零逃逸(严禁跨调用留存 opener 或 password)。

type PrivilegeMethod

type PrivilegeMethod uint8

PrivilegeMethod 标识远端提权执行协议类别(sudo/su/doas);零值 PrivilegeMethodInvalid 失败关闭。

const (
	PrivilegeMethodInvalid PrivilegeMethod = PrivilegeMethod(pc.PrivilegeMethodInvalidCode) // 无效提权方式(零值失败关闭)
	PrivilegeMethodSudo    PrivilegeMethod = PrivilegeMethod(pc.PrivilegeMethodSudoCode)    // POSIX sudo 提权
	PrivilegeMethodSu      PrivilegeMethod = PrivilegeMethod(pc.PrivilegeMethodSuCode)      // POSIX su 提权
	PrivilegeMethodDoas    PrivilegeMethod = PrivilegeMethod(pc.PrivilegeMethodDoasCode)    // OpenBSD/Linux doas 提权
)

func ParsePrivilegeMethod

func ParsePrivilegeMethod(s string) (PrivilegeMethod, error)

func (PrivilegeMethod) AppendText

func (m PrivilegeMethod) AppendText(b []byte) ([]byte, error)

func (PrivilegeMethod) IsValid

func (m PrivilegeMethod) IsValid() bool

func (PrivilegeMethod) IsZero

func (m PrivilegeMethod) IsZero() bool

func (PrivilegeMethod) MarshalText

func (m PrivilegeMethod) MarshalText() ([]byte, error)

func (PrivilegeMethod) String

func (m PrivilegeMethod) String() string

func (*PrivilegeMethod) UnmarshalText

func (m *PrivilegeMethod) UnmarshalText(t []byte) error

type PrivilegeRequest

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

PrivilegeRequest 描述不含明文凭据的不可变远端提权请求;零值恒无效。 提权口令须作为独立借用参数 *secret.SecretBox 经 PrivilegeEscalationPort.RunPrivileged 传入。

func NewPrivilegeRequest

func NewPrivilegeRequest(spec PrivilegeRequestSpec) (PrivilegeRequest, error)

NewPrivilegeRequest 校验提权方式、命令计划、可选目标用户、可选正时长超时及仅限 su/doas 的可选 RE2 提示正则并构造不可变 PrivilegeRequest。

func (PrivilegeRequest) Command

func (PrivilegeRequest) Equal

func (PrivilegeRequest) IsValid

func (r PrivilegeRequest) IsValid() bool

func (PrivilegeRequest) IsZero

func (r PrivilegeRequest) IsZero() bool

func (PrivilegeRequest) MarshalJSONTo

func (r PrivilegeRequest) MarshalJSONTo(e jEnc) error

func (PrivilegeRequest) Method

func (r PrivilegeRequest) Method() PrivilegeMethod

func (PrivilegeRequest) NonInteractive

func (r PrivilegeRequest) NonInteractive() bool

func (PrivilegeRequest) PromptPattern added in v1.3.0

func (r PrivilegeRequest) PromptPattern() algebraic.Option[string]

func (PrivilegeRequest) TargetUser

func (PrivilegeRequest) Timeout

func (*PrivilegeRequest) UnmarshalJSONFrom

func (r *PrivilegeRequest) UnmarshalJSONFrom(c jDec) error

type PrivilegeRequestSpec

type PrivilegeRequestSpec struct {
	Method         PrivilegeMethod                      `json:"method"`
	Command        execution.CommandPlan                `json:"command"`
	TargetUser     algebraic.Option[option.Username]    `json:"target_user,omitzero"`
	NonInteractive bool                                 `json:"non_interactive,omitzero"`
	Timeout        algebraic.Option[algebraic.Duration] `json:"timeout,omitzero"`
	PromptPattern  algebraic.Option[string]             `json:"prompt_pattern,omitzero"`
}

PrivilegeRequestSpec 是构造不可变 PrivilegeRequest 的显式入参规格(严禁携带 SecretBox)。

type ProcessInstanceID

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

ProcessInstanceID 唯一标识单个运行期 Engine 实例,映射 ~/.xops/run/<ProcessInstanceID>.lock(ADR-008)。

func NewProcessInstanceIDFrom

func NewProcessInstanceIDFrom(entropy io.Reader) (ProcessInstanceID, error)

NewProcessInstanceIDFrom 从显式熵源读取 16 字节非全零随机数据并生成 32 位小写十六进制 ProcessInstanceID。

func ParseProcessInstanceID

func ParseProcessInstanceID(raw string) (ProcessInstanceID, error)

ParseProcessInstanceID 校验并构造 ProcessInstanceID(1..64 位安全 ASCII 标识符,满足跨平台单文件名规则)。

func (ProcessInstanceID) AppendText

func (id ProcessInstanceID) AppendText(b []byte) ([]byte, error)

func (ProcessInstanceID) Compare

func (id ProcessInstanceID) Compare(o ProcessInstanceID) int

func (ProcessInstanceID) Equal

func (ProcessInstanceID) IsValid

func (id ProcessInstanceID) IsValid() bool

func (ProcessInstanceID) IsZero

func (id ProcessInstanceID) IsZero() bool

func (ProcessInstanceID) LockFileName

func (id ProcessInstanceID) LockFileName() (pathalg.LocalRootedDest, error)

func (ProcessInstanceID) MarshalText

func (id ProcessInstanceID) MarshalText() ([]byte, error)

func (ProcessInstanceID) String

func (id ProcessInstanceID) String() string

func (*ProcessInstanceID) UnmarshalText

func (id *ProcessInstanceID) UnmarshalText(t []byte) error

type ProcessPort

type ProcessPort interface {
	Run(ctx context.Context, spec ProcessSpec, stdin io.Reader) (ProcessResult, error)
	DialStdio(ctx context.Context, spec ProcessSpec) (net.Conn, error)
}

ProcessPort 定义本机外部进程执行与 stdio 管道连接出站端口(仅由 internal/host/sys 或 sim 实现)。

type ProcessResult

type ProcessResult = portval.ProcessResult

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewProcessResult

func NewProcessResult(spec ProcessResultSpec) (ProcessResult, error)

type ProcessResultSpec

type ProcessResultSpec = portval.ProcessResultSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type ProcessSpec

type ProcessSpec = portval.ProcessSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewProcessSpec

func NewProcessSpec(in ProcessSpecInput) (ProcessSpec, error)

type ProcessSpecInput

type ProcessSpecInput = portval.ProcessSpecInput

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type PublicKeyInfo

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

PublicKeyInfo 表示协议库无关的不可变 SSH 公钥元数据;零值恒无效。

func NewPublicKeyInfo

func NewPublicKeyInfo(spec PublicKeyInfoSpec) (PublicKeyInfo, error)

NewPublicKeyInfo 校验算法名、指纹与非空公钥线缆载荷并构造不可变 PublicKeyInfo。

func (PublicKeyInfo) Algorithm

func (k PublicKeyInfo) Algorithm() string

func (PublicKeyInfo) Comment

func (k PublicKeyInfo) Comment() string

func (PublicKeyInfo) Equal

func (k PublicKeyInfo) Equal(o PublicKeyInfo) bool

func (PublicKeyInfo) Fingerprint

func (k PublicKeyInfo) Fingerprint() inventory.KeyFingerprint

func (PublicKeyInfo) IsValid

func (k PublicKeyInfo) IsValid() bool

func (PublicKeyInfo) IsZero

func (k PublicKeyInfo) IsZero() bool

func (PublicKeyInfo) MarshalJSONTo

func (k PublicKeyInfo) MarshalJSONTo(e jEnc) error

func (*PublicKeyInfo) UnmarshalJSONFrom

func (k *PublicKeyInfo) UnmarshalJSONFrom(c jDec) error

func (PublicKeyInfo) WireBlob

func (k PublicKeyInfo) WireBlob() []byte

type PublicKeyInfoSpec

type PublicKeyInfoSpec struct {
	Algorithm   string
	Fingerprint inventory.KeyFingerprint
	WireBlob    []byte
	Comment     string
}

PublicKeyInfoSpec 是构造不可变 PublicKeyInfo 的显式入参规格。

type ReadLimits

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

ReadLimits 定义有界文件读取的字节上限值对象(INV-A5);零值严格失败关闭。

func NewReadLimits

func NewReadLimits(maxBytes int64) (ReadLimits, error)

NewReadLimits 校验上限严格为正整数后构造不可变 ReadLimits。

func (ReadLimits) Equal

func (l ReadLimits) Equal(o ReadLimits) bool

func (ReadLimits) IsValid

func (l ReadLimits) IsValid() bool

func (ReadLimits) IsZero

func (l ReadLimits) IsZero() bool

func (ReadLimits) MarshalJSONTo

func (l ReadLimits) MarshalJSONTo(e jEnc) error

MarshalJSONTo 与 UnmarshalJSONFrom 实现本包保留不可变值对象的严格 json/v2 编解码(portval 值对象编解码归属 portval)。

func (ReadLimits) MaxBytes

func (l ReadLimits) MaxBytes() int64

func (*ReadLimits) UnmarshalJSONFrom

func (l *ReadLimits) UnmarshalJSONFrom(c jDec) error

type RemoteDirEntry

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

RemoteDirEntry 表示经 pathalg.RemoteName 校验的远端目录项(INV-B1);零值恒无效。

func NewRemoteDirEntry

func NewRemoteDirEntry(spec RemoteDirEntrySpec) (RemoteDirEntry, error)

NewRemoteDirEntry 校验远端目录项名、文件类型、非负大小与时间戳并构造不可变 RemoteDirEntry。

func (RemoteDirEntry) Equal

func (e RemoteDirEntry) Equal(o RemoteDirEntry) bool

func (RemoteDirEntry) FileType

func (e RemoteDirEntry) FileType() RemoteFileType

func (RemoteDirEntry) IsValid

func (e RemoteDirEntry) IsValid() bool

func (RemoteDirEntry) IsZero

func (e RemoteDirEntry) IsZero() bool

func (RemoteDirEntry) MarshalJSONTo

func (e RemoteDirEntry) MarshalJSONTo(x jEnc) error

func (RemoteDirEntry) ModTime

func (e RemoteDirEntry) ModTime() time.Time

func (RemoteDirEntry) Mode

func (e RemoteDirEntry) Mode() fs.FileMode

func (RemoteDirEntry) Name

func (RemoteDirEntry) Perm

func (e RemoteDirEntry) Perm() fs.FileMode

func (RemoteDirEntry) Size

func (e RemoteDirEntry) Size() int64

func (*RemoteDirEntry) UnmarshalJSONFrom

func (e *RemoteDirEntry) UnmarshalJSONFrom(c jDec) error

type RemoteDirEntrySpec

type RemoteDirEntrySpec struct {
	Name     pathalg.RemoteName
	FileType RemoteFileType
	Size     int64
	Mode     fs.FileMode
	ModTime  time.Time
}

RemoteDirEntrySpec 是构造不可变 RemoteDirEntry 的显式入参规格。

type RemoteFSPort

type RemoteFSPort interface {
	RealPath(ctx context.Context, p pathalg.RemotePath) (pathalg.RemotePath, error)
	Stat(ctx context.Context, p pathalg.RemotePath) (RemoteFileStat, error)
	Lstat(ctx context.Context, p pathalg.RemotePath) (RemoteFileStat, error)
	ReadLink(ctx context.Context, p pathalg.RemotePath) (string, error)
	ReadDir(ctx context.Context, dir pathalg.RemotePath) ([]RemoteDirEntry, error)
	// WithReadFile 在 limits 字节上限内打开远端常规文件并在同步闭包内借出只读流与文件大小。
	//xops:syncclosure
	//xops:borrowed
	WithReadFile(ctx context.Context, p pathalg.RemotePath, limits ReadLimits, fn func(r io.Reader, size int64) error) error
	// ReadChunk 从远端常规文件 p 的 offset 处读取至多 length 字节写入 dst;读满返回 (length, nil),遇 EOF 返回 (实际字节数, io.EOF)。
	ReadChunk(ctx context.Context, p pathalg.RemotePath, offset int64, dst io.Writer, length int64) (int64, error)
	WriteFileAtomic(ctx context.Context, p pathalg.RemotePath, spec RemoteWriteSpec, r io.Reader) (RemoteFileStat, error)
	WriteChunk(ctx context.Context, p pathalg.RemotePath, offset int64, r io.Reader, length int64) error
	// RenameAtomic 按已校验 RemoteRenameSpec(支持互斥 NoClobber / ExpectedAnchor)执行远端原子重命名。
	RenameAtomic(ctx context.Context, oldPath, newPath pathalg.RemotePath, spec RemoteRenameSpec) error
	// Chmod 修改远端对象标准权限位(0o001..0o777,拒绝零值及特殊权限位,支撑 scp -p 与 sftpshell)。
	Chmod(ctx context.Context, p pathalg.RemotePath, perm fs.FileMode) error
	// Chtimes 修改远端对象访问与修改时间(拒绝零值及超出 RFC 3339 年份 [1,9999] 的时间戳,支撑 scp -p 时间戳保留)。
	Chtimes(ctx context.Context, p pathalg.RemotePath, atime, mtime time.Time) error
	MkdirAll(ctx context.Context, dir pathalg.RemotePath, perm fs.FileMode) error
	// Remove 仅删除常规文件或符号链接(SFTP SSH_FXP_REMOVE);若目标为目录须返回 ErrRemoteIsDir。
	Remove(ctx context.Context, p pathalg.RemotePath) error
	// RemoveDir 仅删除空目录(SFTP SSH_FXP_RMDIR);非目录或非空目录须返回 ErrInvalidArgument,不存在返回 ErrNotFound。
	RemoveDir(ctx context.Context, dir pathalg.RemotePath) error
	Close() error
}

RemoteFSPort 定义协议库无关的远端 SFTP v3 安全文件访问出站端口(ADR-008 / ADR-016,严禁裸客户端逃生口)。

type RemoteFileAnchor

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

RemoteFileAnchor 表示 SFTP 写路径纵深防御所需的 SSH_FXP_FSTAT 类型与可选 (dev, ino) 锚点(ADR-016)。

func NewRemoteFileAnchor

func NewRemoteFileAnchor(fileType RemoteFileType, hasDevIno bool, dev, ino uint64) (RemoteFileAnchor, error)

NewRemoteFileAnchor 校验文件类型与可选 (dev, ino) 并构造不可变 RemoteFileAnchor。

func (RemoteFileAnchor) Dev

func (a RemoteFileAnchor) Dev() uint64

func (RemoteFileAnchor) Equal

func (RemoteFileAnchor) FileType

func (a RemoteFileAnchor) FileType() RemoteFileType

func (RemoteFileAnchor) HasDevIno

func (a RemoteFileAnchor) HasDevIno() bool

func (RemoteFileAnchor) Ino

func (a RemoteFileAnchor) Ino() uint64

func (RemoteFileAnchor) IsValid

func (a RemoteFileAnchor) IsValid() bool

func (RemoteFileAnchor) IsZero

func (a RemoteFileAnchor) IsZero() bool

func (RemoteFileAnchor) MarshalJSONTo

func (a RemoteFileAnchor) MarshalJSONTo(e jEnc) error

func (RemoteFileAnchor) Matches

func (a RemoteFileAnchor) Matches(o RemoteFileAnchor) bool

func (*RemoteFileAnchor) UnmarshalJSONFrom

func (a *RemoteFileAnchor) UnmarshalJSONFrom(c jDec) error

type RemoteFileStat

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

RemoteFileStat 表示远端文件或目录的已校验元信息快照(强制 Size >= 0);零值恒无效。

func NewRemoteFileStat

func NewRemoteFileStat(spec RemoteFileStatSpec) (RemoteFileStat, error)

NewRemoteFileStat 校验远端路径、非负大小、时间戳与锚点并构造不可变 RemoteFileStat。

func (RemoteFileStat) Anchor

func (s RemoteFileStat) Anchor() RemoteFileAnchor

func (RemoteFileStat) Equal

func (s RemoteFileStat) Equal(o RemoteFileStat) bool

func (RemoteFileStat) FileType

func (s RemoteFileStat) FileType() RemoteFileType

func (RemoteFileStat) IsDir

func (s RemoteFileStat) IsDir() bool

func (RemoteFileStat) IsRegular

func (s RemoteFileStat) IsRegular() bool
func (s RemoteFileStat) IsSymlink() bool

func (RemoteFileStat) IsValid

func (s RemoteFileStat) IsValid() bool

func (RemoteFileStat) IsZero

func (s RemoteFileStat) IsZero() bool

func (RemoteFileStat) MarshalJSONTo

func (s RemoteFileStat) MarshalJSONTo(e jEnc) error

func (RemoteFileStat) ModTime

func (s RemoteFileStat) ModTime() time.Time

func (RemoteFileStat) Mode

func (s RemoteFileStat) Mode() fs.FileMode

func (RemoteFileStat) Path

func (RemoteFileStat) Perm

func (s RemoteFileStat) Perm() fs.FileMode

func (RemoteFileStat) Size

func (s RemoteFileStat) Size() int64

func (*RemoteFileStat) UnmarshalJSONFrom

func (s *RemoteFileStat) UnmarshalJSONFrom(c jDec) error

type RemoteFileStatSpec

type RemoteFileStatSpec struct {
	Path    pathalg.RemotePath
	Size    int64
	Mode    fs.FileMode
	ModTime time.Time
	Anchor  RemoteFileAnchor
}

RemoteFileStatSpec 是构造不可变 RemoteFileStat 的显式入参规格。

type RemoteFileType

type RemoteFileType uint8

RemoteFileType 标识远端 SFTP 文件系统对象类型;零值 RemoteFileTypeInvalid 严格失败关闭。

const (
	RemoteFileTypeInvalid RemoteFileType = RemoteFileType(pc.RemoteFileInvalidCode) // 无效类型(零值失败关闭)
	RemoteFileRegular     RemoteFileType = RemoteFileType(pc.RemoteFileRegularCode) // 常规文件
	RemoteFileDir         RemoteFileType = RemoteFileType(pc.RemoteFileDirCode)     // 目录
	RemoteFileSymlink     RemoteFileType = RemoteFileType(pc.RemoteFileSymlinkCode) // 符号链接
	RemoteFileOther       RemoteFileType = RemoteFileType(pc.RemoteFileOtherCode)   // 非常规特殊对象(下载路径一律拒绝)
)

func ParseRemoteFileType

func ParseRemoteFileType(s string) (RemoteFileType, error)

func (RemoteFileType) AppendText

func (t RemoteFileType) AppendText(b []byte) ([]byte, error)

func (RemoteFileType) IsValid

func (t RemoteFileType) IsValid() bool

func (RemoteFileType) IsZero

func (t RemoteFileType) IsZero() bool

func (RemoteFileType) MarshalText

func (t RemoteFileType) MarshalText() ([]byte, error)

func (RemoteFileType) String

func (t RemoteFileType) String() string

func (*RemoteFileType) UnmarshalText

func (t *RemoteFileType) UnmarshalText(b []byte) error

type RemoteRenameSpec

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

RemoteRenameSpec 描述远端原子重命名策略(ADR-016):支持互斥的 NoClobber 或 ExpectedAnchor 校验;零值恒无效。

func NewRemoteRenameSpec

func NewRemoteRenameSpec(in RemoteRenameSpecInput) (RemoteRenameSpec, error)

NewRemoteRenameSpec 校验互斥的 NoClobber 与可选 FSTAT ExpectedAnchor 并构造不可变 RemoteRenameSpec。

func (RemoteRenameSpec) Equal

func (RemoteRenameSpec) ExpectedAnchor

func (s RemoteRenameSpec) ExpectedAnchor() algebraic.Option[RemoteFileAnchor]

func (RemoteRenameSpec) IsValid

func (s RemoteRenameSpec) IsValid() bool

func (RemoteRenameSpec) IsZero

func (s RemoteRenameSpec) IsZero() bool

func (RemoteRenameSpec) MarshalJSONTo

func (s RemoteRenameSpec) MarshalJSONTo(e jEnc) error

func (RemoteRenameSpec) NoClobber

func (s RemoteRenameSpec) NoClobber() bool

func (*RemoteRenameSpec) UnmarshalJSONFrom

func (r *RemoteRenameSpec) UnmarshalJSONFrom(c jDec) error

type RemoteRenameSpecInput

type RemoteRenameSpecInput struct {
	ExpectedAnchor algebraic.Option[RemoteFileAnchor]
	NoClobber      bool
}

RemoteRenameSpecInput 是构造不可变 RemoteRenameSpec 的显式入参规格。

type RemoteSession

type RemoteSession interface {
	StdinPipe() (io.WriteCloser, error)
	StdoutPipe() (io.Reader, error)
	StderrPipe() (io.Reader, error)
	Start(ctx context.Context, cmd execution.CommandPlan, streams ExecStreams) error
	// StartShell 启动远端交互式 Shell 会话(可选 PTY 与环境变量统一由 streams.PTY / streams.Env 承载)。
	StartShell(ctx context.Context, streams ExecStreams) error
	ResizePTY(ctx context.Context, size TerminalSize) error
	Signal(ctx context.Context, signal string) error
	Wait(ctx context.Context) (execution.ExecutionOutcome, error)
	Close() error
}

RemoteSession 表示单条 SSH 通道上建立的远端命令或交互式 Shell 会话(隔离 x/crypto/ssh.Session)。 StdinPipe / StdoutPipe / StderrPipe 须在 Start / StartShell 前获取且分别与非空 ExecStreams.{Stdin,Stdout,Stderr} 互斥, 支撑 TerminalHandle.Relay 双向流中继与 sshnet/priv 随机 -p 提权握手(含 PROTOCOL.mux v4)。

type RemoteWriteSpec

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

RemoteWriteSpec 描述远端安全写路径策略(ADR-016):非零标准权限位、可选 FSTAT 锚点、NoClobber 与原子重命名。

func NewRemoteWriteSpec

func NewRemoteWriteSpec(in RemoteWriteSpecInput) (RemoteWriteSpec, error)

NewRemoteWriteSpec 校验标准权限位(0o001..0o777)与可选 FSTAT 锚点并构造不可变 RemoteWriteSpec。

func (RemoteWriteSpec) AtomicRename

func (s RemoteWriteSpec) AtomicRename() bool

func (RemoteWriteSpec) Equal

func (RemoteWriteSpec) ExpectedAnchor

func (s RemoteWriteSpec) ExpectedAnchor() algebraic.Option[RemoteFileAnchor]

func (RemoteWriteSpec) IsValid

func (s RemoteWriteSpec) IsValid() bool

func (RemoteWriteSpec) IsZero

func (s RemoteWriteSpec) IsZero() bool

func (RemoteWriteSpec) MarshalJSONTo

func (s RemoteWriteSpec) MarshalJSONTo(e jEnc) error

func (RemoteWriteSpec) NoClobber

func (s RemoteWriteSpec) NoClobber() bool

func (RemoteWriteSpec) Perm

func (s RemoteWriteSpec) Perm() fs.FileMode

func (*RemoteWriteSpec) UnmarshalJSONFrom

func (s *RemoteWriteSpec) UnmarshalJSONFrom(c jDec) error

type RemoteWriteSpecInput

type RemoteWriteSpecInput struct {
	Perm           fs.FileMode                        `json:"perm"`
	ExpectedAnchor algebraic.Option[RemoteFileAnchor] `json:"expected_anchor,omitzero"`
	NoClobber      bool                               `json:"no_clobber,omitzero"`
	AtomicRename   bool                               `json:"atomic_rename,omitzero"`
}

RemoteWriteSpecInput 是构造不可变 RemoteWriteSpec 的显式入参规格。

type Revision

type Revision = portval.Revision

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func ParseRevision

func ParseRevision(raw string) (Revision, error)

资产存储、CAS 持久化、WAL 世代与 OpenSSH 虚拟主机值对象构造薄转发函数。

type RootHandle

type RootHandle interface {
	ReadAllBounded(dest pathalg.LocalRootedDest, limits ReadLimits) ([]byte, error)
	// WithReadRegular 以有界随机只读句柄在同步闭包内借出常规文件,退出后自动失效关闭。
	//xops:syncclosure
	//xops:borrowed
	WithReadRegular(dest pathalg.LocalRootedDest, limits ReadLimits, fn func(r BoundedReadHandle, size int64) error) error
	// CreateExclusive 以 O_CREAT|O_EXCL|O_NOFOLLOW 独占创建常规文件并写入内容。
	//xops:syncclosure
	//xops:borrowed
	CreateExclusive(dest pathalg.LocalRootedDest, perm fs.FileMode, fn func(w io.Writer) error) error
	// AtomicReplace 写同目录随机临时文件、刷盘后原子替换目标文件。
	//xops:syncclosure
	//xops:borrowed
	AtomicReplace(dest pathalg.LocalRootedDest, perm fs.FileMode, fn func(w io.Writer) error) error
	// WriteChunk 向暂存文件 dest 的 offset 处非截断写入来自 r 的精确 length 字节并刷盘;流提前结束返回 (已写字节数, io.ErrUnexpectedEOF)。
	WriteChunk(dest pathalg.LocalRootedDest, offset int64, r io.Reader, length int64, perm fs.FileMode) (int64, error)
	// Rename 在沙箱根内原子重命名 oldDest -> newDest(非软链校验 + os.Root.Rename + 父目录同步)。
	Rename(oldDest, newDest pathalg.LocalRootedDest) error
	// WithLockedFile 在 ctx 取消控制下获取文件锁并校验 SameFile 后借出 LockedFile。
	//xops:syncclosure
	//xops:borrowed
	WithLockedFile(ctx context.Context, dest pathalg.LocalRootedDest, mode LockMode, create bool, perm fs.FileMode, fn func(f LockedFile) error) error
	// TryWithLockedFile 非阻塞尝试抢锁:锁忙立即返回 (false, nil),成功则同步执行 fn。
	//xops:syncclosure
	//xops:borrowed
	TryWithLockedFile(dest pathalg.LocalRootedDest, mode LockMode, create bool, perm fs.FileMode, fn func(f LockedFile) error) (acquired bool, err error)
	AppendLine(dest pathalg.LocalRootedDest, perm fs.FileMode, line []byte) error
	Stat(dest pathalg.LocalRootedDest) (LocalFileInfo, error)
	Lstat(dest pathalg.LocalRootedDest) (LocalFileInfo, error)
	ReadDir(dir algebraic.Option[pathalg.LocalRootedDest]) ([]LocalDirEntry, error)
	MkdirAll(dir pathalg.LocalRootedDest, perm fs.FileMode) error
	CreateSymlink(link pathalg.LocalRootedDest, target string) error
	// Chtimes 修改沙箱内常规文件或目录的访问与修改时间(拒绝符号链接、零值及超出 RFC 3339 年份 [1,9999] 的时间戳,支撑 scp -p)。
	Chtimes(dest pathalg.LocalRootedDest, atime, mtime time.Time) error
	Remove(dest pathalg.LocalRootedDest) error
}

RootHandle 是 ScopedRootFS.WithRoot 在同步回调内借出的沙箱目录根句柄(ADR-007 / INV-A1..A5)。 全部路径须为已校验 LocalRootedDest;写锁一律加在同根旁路锁 <name>.lock,绝不对数据文件本身加锁后再 Rename。

type SSHAgentPort

type SSHAgentPort interface {
	DialAgent(ctx context.Context, spec algebraic.Option[inventory.AgentSpec]) (net.Conn, error)
	ListAgentKeys(ctx context.Context, spec algebraic.Option[inventory.AgentSpec]) ([]PublicKeyInfo, error)
	SignWithAgent(ctx context.Context, spec algebraic.Option[inventory.AgentSpec], key inventory.KeyFingerprint, algorithm string, data []byte) (Signature, error)
}

SSHAgentPort 定义本机 SSH Agent 通道连接、公钥列举与签名出站端口(统一封装 Unix $SSH_AUTH_SOCK 与 Windows 命名管道)。

type SSHFPLookupPort

type SSHFPLookupPort interface {
	LookupSSHFP(ctx context.Context, host netaddr.CanonicalHost) ([]SSHFPRecord, error)
}

SSHFPLookupPort 定义 DNS SSHFP 记录只读查询出站端口(由 internal/host/sys 实现并注入 sshnet/hostkey)。

type SSHFPRecord

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

SSHFPRecord 表示单条经校验的 DNS SSHFP 记录;零值恒无效且 Authenticated==false。

func NewSSHFPRecord

func NewSSHFPRecord(spec SSHFPRecordSpec) (SSHFPRecord, error)

NewSSHFPRecord 校验算法编号、摘要类型(1=SHA-1/20B, 2=SHA-256/32B)与长度并构造不可变记录。

func (SSHFPRecord) Algorithm

func (r SSHFPRecord) Algorithm() uint8

func (SSHFPRecord) Authenticated

func (r SSHFPRecord) Authenticated() bool

func (SSHFPRecord) Digest

func (r SSHFPRecord) Digest() []byte

func (SSHFPRecord) Equal

func (r SSHFPRecord) Equal(o SSHFPRecord) bool

func (SSHFPRecord) FingerprintType

func (r SSHFPRecord) FingerprintType() uint8

func (SSHFPRecord) IsValid

func (r SSHFPRecord) IsValid() bool

func (SSHFPRecord) IsZero

func (r SSHFPRecord) IsZero() bool

func (SSHFPRecord) MarshalJSONTo

func (r SSHFPRecord) MarshalJSONTo(e jEnc) error

func (*SSHFPRecord) UnmarshalJSONFrom

func (r *SSHFPRecord) UnmarshalJSONFrom(c jDec) error

type SSHFPRecordSpec

type SSHFPRecordSpec struct {
	Algorithm, FingerprintType uint8
	Digest                     []byte
	Authenticated              bool // DNSSEC AD 校验标记(零值 false 失败关闭)
}

SSHFPRecordSpec 是构造不可变 SSHFPRecord 的显式入参规格(RFC 4255 / RFC 6594)。

type ScopedRootFS

type ScopedRootFS interface {
	// EnsureRoot 跨平台安全确保根目录 dir 存在且末段非软链(Unix 按 perm/0700,Windows 0700 附 Owner-Only DACL)。
	EnsureRoot(dir pathalg.LocalDir, perm fs.FileMode) error
	// WithRoot 打开绑定至 dir 的沙箱根句柄并在同步闭包内借出;退出前无条件关闭。
	//xops:syncclosure
	//xops:borrowed
	WithRoot(dir pathalg.LocalDir, fn func(root RootHandle) error) error
}

ScopedRootFS 定义基于 Go *os.Root 的沙箱本地文件系统出站端口(ADR-007)。

type SecretPromptCapable added in v1.3.0

type SecretPromptCapable interface {
	CanPromptSecret() bool
}

SecretPromptCapable 是 InteractionPort 的具名可选扩展接口(ADR-019 B3), 用于将「具备真实控制 TTY(CanInteract)」与「支持通过 TTY 或合规 SSH_ASKPASS 采集 SSH 认证机密/确认(CanPromptSecret)」解耦; 严禁用于 gate 审批、PromptApproval、离线凭据库解锁或 ControlMaster 确认。

type SecretPromptRequest

type SecretPromptRequest = portval.SecretPromptRequest

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewSecretPromptRequest

func NewSecretPromptRequest(spec SecretPromptRequestSpec) (SecretPromptRequest, error)

交互提示与审批回执值对象构造薄转发函数。

type SecretPromptRequestSpec

type SecretPromptRequestSpec = portval.SecretPromptRequestSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type SecretVault

type SecretVault interface {
	// WithSecret 按 ref 读取机密并在同步闭包内借出 *secret.SecretBox;退出前无条件清零。
	//xops:syncclosure
	//xops:borrowed
	WithSecret(ctx context.Context, ref secret.Ref, fn func(box *secret.SecretBox) error) error
	PutAndVerify(ctx context.Context, ref secret.Ref, box *secret.SecretBox) error
	Delete(ctx context.Context, ref secret.Ref) error
}

SecretVault 定义 100% 作用域闭包化的凭据存储出站端口(ADR-011 / RFC §3.2)。

type SessionOpener

type SessionOpener interface {
	OpenSession(ctx context.Context) (RemoteSession, error)
}

SessionOpener 是打开隔离远端会话通道的最小能力窄接口;*pool.Lease 与 TransportConn 均天然满足。

type ShellProbePort

type ShellProbePort interface {
	ProbeShell(ctx context.Context, opener SessionOpener) (ShellProbeResult, error)
}

ShellProbePort 定义远端默认启动方言与解释器两阶段探测出站端口(P3-T2 <-> P4-T1 sshnet/probe)。

type ShellProbeResult

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

ShellProbeResult 表示远端两阶段 Shell 探测产出的已校验启动方言与解释器快照;零值恒无效。

func NewShellProbeResult

func NewShellProbeResult(spec ShellProbeResultSpec) (ShellProbeResult, error)

NewShellProbeResult 校验方言/解释器兼容性矩阵、探测阶段(1 或 2)与可选元信息并构造不可变结果。

func (ShellProbeResult) Dialect

func (ShellProbeResult) Equal

func (ShellProbeResult) Interpreter

func (r ShellProbeResult) Interpreter() execution.Interpreter

func (ShellProbeResult) IsValid

func (r ShellProbeResult) IsValid() bool

func (ShellProbeResult) IsZero

func (r ShellProbeResult) IsZero() bool

func (ShellProbeResult) LaunchProfile

func (r ShellProbeResult) LaunchProfile() execution.LaunchProfile

func (ShellProbeResult) MarshalJSONTo

func (r ShellProbeResult) MarshalJSONTo(e jEnc) error

func (ShellProbeResult) OSFamily

func (r ShellProbeResult) OSFamily() string

func (ShellProbeResult) ProbeStage

func (r ShellProbeResult) ProbeStage() uint8

func (ShellProbeResult) RawBanner

func (r ShellProbeResult) RawBanner() string

func (*ShellProbeResult) UnmarshalJSONFrom

func (r *ShellProbeResult) UnmarshalJSONFrom(c jDec) error

type ShellProbeResultSpec

type ShellProbeResultSpec struct {
	Dialect     execution.LaunchDialect `json:"dialect"`
	Interpreter execution.Interpreter   `json:"interpreter"`
	OSFamily    string                  `json:"os_family,omitzero"`
	ProbeStage  uint8                   `json:"probe_stage"`
	RawBanner   string                  `json:"raw_banner,omitzero"`
}

ShellProbeResultSpec 是构造不可变 ShellProbeResult 的显式入参规格。

type Signature

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

Signature 表示协议库无关的不可变 SSH 数字签名值对象;零值恒无效。

func NewSignature

func NewSignature(format string, blob []byte) (Signature, error)

NewSignature 校验签名算法格式与非空载荷并构造不可变 Signature。

func (Signature) Blob

func (s Signature) Blob() []byte

func (Signature) Equal

func (s Signature) Equal(o Signature) bool

func (Signature) Format

func (s Signature) Format() string

func (Signature) IsValid

func (s Signature) IsValid() bool

func (Signature) IsZero

func (s Signature) IsZero() bool

type SubsystemRemoteSession added in v1.3.0

type SubsystemRemoteSession interface {
	StartSubsystem(ctx context.Context, subsystem string, streams ExecStreams) error
}

SubsystemRemoteSession 是 RemoteSession 的具名可选扩展接口(ADR-019 C1), 用于在同一 SSH 通道上按 RFC 4254 subsystem 请求启动指定远端 SSH 子系统(如 netconf / sftp); 流管道互斥与单次启动约束与 Start / StartShell 保持一致,严禁匿名接口断言(noimplicit)。

type SuspendableTerminalHandle added in v1.3.0

type SuspendableTerminalHandle interface {
	Suspend() error
}

SuspendableTerminalHandle 是 TerminalHandle 的具名可选扩展接口(ADR-019 C1), 供交互会话 ~^Z 转义在通过 TerminalPort.CanSuspendProcessGroup 安全判定(INV-E1)后执行可重入挂起与恢复; 严禁匿名接口断言(noimplicit)。

type TUNDevicePort

type TUNDevicePort interface {
	// OpenLocalTUN 按 spec 打开本机 TUN/TAP 设备,返回双向帧流与操作系统实际分配的接口名(如 "tun0"/"utun3")。
	OpenLocalTUN(ctx context.Context, spec TUNSpec) (dev io.ReadWriteCloser, ifaceName string, err error)
}

TUNDevicePort 定义本机 TUN/TAP 虚拟网卡打开出站端口(P4-T4 internal/host/sys <-> P4-T2 sshnet/forward),隔离平台系统调用。

type TUNMode

type TUNMode uint8

TUNMode 标识 OpenSSH tun@openssh.com 隧道工作模式(L3 点对点 / L2 以太网);零值 TUNModeInvalid 失败关闭。

const (
	TUNModeInvalid      TUNMode = TUNMode(pc.TUNModeInvalidCode)      // 无效模式(零值失败关闭)
	TUNModePointToPoint TUNMode = TUNMode(pc.TUNModePointToPointCode) // L3 点对点 IP 隧道(tun)
	TUNModeEthernet     TUNMode = TUNMode(pc.TUNModeEthernetCode)     // L2 以太网帧隧道(tap)
)

func ParseTUNMode

func ParseTUNMode(s string) (TUNMode, error)

func (TUNMode) AppendText

func (m TUNMode) AppendText(b []byte) ([]byte, error)

func (TUNMode) IsValid

func (m TUNMode) IsValid() bool

func (TUNMode) IsZero

func (m TUNMode) IsZero() bool

func (TUNMode) MarshalText

func (m TUNMode) MarshalText() ([]byte, error)

func (TUNMode) String

func (m TUNMode) String() string

func (*TUNMode) UnmarshalText

func (m *TUNMode) UnmarshalText(t []byte) error

type TUNSpec

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

TUNSpec 描述 OpenSSH tun@openssh.com 通道规格(模式与本地/远端单元号);零值恒无效。

func NewTUNSpec

func NewTUNSpec(mode TUNMode, localUnit, remoteUnit uint32) (TUNSpec, error)

NewTUNSpec 校验 TUN 模式与合法单元号(0..4096 或 TUNUnitAny)并构造不可变 TUNSpec。

func (TUNSpec) Equal

func (s TUNSpec) Equal(o TUNSpec) bool

func (TUNSpec) IsValid

func (s TUNSpec) IsValid() bool

func (TUNSpec) IsZero

func (s TUNSpec) IsZero() bool

func (TUNSpec) LocalUnit

func (s TUNSpec) LocalUnit() uint32

func (TUNSpec) MarshalJSONTo

func (s TUNSpec) MarshalJSONTo(e jEnc) error

func (TUNSpec) Mode

func (s TUNSpec) Mode() TUNMode

func (TUNSpec) RemoteUnit

func (s TUNSpec) RemoteUnit() uint32

func (*TUNSpec) UnmarshalJSONFrom

func (s *TUNSpec) UnmarshalJSONFrom(c jDec) error

type TerminalHandle

type TerminalHandle interface {
	io.Reader
	io.Writer
	Size() (TerminalSize, error)
	ResizeEvents() <-chan TerminalSize
	// Relay 在同步作用域内将本机输入/输出与缩放事件并发中继至远端(本机 EOF 半关闭并排空 remoteOut,
	// remoteOut EOF 或 ctx 取消时唤醒阻塞端并零泄漏收敛;nil ctx/流返回 ErrNilContext/ErrInvalidArgument,过期返回 ErrHandleExpired)。
	//xops:syncclosure
	Relay(ctx context.Context, remoteIn io.Writer, remoteOut io.Reader, onResize func(ctx context.Context, size TerminalSize) error) error
}

TerminalHandle 是 TerminalPort.WithRawTerminal 在同步作用域闭包内借出的原始终端句柄。 Write 实现必须支持与 Relay 并发调用(例如在 Relay 持续输出远端流期间并发写入本地提示或转义诊断), 严禁在并发 Write 下产生数据竞争(ADR-019 v2.2 S3-Q4a)。

type TerminalPort

type TerminalPort interface {
	IsInteractive() bool
	Size() (TerminalSize, error)
	// WithRawTerminal 进入原始终端/ConPTY 模式并在同步闭包内借出 TerminalHandle,退出前无条件恢复。
	//xops:syncclosure
	//xops:borrowed
	WithRawTerminal(ctx context.Context, fn func(term TerminalHandle) error) error
	// CanSuspendProcessGroup 执行 POSIX 孤儿进程组安全挂起判定(INV-E1:任何错误失败关闭返回 VerdictDeny + error)。
	CanSuspendProcessGroup() (security.Verdict, error)
}

TerminalPort 定义本机 PTY / Windows ConPTY 控制台与进程组挂起判定出站端口(仅由 internal/host/sys 或 sim 实现)。

type TerminalSize

type TerminalSize = portval.TerminalSize

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewTerminalSize

func NewTerminalSize(cols, rows uint16) (TerminalSize, error)

type TextPromptRequest

type TextPromptRequest = portval.TextPromptRequest

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

func NewTextPromptRequest

func NewTextPromptRequest(spec TextPromptRequestSpec) (TextPromptRequest, error)

type TextPromptRequestSpec

type TextPromptRequestSpec = portval.TextPromptRequestSpec

下述类型别名与构造转发函数完整重导出子包 core/ports/portval, 保持 core/ports 既有公开契约 100% 二进制与源码兼容; //xops:opaque 与 //xops:failclosed 契约唯一归属 portval 定义处,绝不在别名处重复标注。

type Tier4ResolveOptions added in v1.3.0

type Tier4ResolveOptions struct {
	// CanonicalPass 为 true 时启用 OpenSSH post_canon=1 语义(命中 Match canonical,不命中 Match !canonical)。
	CanonicalPass bool
}

Tier4ResolveOptions 封装面向 CanonicalOpenSSHConfigSource.ResolveTier4WithOptions 的两轮解析选项(ADR-019 E1); 零值 CanonicalPass == false 表示 OpenSSH 首轮(规范化前)匹配语义。

type Timer

type Timer interface {
	C() <-chan time.Time
	Stop() bool
	Reset(d time.Duration) bool
}

Timer 表示由 Clock 创建的可取消单次定时器,支撑确定性仿真时钟与真实系统时钟一致抽象。

type TransportConn

type TransportConn interface {
	SessionOpener
	TunnelTransport
	HopDigest() plan.HopDigest
	Endpoint() netaddr.Endpoint
	OpenRemoteFS(ctx context.Context) (RemoteFSPort, error)
	SendKeepalive(ctx context.Context) error
	IsAlive() bool
	Close() error
}

TransportConn 表示一条已认证的实时 SSH 传输连接,由 core/internal/pool 独占托管(ADR-009)。

type TunnelTransport

type TunnelTransport interface {
	DialTCP(ctx context.Context, target netaddr.HostPort) (net.Conn, error)
	ListenTCP(ctx context.Context, bindAddr string) (net.Listener, error)
	DialStreamLocal(ctx context.Context, remoteSocket pathalg.RemotePath) (net.Conn, error)
	ListenStreamLocal(ctx context.Context, remoteSocket pathalg.RemotePath) (net.Listener, error)
	OpenTUN(ctx context.Context, spec TUNSpec) (io.ReadWriteCloser, error)
}

TunnelTransport 是面向端口转发、StreamLocal 与 TUN 隧道的最小数据面窄接口;*pool.Lease 与 TransportConn 均满足。

type VaultControlPort

type VaultControlPort interface {
	Init(ctx context.Context, pass *secret.SecretBox) error   // 使用借用主口令初始化;已初始化返回 ErrAlreadyExists
	Unlock(ctx context.Context, pass *secret.SecretBox) error // 解锁凭据库;口令错返回 ErrAuthFailed,未初始化返回 ErrNotFound
	Lock(ctx context.Context) error
	Status(ctx context.Context) (VaultStatus, error)
}

VaultControlPort 定义凭据库初始化、解锁、锁定与状态查询出站端口(P3-T1 <-> P4-T4)。 Init / Unlock 无回调参数,借用的主口令 *secret.SecretBox 由 secretbox Rule 1 与具体实现参数级 //xops:borrowed 共同保证零逃逸。

type VaultControlRouter added in v1.3.0

type VaultControlRouter interface {
	ControlFor(store string) (VaultControlPort, error)
	ControlledStores() []string
}

VaultControlRouter 定义面向多离线凭据库实例的按存储名控制面路由出站端口(ADR-018)。 保留既有 VaultControlPort 单库契约零破坏,支撑 M1-T4 / M2-T1 按配置 store 名路由至对应后端控制器; 未登记或非法 store 名须失败关闭返回 ErrNotFound / ErrInvalidArgument,ControlledStores 须返回按字典序排序去重的防御性副本。

type VaultState

type VaultState uint8

VaultState 表示凭据库生命周期状态;零值 VaultStateInvalid 严格失败关闭。

const (
	VaultStateInvalid       VaultState = VaultState(pc.VaultStateInvalidCode)       // 无效状态(零值失败关闭)
	VaultStateUninitialized VaultState = VaultState(pc.VaultStateUninitializedCode) // 尚未初始化凭据库
	VaultStateLocked        VaultState = VaultState(pc.VaultStateLockedCode)        // 已初始化但处于锁定状态
	VaultStateUnlocked      VaultState = VaultState(pc.VaultStateUnlockedCode)      // 已解锁并可供读写
)

func ParseVaultState

func ParseVaultState(s string) (VaultState, error)

func (VaultState) AppendText

func (s VaultState) AppendText(b []byte) ([]byte, error)

func (VaultState) IsValid

func (s VaultState) IsValid() bool

func (VaultState) IsZero

func (s VaultState) IsZero() bool

func (VaultState) MarshalText

func (s VaultState) MarshalText() ([]byte, error)

func (VaultState) String

func (s VaultState) String() string

func (*VaultState) UnmarshalText

func (s *VaultState) UnmarshalText(t []byte) error

type VaultStatus

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

VaultStatus 描述凭据库当前锁定状态、可用存储后端清单、解锁/交互控制面策略与诊断摘要;零值恒无效。

func NewVaultStatus

func NewVaultStatus(spec VaultStatusSpec) (VaultStatus, error)

NewVaultStatus 校验状态、存储后端清单与可选解锁/超时策略,并构造规范排序去重的不可变 VaultStatus。

func (VaultStatus) Detail

func (s VaultStatus) Detail() string

func (VaultStatus) EffectiveUnlockMode added in v1.3.0

func (s VaultStatus) EffectiveUnlockMode() VaultUnlockMode

EffectiveUnlockMode 返回生效解锁模式:无效零值返回 VaultUnlockModeInvalid,有效且未显式设置时向后兼容默认 VaultUnlockModePassphrase。

func (VaultStatus) Equal

func (s VaultStatus) Equal(o VaultStatus) bool

func (VaultStatus) IsUnlocked

func (s VaultStatus) IsUnlocked() bool

func (VaultStatus) IsValid

func (s VaultStatus) IsValid() bool

func (VaultStatus) IsZero

func (s VaultStatus) IsZero() bool

func (VaultStatus) KnownStores

func (s VaultStatus) KnownStores() []string

func (VaultStatus) MarshalJSONTo

func (s VaultStatus) MarshalJSONTo(e jEnc) error

func (VaultStatus) NonInteractive added in v1.3.0

func (s VaultStatus) NonInteractive() bool

NonInteractive 报告目标凭据库是否禁止交互式口令提示;无效零值严格失败关闭返回 true。

func (VaultStatus) PromptTimeout added in v1.3.0

func (s VaultStatus) PromptTimeout() algebraic.Option[algebraic.Duration]

func (VaultStatus) State

func (s VaultStatus) State() VaultState

func (VaultStatus) UnlockMode added in v1.3.0

func (s VaultStatus) UnlockMode() algebraic.Option[VaultUnlockMode]

func (*VaultStatus) UnmarshalJSONFrom

func (s *VaultStatus) UnmarshalJSONFrom(c jDec) error

type VaultStatusSpec

type VaultStatusSpec struct {
	State          VaultState                           `json:"state"`
	KnownStores    []string                             `json:"known_stores,omitzero"`
	Detail         string                               `json:"detail,omitzero"`
	UnlockMode     algebraic.Option[VaultUnlockMode]    `json:"unlock_mode,omitzero"`
	NonInteractive bool                                 `json:"non_interactive,omitzero"`
	PromptTimeout  algebraic.Option[algebraic.Duration] `json:"prompt_timeout,omitzero"`
}

VaultStatusSpec 是构造不可变 VaultStatus 的显式入参规格。

type VaultUnlockMode added in v1.3.0

type VaultUnlockMode uint8

VaultUnlockMode 表示凭据库的解锁方式枚举;零值 VaultUnlockModeInvalid 严格失败关闭。

const (
	VaultUnlockModeInvalid    VaultUnlockMode = VaultUnlockMode(pc.VaultUnlockModeInvalidCode)    // 无效解锁模式(零值失败关闭)
	VaultUnlockModePassphrase VaultUnlockMode = VaultUnlockMode(pc.VaultUnlockModePassphraseCode) // 主口令解锁模式
	VaultUnlockModeKeyFile    VaultUnlockMode = VaultUnlockMode(pc.VaultUnlockModeKeyFileCode)    // 密钥文件无头解锁模式
)

func ParseVaultUnlockMode added in v1.3.0

func ParseVaultUnlockMode(s string) (VaultUnlockMode, error)

func (VaultUnlockMode) AppendText added in v1.3.0

func (m VaultUnlockMode) AppendText(b []byte) ([]byte, error)

func (VaultUnlockMode) IsValid added in v1.3.0

func (m VaultUnlockMode) IsValid() bool

func (VaultUnlockMode) IsZero added in v1.3.0

func (m VaultUnlockMode) IsZero() bool

func (VaultUnlockMode) MarshalText added in v1.3.0

func (m VaultUnlockMode) MarshalText() ([]byte, error)

func (VaultUnlockMode) String added in v1.3.0

func (m VaultUnlockMode) String() string

func (*VaultUnlockMode) UnmarshalText added in v1.3.0

func (m *VaultUnlockMode) UnmarshalText(t []byte) error

Directories

Path Synopsis
internal
portscheck
Package portscheck 提供 core/ports 使用的纯编解码名称表、通用 JSON/文本编解码辅助与值对象边界校验工具。
Package portscheck 提供 core/ports 使用的纯编解码名称表、通用 JSON/文本编解码辅助与值对象边界校验工具。
Package portval 提供 core/ports 拆分的交互、系统、诊断、多路复用快照与存储出站契约不可变值对象子包。
Package portval 提供 core/ports 拆分的交互、系统、诊断、多路复用快照与存储出站契约不可变值对象子包。
tck
Package tck 提供面向 core/ports 全部出站端口的可复用测试契约夹具套件(Test Compatibility Kit,ADR-002 / Plan P2-T1)。
Package tck 提供面向 core/ports 全部出站端口的可复用测试契约夹具套件(Test Compatibility Kit,ADR-002 / Plan P2-T1)。
internal/tckutil
Package tckutil 提供 core/ports/tck 使用的无环内部测试夹具构造、确定性熵源与通用断言辅助。
Package tckutil 提供 core/ports/tck 使用的无环内部测试夹具构造、确定性熵源与通用断言辅助。

Jump to

Keyboard shortcuts

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