Documentation
¶
Overview ¶
Package simports 为 core/internal/sim 提供无环纯内存非明文端口仿真叶包(LayerCoreSim):
- 存储、日志与导入仿真:InventoryStore、JournalStore、FormatImporter;
- 签名与主机信任仿真:KeySigner、HostTrust;
- 扩展会话与系统端口仿真:SSHAgent、ShellProbe、Forwarder、ProcessPort、RemoteSession;
- OpenSSH 规范化解析与诊断仿真:CanonicalResolver、DiagnosticSink、OpenSSHConfigSource;
- 虚拟时钟、终端与文件系统仿真:Clock、TerminalPort、OperatorReadFS、RemoteFS;
- 多凭据库控制面路由仿真:VaultControlRouter。
架构约束:零生产可达(xopsvet/archbound)、零反向导入父包 core/internal/sim、零明文 SecretBox 消费、 零 time.Now/time.Sleep/裸 go/crypto/rand/path/filepath/nolint;零值适配器统一失败关闭返回 ErrSimNotInitialized。
Index ¶
- Variables
- type CanonicalResolver
- func (r *CanonicalResolver) CNAMELookupCount() uint64
- func (b *CanonicalResolver) Faults() *memtree.FaultInjector
- func (r *CanonicalResolver) HostLookupCount() uint64
- func (r *CanonicalResolver) LookupCNAME(ctx context.Context, host string) (string, error)
- func (r *CanonicalResolver) LookupCount() uint64
- func (r *CanonicalResolver) LookupHost(ctx context.Context, host string) ([]string, error)
- func (r *CanonicalResolver) RecordedQueries() []string
- func (r *CanonicalResolver) SetCNAME(host, target string)
- func (r *CanonicalResolver) SetCNAMEChain(names ...string)
- func (r *CanonicalResolver) SetCNAMELoop(names ...string)
- func (r *CanonicalResolver) SetFollowCNAMEChain(follow bool)
- func (r *CanonicalResolver) SetHost(host string, addrs ...string)
- func (r *CanonicalResolver) SetHostError(host string, err error)
- func (r *CanonicalResolver) SetLatency(d time.Duration)
- func (r *CanonicalResolver) SetMaxCNAMEHops(maxHops int)
- type Clock
- func (c *Clock) Advance(d time.Duration)
- func (c *Clock) AdvanceToNext() (time.Duration, bool)
- func (b *Clock) Faults() *memtree.FaultInjector
- func (c *Clock) NewTimer(d time.Duration) ports.Timer
- func (c *Clock) Now() time.Time
- func (c *Clock) PendingTimers() int
- func (c *Clock) Since(t time.Time) time.Duration
- func (c *Clock) Sleep(ctx context.Context, d time.Duration) error
- func (c *Clock) WaitPending(ctx context.Context, n int) error
- type DiagnosticSink
- func (s *DiagnosticSink) Count() int
- func (s *DiagnosticSink) Dropped() uint64
- func (s *DiagnosticSink) Emit(ctx context.Context, rec ports.DiagnosticRecord)
- func (b *DiagnosticSink) Faults() *memtree.FaultInjector
- func (s *DiagnosticSink) Records() []ports.DiagnosticRecord
- func (s *DiagnosticSink) Reset()
- func (s *DiagnosticSink) SetMaxLevel(level uint8)
- func (s *DiagnosticSink) SetMaxRecords(limit int)
- type FormatImporter
- type Forwarder
- type HostTrust
- func (b *HostTrust) Faults() *memtree.FaultInjector
- func (t *HostTrust) PreferredAlgorithms(ctx context.Context, ep netaddr.Endpoint, _ option.KnownHostsList) ([]string, error)
- func (t *HostTrust) RecordHostKey(ctx context.Context, ep netaddr.Endpoint, key ports.PublicKeyInfo, ...) error
- func (t *HostTrust) RevokeKey(fp inventory.KeyFingerprint)
- func (t *HostTrust) VerifyHostKey(ctx context.Context, req ports.HostTrustRequest) (out ports.HostTrustCheck, err error)
- type InventoryStore
- func (s *InventoryStore) CommitCAS(ctx context.Context, expected ports.Revision, next inventory.Graph) (out ports.DurabilityOutcome, err error)
- func (b *InventoryStore) Faults() *memtree.FaultInjector
- func (s *InventoryStore) InjectNextDurability(out ports.DurabilityOutcome)
- func (s *InventoryStore) Load(ctx context.Context) (out ports.InventorySnapshot, err error)
- type JournalStore
- func (s *JournalStore) Append(ctx context.Context, rec fsm.TransferJournalRecord) error
- func (s *JournalStore) CorruptGeneration(id security.OperationID, generation uint64, cause error)
- func (s *JournalStore) Delete(ctx context.Context, id security.OperationID) error
- func (b *JournalStore) Faults() *memtree.FaultInjector
- func (s *JournalStore) ListActive(ctx context.Context) ([]security.OperationID, error)
- func (s *JournalStore) Load(ctx context.Context, id security.OperationID) (out []fsm.TransferJournalRecord, err error)
- func (s *JournalStore) LoadGenerations(ctx context.Context, id security.OperationID) ([]ports.JournalGenerationSnapshot, error)
- func (s *JournalStore) PruneGeneration(ctx context.Context, id security.OperationID, generation uint64) error
- type KeySigner
- func (s *KeySigner) AddKey(pub ports.PublicKeyInfo, keyPath string)
- func (b *KeySigner) Faults() *memtree.FaultInjector
- func (s *KeySigner) InspectPrivateKeyFingerprint(ctx context.Context, keyPath inventory.KeyPathSpec, ...) (out inventory.KeyFingerprint, err error)
- func (s *KeySigner) ListPublicKeys(ctx context.Context, auth inventory.AuthMethod) ([]ports.PublicKeyInfo, error)
- func (s *KeySigner) Sign(ctx context.Context, key inventory.KeyFingerprint, algorithm string, ...) (out ports.Signature, err error)
- type OpenSSHConfigSource
- func (b *OpenSSHConfigSource) Faults() *memtree.FaultInjector
- func (s *OpenSSHConfigSource) LastResolveOptions() ports.Tier4ResolveOptions
- func (s *OpenSSHConfigSource) ListVirtualHosts(ctx context.Context) ([]ports.OpenSSHVirtualHost, error)
- func (s *OpenSSHConfigSource) ResolveCount() int
- func (s *OpenSSHConfigSource) ResolveTier4(ctx context.Context, target option.OriginalHostSpec, ...) (out option.OptionLayer, err error)
- func (s *OpenSSHConfigSource) ResolveTier4WithOptions(ctx context.Context, target option.OriginalHostSpec, ...) (out option.OptionLayer, err error)
- func (s *OpenSSHConfigSource) SetCanonicalHosts(hosts ...ports.OpenSSHVirtualHost)
- type OperatorReadFS
- func (b *OperatorReadFS) Faults() *memtree.FaultInjector
- func (o *OperatorReadFS) PutFile(p pathalg.LocalSourcePath, data []byte) error
- func (o *OperatorReadFS) PutSymlink(linkPath, targetPath pathalg.LocalSourcePath) error
- func (o *OperatorReadFS) WithOperatorRead(ctx context.Context, srcPath pathalg.LocalSourcePath, ...) error
- type ProcessHandler
- type ProcessPort
- func (p *ProcessPort) DialStdio(ctx context.Context, spec ports.ProcessSpec) (net.Conn, error)
- func (b *ProcessPort) Faults() *memtree.FaultInjector
- func (p *ProcessPort) RegisterCommand(cmd string, fn ProcessHandler)
- func (p *ProcessPort) Run(ctx context.Context, spec ports.ProcessSpec, stdin io.Reader) (out ports.ProcessResult, err error)
- type RemoteFS
- func (r *RemoteFS) Chmod(ctx context.Context, p pathalg.RemotePath, perm fs.FileMode) error
- func (r *RemoteFS) Chtimes(ctx context.Context, p pathalg.RemotePath, atime, mtime time.Time) error
- func (r *RemoteFS) Close() error
- func (b *RemoteFS) Faults() *memtree.FaultInjector
- func (r *RemoteFS) Lstat(ctx context.Context, p pathalg.RemotePath) (ports.RemoteFileStat, error)
- func (r *RemoteFS) MkdirAll(ctx context.Context, dir pathalg.RemotePath, perm fs.FileMode) error
- func (r *RemoteFS) PutSymlink(linkPath pathalg.RemotePath, target string) error
- func (r *RemoteFS) ReadChunk(ctx context.Context, p pathalg.RemotePath, offset int64, dst io.Writer, ...) (int64, error)
- func (r *RemoteFS) ReadDir(ctx context.Context, dir pathalg.RemotePath) (out []ports.RemoteDirEntry, err error)
- func (r *RemoteFS) ReadLink(ctx context.Context, p pathalg.RemotePath) (target string, err error)
- func (r *RemoteFS) RealPath(ctx context.Context, p pathalg.RemotePath) (out pathalg.RemotePath, err error)
- func (r *RemoteFS) Remove(ctx context.Context, p pathalg.RemotePath) error
- func (r *RemoteFS) RemoveDir(ctx context.Context, dir pathalg.RemotePath) error
- func (r *RemoteFS) RenameAtomic(ctx context.Context, oldPath, newPath pathalg.RemotePath, ...) error
- func (r *RemoteFS) SetENOSPC(en bool)
- func (r *RemoteFS) Stat(ctx context.Context, p pathalg.RemotePath) (ports.RemoteFileStat, error)
- func (r *RemoteFS) WithReadFile(ctx context.Context, p pathalg.RemotePath, limits ports.ReadLimits, ...) error
- func (r *RemoteFS) WriteChunk(ctx context.Context, p pathalg.RemotePath, offset int64, src io.Reader, ...) error
- func (r *RemoteFS) WriteFileAtomic(ctx context.Context, p pathalg.RemotePath, spec ports.RemoteWriteSpec, ...) (out ports.RemoteFileStat, err error)
- type RemoteSession
- func (s *RemoteSession) BeginStartLocked(streams ports.ExecStreams) error
- func (s *RemoteSession) Close() error
- func (s *RemoteSession) LastEscapeChar() algebraic.Option[option.EscapeCharSpec]
- func (s *RemoteSession) LastForwardAgent() algebraic.Option[inventory.AgentSpec]
- func (s *RemoteSession) LastSubsystem() string
- func (s *RemoteSession) ResizePTY(ctx context.Context, size ports.TerminalSize) error
- func (s *RemoteSession) SetDirectNativeTTY(enabled bool)
- func (s *RemoteSession) Signal(ctx context.Context, sig string) error
- func (s *RemoteSession) Start(ctx context.Context, cmd execution.CommandPlan, streams ports.ExecStreams) error
- func (s *RemoteSession) StartShell(ctx context.Context, streams ports.ExecStreams) error
- func (s *RemoteSession) StartSubsystem(ctx context.Context, subsystem string, streams ports.ExecStreams) error
- func (s *RemoteSession) StderrPipe() (io.Reader, error)
- func (s *RemoteSession) StdinPipe() (io.WriteCloser, error)
- func (s *RemoteSession) StdoutPipe() (io.Reader, error)
- func (s *RemoteSession) UsesDirectNativeTTY() bool
- func (s *RemoteSession) Wait(ctx context.Context) (execution.ExecutionOutcome, error)
- type RevokedPrivStreamHandle
- func (h *RevokedPrivStreamHandle) ResizePTY(ctx context.Context, size ports.TerminalSize) error
- func (h *RevokedPrivStreamHandle) Revoke()
- func (h *RevokedPrivStreamHandle) Signal(ctx context.Context, sig string) error
- func (h *RevokedPrivStreamHandle) Stderr() io.Reader
- func (h *RevokedPrivStreamHandle) Stdin() io.WriteCloser
- func (h *RevokedPrivStreamHandle) Stdout() io.Reader
- func (h *RevokedPrivStreamHandle) Wait(ctx context.Context) (execution.ExecutionOutcome, error)
- type RevokedRemoteFS
- func (r *RevokedRemoteFS) Chmod(ctx context.Context, p pathalg.RemotePath, perm fs.FileMode) error
- func (r *RevokedRemoteFS) Chtimes(ctx context.Context, p pathalg.RemotePath, atime, mtime time.Time) error
- func (r *RevokedRemoteFS) Close() error
- func (r *RevokedRemoteFS) Lstat(ctx context.Context, p pathalg.RemotePath) (out ports.RemoteFileStat, err error)
- func (r *RevokedRemoteFS) MkdirAll(ctx context.Context, dir pathalg.RemotePath, perm fs.FileMode) error
- func (r *RevokedRemoteFS) ReadChunk(ctx context.Context, p pathalg.RemotePath, offset int64, dst io.Writer, ...) (int64, error)
- func (r *RevokedRemoteFS) ReadDir(ctx context.Context, dir pathalg.RemotePath) ([]ports.RemoteDirEntry, error)
- func (r *RevokedRemoteFS) ReadLink(ctx context.Context, p pathalg.RemotePath) (string, error)
- func (r *RevokedRemoteFS) RealPath(ctx context.Context, p pathalg.RemotePath) (out pathalg.RemotePath, err error)
- func (r *RevokedRemoteFS) Remove(ctx context.Context, p pathalg.RemotePath) error
- func (r *RevokedRemoteFS) RemoveDir(ctx context.Context, dir pathalg.RemotePath) error
- func (r *RevokedRemoteFS) RenameAtomic(ctx context.Context, oldPath, newPath pathalg.RemotePath, ...) error
- func (r *RevokedRemoteFS) Revoke()
- func (r *RevokedRemoteFS) Stat(ctx context.Context, p pathalg.RemotePath) (out ports.RemoteFileStat, err error)
- func (r *RevokedRemoteFS) WithReadFile(ctx context.Context, p pathalg.RemotePath, limits ports.ReadLimits, ...) error
- func (r *RevokedRemoteFS) WriteChunk(ctx context.Context, p pathalg.RemotePath, offset int64, rd io.Reader, ...) error
- func (r *RevokedRemoteFS) WriteFileAtomic(ctx context.Context, p pathalg.RemotePath, spec ports.RemoteWriteSpec, ...) (out ports.RemoteFileStat, err error)
- type SSHAgent
- func (a *SSHAgent) AddKey(pub ports.PublicKeyInfo)
- func (a *SSHAgent) DialAgent(ctx context.Context, spec algebraic.Option[inventory.AgentSpec]) (net.Conn, error)
- func (b *SSHAgent) Faults() *memtree.FaultInjector
- func (a *SSHAgent) ListAgentKeys(ctx context.Context, spec algebraic.Option[inventory.AgentSpec]) ([]ports.PublicKeyInfo, error)
- func (a *SSHAgent) SetAvailable(en bool)
- func (a *SSHAgent) SignWithAgent(ctx context.Context, spec algebraic.Option[inventory.AgentSpec], ...) (out ports.Signature, err error)
- type ShellProbe
- type TerminalPort
- func (t *TerminalPort) CanSuspendProcessGroup() (v security.Verdict, err error)
- func (b *TerminalPort) Faults() *memtree.FaultInjector
- func (t *TerminalPort) IsInteractive() bool
- func (t *TerminalPort) Output() []byte
- func (t *TerminalPort) QueueResize(sizes ...ports.TerminalSize)
- func (t *TerminalPort) SetBlockInputAfterData(block bool)
- func (t *TerminalPort) SetHandleSuspendErr(err error)
- func (t *TerminalPort) SetInput(data []byte)
- func (t *TerminalPort) SetSuspendResult(v security.Verdict, err error)
- func (t *TerminalPort) Size() (out ports.TerminalSize, err error)
- func (t *TerminalPort) SuspendCount() uint64
- func (t *TerminalPort) WithNativeTTYFiles(ctx context.Context, fn func(stdin, stdout, stderr *ports.NativeTTYFile) error) error
- func (t *TerminalPort) WithRawTerminal(ctx context.Context, fn func(term ports.TerminalHandle) error) error
- type VaultControlRouter
Constants ¶
This section is empty.
Variables ¶
var ErrSimNotInitialized = errors.New("sim: 仿真适配器未初始化")
ErrSimNotInitialized 表示零值或未初始化仿真适配器被调用时的规范失败关闭哨兵错误,由父包 sim 只读重导出保持指针同一性。
var ErrSimulatedENOSPC = errors.New("sim: 模拟磁盘空间不足 (ENOSPC)")
ErrSimulatedENOSPC 表示仿真磁盘空间不足(ENOSPC)故障的不可变哨兵错误,由父包 sim 只读重导出保持指针同一性。
Functions ¶
This section is empty.
Types ¶
type CanonicalResolver ¶
type CanonicalResolver struct {
// contains filtered or unexported fields
}
CanonicalResolver 实现 ports.CanonicalResolverPort 的零网络确定性主机/CNAME 解析仿真器(ADR-019 E1), 支持主机记录、CNAME 链与环路模拟、虚拟时钟延迟与确定性故障注入;零值恒失败关闭。
func NewCanonicalResolver ¶
func NewCanonicalResolver(clk ports.Clock) *CanonicalResolver
NewCanonicalResolver 创建零网络确定性规范化解析仿真器(clk 可为 nil,仅在设置延迟时用于虚拟睡眠)。
func (*CanonicalResolver) CNAMELookupCount ¶
func (r *CanonicalResolver) CNAMELookupCount() uint64
func (*CanonicalResolver) Faults ¶
func (b *CanonicalResolver) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*CanonicalResolver) HostLookupCount ¶
func (r *CanonicalResolver) HostLookupCount() uint64
HostLookupCount / CNAMELookupCount / LookupCount / RecordedQueries 提供零 DNS 副作用与查询序列观测。
func (*CanonicalResolver) LookupCNAME ¶
LookupCNAME 查询主机名对应的 CNAME 规范名(默认单跳便于调用方校验 PermittedCNAMEs;开启 FollowCNAMEChain 时完整追链并防环)。 遵循 ports.CanonicalResolverPort 契约:返回小写且不含末尾 DNS 根点 '.' 的规范主机名 (真实宿主适配器包装标准库 net.Resolver.LookupCNAME 时亦须在端口边界去除末尾 '.')。
func (*CanonicalResolver) LookupCount ¶
func (r *CanonicalResolver) LookupCount() uint64
func (*CanonicalResolver) LookupHost ¶
LookupHost 解析主机名对应地址列表(沿 CNAME 链追查并执行环路与跳数上限防呆,返回防御性副本)。
func (*CanonicalResolver) RecordedQueries ¶
func (r *CanonicalResolver) RecordedQueries() []string
func (*CanonicalResolver) SetCNAME ¶
func (r *CanonicalResolver) SetCNAME(host, target string)
SetCNAME 注册或清空单跳 CNAME 映射(host -> target)。
func (*CanonicalResolver) SetCNAMEChain ¶
func (r *CanonicalResolver) SetCNAMEChain(names ...string)
SetCNAMEChain 按顺序批量注册多跳 CNAME 链(names[0] -> names[1] -> ... -> names[n-1])。
func (*CanonicalResolver) SetCNAMELoop ¶
func (r *CanonicalResolver) SetCNAMELoop(names ...string)
SetCNAMELoop 注册首尾闭环的 CNAME 环路(names[0] -> ... -> names[n-1] -> names[0]),用于验证防环截断。
func (*CanonicalResolver) SetFollowCNAMEChain ¶
func (r *CanonicalResolver) SetFollowCNAMEChain(follow bool)
SetFollowCNAMEChain 控制 LookupCNAME 是返回单跳下一规范名(false,默认,便于调用方逐跳校验与防环)还是递归追链至终点(true)。
func (*CanonicalResolver) SetHost ¶
func (r *CanonicalResolver) SetHost(host string, addrs ...string)
SetHost 注册或清空主机名对应的解析地址列表(不区分大小写,自动归一末尾点号)。
func (*CanonicalResolver) SetHostError ¶
func (r *CanonicalResolver) SetHostError(host string, err error)
SetHostError 为指定主机名注入确定性解析错误(传 nil 清除)。
func (*CanonicalResolver) SetLatency ¶
func (r *CanonicalResolver) SetLatency(d time.Duration)
SetLatency 配置单次查询通过注入 Clock 等待的确定性延迟(<= 0 表示无延迟)。
func (*CanonicalResolver) SetMaxCNAMEHops ¶
func (r *CanonicalResolver) SetMaxCNAMEHops(maxHops int)
SetMaxCNAMEHops 配置解析器内部追链最大跳数上限(<= 0 恢复默认值 16)。
type Clock ¶ added in v1.4.0
type Clock struct {
// contains filtered or unexported fields
}
Clock 提供 100% 确定性并发安全虚拟时钟与定时器调度器(实现 ports.Clock,零 time.Sleep)。
func (*Clock) Faults ¶ added in v1.4.0
func (b *Clock) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*Clock) Now ¶ added in v1.4.0
Now / Since / PendingTimers / Advance / AdvanceToNext / NewTimer / Sleep / WaitPending 驱动虚拟时钟。
func (*Clock) PendingTimers ¶ added in v1.4.0
type DiagnosticSink ¶
type DiagnosticSink struct {
// contains filtered or unexported fields
}
DiagnosticSink 实现 ports.DiagnosticSink 的纯内存确定性诊断接收仿真器(ADR-019 C3), 支持级别过滤、有界容量丢弃计数与记录快照观测;零值恒安全静默忽略。
func NewDiagnosticSink ¶
func NewDiagnosticSink() *DiagnosticSink
NewDiagnosticSink 创建默认接收全部 1..3 级有效诊断记录的纯内存仿真接收器。
func (*DiagnosticSink) Dropped ¶
func (s *DiagnosticSink) Dropped() uint64
Dropped 返回因有界缓冲满载而丢弃的诊断记录总数。
func (*DiagnosticSink) Emit ¶
func (s *DiagnosticSink) Emit(ctx context.Context, rec ports.DiagnosticRecord)
Emit 接收单条脱敏诊断记录;未初始化接收器、nil/已取消 ctx、零值/无效 rec 或超级别记录均安全静默忽略。
func (*DiagnosticSink) Faults ¶
func (b *DiagnosticSink) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*DiagnosticSink) Records ¶
func (s *DiagnosticSink) Records() []ports.DiagnosticRecord
Records 返回当前已记录的诊断快照防御性副本。
func (*DiagnosticSink) SetMaxLevel ¶
func (s *DiagnosticSink) SetMaxLevel(level uint8)
SetMaxLevel 设置接收的最大诊断级别(1..3,越界输入静默忽略)。
func (*DiagnosticSink) SetMaxRecords ¶
func (s *DiagnosticSink) SetMaxRecords(limit int)
SetMaxRecords 设置最大缓冲记录条数(<= 0 表示无上限;超限时新记录丢弃并累加 Dropped)。
type FormatImporter ¶
type FormatImporter struct {
// contains filtered or unexported fields
}
FormatImporter 实现 ports.FormatImporter,将 CSV 行(alias,addr,port,user)解析为 ImportBundle。
func NewFormatImporter ¶
func NewFormatImporter(format string) *FormatImporter
NewFormatImporter 创建格式导入仿真器(空格式名默认 "csv")。
func (*FormatImporter) Faults ¶
func (b *FormatImporter) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*FormatImporter) Format ¶
func (i *FormatImporter) Format() string
type Forwarder ¶
type Forwarder struct {
// contains filtered or unexported fields
}
Forwarder 实现 ports.ForwarderPort,返回持留池钉选传输的 *memtree.ForwardHandle(满足 pool.ManagedResource)。
func (*Forwarder) Faults ¶
func (b *Forwarder) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*Forwarder) LastBindOptions ¶
func (f *Forwarder) LastBindOptions() (out ports.ForwardBindOptions)
LastBindOptions 返回最近一次通过参数校验的 StartForward 绑定选项快照(供单测断言策略透传闭环)。
func (*Forwarder) StartForward ¶
func (f *Forwarder) StartForward(ctx context.Context, transport ports.TunnelTransport, spec ports.ForwardSpec, opts ports.ForwardBindOptions) (ports.ForwardHandle, error)
StartForward 启动单条受管隧道转发并持留非借用 transport 直至 ForwardHandle.Close()(支持启动后持续打开新通道)。
type HostTrust ¶
type HostTrust struct {
// contains filtered or unexported fields
}
HostTrust 实现按 Endpoint (Host, Port) 严格隔离的主机密钥信任库仿真器(INV-E2)。
func (*HostTrust) Faults ¶
func (b *HostTrust) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*HostTrust) PreferredAlgorithms ¶
func (*HostTrust) RecordHostKey ¶
func (t *HostTrust) RecordHostKey(ctx context.Context, ep netaddr.Endpoint, key ports.PublicKeyInfo, _ option.KnownHostsList) error
func (*HostTrust) RevokeKey ¶
func (t *HostTrust) RevokeKey(fp inventory.KeyFingerprint)
RevokeKey 吊销指定主机公钥指纹,后续核验将返回 HostTrustRevoked。
func (*HostTrust) VerifyHostKey ¶
func (t *HostTrust) VerifyHostKey(ctx context.Context, req ports.HostTrustRequest) (out ports.HostTrustCheck, err error)
type InventoryStore ¶
type InventoryStore struct {
// contains filtered or unexported fields
}
InventoryStore 实现 ports.InventoryStore,支持 CAS 并发冲突与不确定落盘结果注入。
func NewInventoryStore ¶
func NewInventoryStore(initial inventory.Graph) (*InventoryStore, error)
NewInventoryStore 以初始资产图(无效时自动构造空有效图)创建存储仿真器。
func (*InventoryStore) CommitCAS ¶
func (s *InventoryStore) CommitCAS(ctx context.Context, expected ports.Revision, next inventory.Graph) (out ports.DurabilityOutcome, err error)
func (*InventoryStore) Faults ¶
func (b *InventoryStore) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*InventoryStore) InjectNextDurability ¶
func (s *InventoryStore) InjectNextDurability(out ports.DurabilityOutcome)
InjectNextDurability 注入下一次 CommitCAS 的持久化结果(如 Applied&&!Durable 或 Unknown)。
func (*InventoryStore) Load ¶
func (s *InventoryStore) Load(ctx context.Context) (out ports.InventorySnapshot, err error)
type JournalStore ¶
type JournalStore struct {
// contains filtered or unexported fields
}
JournalStore 实现 ports.JournalStore 的纯内存确定性双代传输 WAL 仿真器(支持按代隔离与单侧损坏注入)。
func (*JournalStore) Append ¶
func (s *JournalStore) Append(ctx context.Context, rec fsm.TransferJournalRecord) error
func (*JournalStore) CorruptGeneration ¶
func (s *JournalStore) CorruptGeneration(id security.OperationID, generation uint64, cause error)
CorruptGeneration 将指定 (transferID, generation) 标记为损坏态以供双代损坏隔离崩溃恢复测试。
func (*JournalStore) Delete ¶
func (s *JournalStore) Delete(ctx context.Context, id security.OperationID) error
func (*JournalStore) Faults ¶
func (b *JournalStore) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*JournalStore) ListActive ¶
func (s *JournalStore) ListActive(ctx context.Context) ([]security.OperationID, error)
func (*JournalStore) Load ¶
func (s *JournalStore) Load(ctx context.Context, id security.OperationID) (out []fsm.TransferJournalRecord, err error)
func (*JournalStore) LoadGenerations ¶
func (s *JournalStore) LoadGenerations(ctx context.Context, id security.OperationID) ([]ports.JournalGenerationSnapshot, error)
func (*JournalStore) PruneGeneration ¶
func (s *JournalStore) PruneGeneration(ctx context.Context, id security.OperationID, generation uint64) error
type KeySigner ¶
type KeySigner struct {
// contains filtered or unexported fields
}
KeySigner 实现 ports.KeySignerPort 的确定性签名与指纹查询仿真器。
func NewKeySigner ¶
func NewKeySigner(keys ...ports.PublicKeyInfo) *KeySigner
NewKeySigner 创建预置公钥的密钥签名仿真器。
func (*KeySigner) AddKey ¶
func (s *KeySigner) AddKey(pub ports.PublicKeyInfo, keyPath string)
AddKey 注册公钥及其可选私钥路径映射(未注册路径查询时返回 ErrNotFound)。
func (*KeySigner) Faults ¶
func (b *KeySigner) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*KeySigner) InspectPrivateKeyFingerprint ¶
func (*KeySigner) ListPublicKeys ¶
func (s *KeySigner) ListPublicKeys(ctx context.Context, auth inventory.AuthMethod) ([]ports.PublicKeyInfo, error)
type OpenSSHConfigSource ¶ added in v1.4.0
type OpenSSHConfigSource struct {
// contains filtered or unexported fields
}
OpenSSHConfigSource 实现 ports.OpenSSHConfigSource 与具名可选接口 ports.CanonicalOpenSSHConfigSource 的虚拟主机与两轮 Tier-4 选项折叠仿真器。
func NewOpenSSHConfigSource ¶ added in v1.4.0
func NewOpenSSHConfigSource(hosts ...ports.OpenSSHVirtualHost) *OpenSSHConfigSource
NewOpenSSHConfigSource 创建预置虚拟主机的 OpenSSHConfigSource 仿真器。
func (*OpenSSHConfigSource) Faults ¶ added in v1.4.0
func (b *OpenSSHConfigSource) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*OpenSSHConfigSource) LastResolveOptions ¶ added in v1.4.0
func (s *OpenSSHConfigSource) LastResolveOptions() ports.Tier4ResolveOptions
LastResolveOptions 与 ResolveCount 返回最近一次 Tier-4 折叠选项与调用次数(供单测观测)。
func (*OpenSSHConfigSource) ListVirtualHosts ¶ added in v1.4.0
func (s *OpenSSHConfigSource) ListVirtualHosts(ctx context.Context) ([]ports.OpenSSHVirtualHost, error)
func (*OpenSSHConfigSource) ResolveCount ¶ added in v1.4.0
func (s *OpenSSHConfigSource) ResolveCount() int
func (*OpenSSHConfigSource) ResolveTier4 ¶ added in v1.4.0
func (s *OpenSSHConfigSource) ResolveTier4(ctx context.Context, target option.OriginalHostSpec, endpoint algebraic.Option[netaddr.Endpoint]) (out option.OptionLayer, err error)
func (*OpenSSHConfigSource) ResolveTier4WithOptions ¶ added in v1.4.0
func (s *OpenSSHConfigSource) ResolveTier4WithOptions( ctx context.Context, target option.OriginalHostSpec, endpoint algebraic.Option[netaddr.Endpoint], opts ports.Tier4ResolveOptions, ) (out option.OptionLayer, err error)
ResolveTier4WithOptions 实现 ports.CanonicalOpenSSHConfigSource,支持 CanonicalPass=true 轮次折叠。
func (*OpenSSHConfigSource) SetCanonicalHosts ¶ added in v1.4.0
func (s *OpenSSHConfigSource) SetCanonicalHosts(hosts ...ports.OpenSSHVirtualHost)
SetCanonicalHosts 配置仅在 CanonicalPass == true(OpenSSH post_canon=1)轮次参与折叠的虚拟主机规则。
type OperatorReadFS ¶ added in v1.4.0
type OperatorReadFS struct {
// contains filtered or unexported fields
}
OperatorReadFS 实现 ports.OperatorReadFS 的人工只读源内存仿真器(复用 memtree.Tree)。
func NewOperatorReadFS ¶ added in v1.4.0
func NewOperatorReadFS() *OperatorReadFS
NewOperatorReadFS 创建空白的操作员只读源仿真器。
func (*OperatorReadFS) Faults ¶ added in v1.4.0
func (b *OperatorReadFS) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*OperatorReadFS) PutFile ¶ added in v1.4.0
func (o *OperatorReadFS) PutFile(p pathalg.LocalSourcePath, data []byte) error
PutFile 与 PutSymlink 注册仿真只读常规文件与符号链接夹具。
func (*OperatorReadFS) PutSymlink ¶ added in v1.4.0
func (o *OperatorReadFS) PutSymlink(linkPath, targetPath pathalg.LocalSourcePath) error
func (*OperatorReadFS) WithOperatorRead ¶ added in v1.4.0
func (o *OperatorReadFS) WithOperatorRead(ctx context.Context, srcPath pathalg.LocalSourcePath, policy pathalg.SymlinkPolicy, fn func(r ports.BoundedReadHandle, size int64) error) error
WithOperatorRead 按 SymlinkPolicy 逐段解析并打开只读源,在同步闭包内借出受哨兵保护的随机读取句柄。
type ProcessHandler ¶
type ProcessHandler func(ctx context.Context, spec ports.ProcessSpec, stdin []byte) (ports.ProcessResult, error)
ProcessHandler 定义 ProcessPort 的可编程命令处理回调。
type ProcessPort ¶
type ProcessPort struct {
// contains filtered or unexported fields
}
ProcessPort 是零 os/exec 的纯内存子进程与 stdio 管道仿真器,实现 ports.ProcessPort。
func NewProcessPort ¶
func NewProcessPort() *ProcessPort
NewProcessPort 创建纯内存子进程仿真器("fail"/"false" 返回退出码 1,其余默认回显 stdin)。
func (*ProcessPort) DialStdio ¶
func (p *ProcessPort) DialStdio(ctx context.Context, spec ports.ProcessSpec) (net.Conn, error)
func (*ProcessPort) Faults ¶
func (b *ProcessPort) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*ProcessPort) RegisterCommand ¶
func (p *ProcessPort) RegisterCommand(cmd string, fn ProcessHandler)
RegisterCommand 注册或注销指定命令名的自定义处理回调。
func (*ProcessPort) Run ¶
func (p *ProcessPort) Run(ctx context.Context, spec ports.ProcessSpec, stdin io.Reader) (out ports.ProcessResult, err error)
type RemoteFS ¶ added in v1.4.0
type RemoteFS struct {
// contains filtered or unexported fields
}
RemoteFS 是纯内存远端 POSIX/SFTP 文件系统仿真器(ADR-016,仅使用 path 包,支持中间目录软链解析、(dev,ino) 锚点与原子子树重命名)。
func NewRemoteFS ¶ added in v1.4.0
NewRemoteFS 创建预置根目录 "/" 的远端 POSIX 文件系统仿真器。
func (*RemoteFS) Faults ¶ added in v1.4.0
func (b *RemoteFS) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*RemoteFS) Lstat ¶ added in v1.4.0
func (r *RemoteFS) Lstat(ctx context.Context, p pathalg.RemotePath) (ports.RemoteFileStat, error)
func (*RemoteFS) PutSymlink ¶ added in v1.4.0
func (r *RemoteFS) PutSymlink(linkPath pathalg.RemotePath, target string) error
func (*RemoteFS) ReadChunk ¶ added in v1.4.0
func (r *RemoteFS) ReadChunk(ctx context.Context, p pathalg.RemotePath, offset int64, dst io.Writer, length int64) (int64, error)
ReadChunk 从远端常规文件 offset 处读取至多 length 字节写入 dst;读满返回 (length, nil),遇 EOF 返回 (实际字节数, io.EOF)。
func (*RemoteFS) ReadDir ¶ added in v1.4.0
func (r *RemoteFS) ReadDir(ctx context.Context, dir pathalg.RemotePath) (out []ports.RemoteDirEntry, err error)
func (*RemoteFS) RealPath ¶ added in v1.4.0
func (r *RemoteFS) RealPath(ctx context.Context, p pathalg.RemotePath) (out pathalg.RemotePath, err error)
func (*RemoteFS) RenameAtomic ¶ added in v1.4.0
func (r *RemoteFS) RenameAtomic(ctx context.Context, oldPath, newPath pathalg.RemotePath, spec ports.RemoteRenameSpec) error
func (*RemoteFS) Stat ¶ added in v1.4.0
func (r *RemoteFS) Stat(ctx context.Context, p pathalg.RemotePath) (ports.RemoteFileStat, error)
func (*RemoteFS) WithReadFile ¶ added in v1.4.0
func (r *RemoteFS) WithReadFile(ctx context.Context, p pathalg.RemotePath, limits ports.ReadLimits, fn func(rd io.Reader, size int64) error) error
WithReadFile 在 limits 上限内以同步闭包借出远端文件只读流。
func (*RemoteFS) WriteChunk ¶ added in v1.4.0
func (*RemoteFS) WriteFileAtomic ¶ added in v1.4.0
func (r *RemoteFS) WriteFileAtomic(ctx context.Context, p pathalg.RemotePath, spec ports.RemoteWriteSpec, src io.Reader) (out ports.RemoteFileStat, err error)
type RemoteSession ¶
type RemoteSession struct {
// contains filtered or unexported fields
}
RemoteSession 实现 ports.RemoteSession 及具名可选接口 ports.SubsystemRemoteSession、 ports.DirectTTYRemoteSession(ADR-019 A2 / C1 / D3),内部复用 memtree.RemoteSession 管道互斥与 生命周期状态机,补充 StartSubsystem、DirectNativeTTY、ForwardAgent 与 EscapeChar 观测。
func NewRemoteSession ¶
func NewRemoteSession(aliveFn func() bool, cfg memtree.SessionFaultConfig, onClose func()) *RemoteSession
NewRemoteSession 构造绑定至底层连接探活回调、故障配置与可选关闭计数回调的纯内存远端会话。
func (*RemoteSession) BeginStartLocked ¶
func (s *RemoteSession) BeginStartLocked(streams ports.ExecStreams) error
BeginStartLocked 委托底层 memtree.RemoteSession 执行持锁状态复核。
func (*RemoteSession) Close ¶
func (s *RemoteSession) Close() error
func (*RemoteSession) LastEscapeChar ¶
func (s *RemoteSession) LastEscapeChar() algebraic.Option[option.EscapeCharSpec]
LastEscapeChar 返回最近一次会话启动请求携带的可选 EscapeChar 规格(供单测断言)。
func (*RemoteSession) LastForwardAgent ¶
func (s *RemoteSession) LastForwardAgent() algebraic.Option[inventory.AgentSpec]
LastForwardAgent 返回最近一次会话启动请求携带的可选 ForwardAgent 规格(供单测断言)。
func (*RemoteSession) LastSubsystem ¶
func (s *RemoteSession) LastSubsystem() string
LastSubsystem 返回最近一次通过 StartSubsystem 启动的子系统名称(供单测断言)。
func (*RemoteSession) ResizePTY ¶
func (s *RemoteSession) ResizePTY(ctx context.Context, size ports.TerminalSize) error
func (*RemoteSession) SetDirectNativeTTY ¶
func (s *RemoteSession) SetDirectNativeTTY(enabled bool)
SetDirectNativeTTY 配置该仿真会话是否模拟原生 OpenSSH ControlMaster 控制终端 FD 直通模式(默认 false)。
func (*RemoteSession) Signal ¶
func (s *RemoteSession) Signal(ctx context.Context, sig string) error
func (*RemoteSession) Start ¶
func (s *RemoteSession) Start(ctx context.Context, cmd execution.CommandPlan, streams ports.ExecStreams) error
func (*RemoteSession) StartShell ¶
func (s *RemoteSession) StartShell(ctx context.Context, streams ports.ExecStreams) error
func (*RemoteSession) StartSubsystem ¶
func (s *RemoteSession) StartSubsystem(ctx context.Context, subsystem string, streams ports.ExecStreams) error
StartSubsystem 实现 ports.SubsystemRemoteSession,校验非空合法子系统名、ForwardAgent 与 EscapeChar 规格, 保持与管道互斥及单次启动一致契约,并记录启动子系统名供仿真测试观测。
func (*RemoteSession) StderrPipe ¶
func (s *RemoteSession) StderrPipe() (io.Reader, error)
func (*RemoteSession) StdinPipe ¶
func (s *RemoteSession) StdinPipe() (io.WriteCloser, error)
func (*RemoteSession) StdoutPipe ¶
func (s *RemoteSession) StdoutPipe() (io.Reader, error)
func (*RemoteSession) UsesDirectNativeTTY ¶
func (s *RemoteSession) UsesDirectNativeTTY() bool
UsesDirectNativeTTY 实现 ports.DirectTTYRemoteSession;未初始化零值失败关闭返回 false。
func (*RemoteSession) Wait ¶
func (s *RemoteSession) Wait(ctx context.Context) (execution.ExecutionOutcome, error)
type RevokedPrivStreamHandle ¶ added in v1.4.0
type RevokedPrivStreamHandle struct {
// contains filtered or unexported fields
}
RevokedPrivStreamHandle 是带原子吊销哨兵的仿真提权流句柄,实现 ports.PrivilegedStreamHandle; 退出作用域后 Stdin/Stdout/Stderr 读写关闭与控制面调用均失败关闭返回 ports.ErrHandleExpired。
func NewRevokedPrivStreamHandle ¶ added in v1.4.0
func NewRevokedPrivStreamHandle(outcome execution.ExecutionOutcome) *RevokedPrivStreamHandle
NewRevokedPrivStreamHandle 构造绑定终态结果的可吊销仿真提权流句柄。
func (*RevokedPrivStreamHandle) ResizePTY ¶ added in v1.4.0
func (h *RevokedPrivStreamHandle) ResizePTY(ctx context.Context, size ports.TerminalSize) error
func (*RevokedPrivStreamHandle) Revoke ¶ added in v1.4.0
func (h *RevokedPrivStreamHandle) Revoke()
Revoke 不可逆吊销句柄,使后续全部读写、关闭与控制面调用均返回 ports.ErrHandleExpired。
func (*RevokedPrivStreamHandle) Signal ¶ added in v1.4.0
func (h *RevokedPrivStreamHandle) Signal(ctx context.Context, sig string) error
func (*RevokedPrivStreamHandle) Stderr ¶ added in v1.4.0
func (h *RevokedPrivStreamHandle) Stderr() io.Reader
func (*RevokedPrivStreamHandle) Stdin ¶ added in v1.4.0
func (h *RevokedPrivStreamHandle) Stdin() io.WriteCloser
func (*RevokedPrivStreamHandle) Stdout ¶ added in v1.4.0
func (h *RevokedPrivStreamHandle) Stdout() io.Reader
func (*RevokedPrivStreamHandle) Wait ¶ added in v1.4.0
func (h *RevokedPrivStreamHandle) Wait(ctx context.Context) (execution.ExecutionOutcome, error)
type RevokedRemoteFS ¶ added in v1.4.0
type RevokedRemoteFS struct {
// contains filtered or unexported fields
}
RevokedRemoteFS 是退出即吊销的 ports.RemoteFSPort 仿真包装视图;吊销后全量方法(含 Close)返回 ports.ErrHandleExpired。
func NewRevokedRemoteFS ¶ added in v1.4.0
func NewRevokedRemoteFS(inner ports.RemoteFSPort) *RevokedRemoteFS
NewRevokedRemoteFS 构造包装 inner 的可吊销 RemoteFSPort 仿真视图。
func (*RevokedRemoteFS) Chmod ¶ added in v1.4.0
func (r *RevokedRemoteFS) Chmod(ctx context.Context, p pathalg.RemotePath, perm fs.FileMode) error
func (*RevokedRemoteFS) Chtimes ¶ added in v1.4.0
func (r *RevokedRemoteFS) Chtimes(ctx context.Context, p pathalg.RemotePath, atime, mtime time.Time) error
func (*RevokedRemoteFS) Close ¶ added in v1.4.0
func (r *RevokedRemoteFS) Close() error
func (*RevokedRemoteFS) Lstat ¶ added in v1.4.0
func (r *RevokedRemoteFS) Lstat(ctx context.Context, p pathalg.RemotePath) (out ports.RemoteFileStat, err error)
func (*RevokedRemoteFS) MkdirAll ¶ added in v1.4.0
func (r *RevokedRemoteFS) MkdirAll(ctx context.Context, dir pathalg.RemotePath, perm fs.FileMode) error
func (*RevokedRemoteFS) ReadDir ¶ added in v1.4.0
func (r *RevokedRemoteFS) ReadDir(ctx context.Context, dir pathalg.RemotePath) ([]ports.RemoteDirEntry, error)
func (*RevokedRemoteFS) ReadLink ¶ added in v1.4.0
func (r *RevokedRemoteFS) ReadLink(ctx context.Context, p pathalg.RemotePath) (string, error)
func (*RevokedRemoteFS) RealPath ¶ added in v1.4.0
func (r *RevokedRemoteFS) RealPath(ctx context.Context, p pathalg.RemotePath) (out pathalg.RemotePath, err error)
func (*RevokedRemoteFS) Remove ¶ added in v1.4.0
func (r *RevokedRemoteFS) Remove(ctx context.Context, p pathalg.RemotePath) error
func (*RevokedRemoteFS) RemoveDir ¶ added in v1.4.0
func (r *RevokedRemoteFS) RemoveDir(ctx context.Context, dir pathalg.RemotePath) error
func (*RevokedRemoteFS) RenameAtomic ¶ added in v1.4.0
func (r *RevokedRemoteFS) RenameAtomic(ctx context.Context, oldPath, newPath pathalg.RemotePath, spec ports.RemoteRenameSpec) error
func (*RevokedRemoteFS) Revoke ¶ added in v1.4.0
func (r *RevokedRemoteFS) Revoke()
Revoke 不可逆吊销视图,使后续全部 RemoteFSPort 调用返回 ports.ErrHandleExpired。
func (*RevokedRemoteFS) Stat ¶ added in v1.4.0
func (r *RevokedRemoteFS) Stat(ctx context.Context, p pathalg.RemotePath) (out ports.RemoteFileStat, err error)
func (*RevokedRemoteFS) WithReadFile ¶ added in v1.4.0
func (r *RevokedRemoteFS) WithReadFile(ctx context.Context, p pathalg.RemotePath, limits ports.ReadLimits, fn func(rd io.Reader, size int64) error) error
func (*RevokedRemoteFS) WriteChunk ¶ added in v1.4.0
func (r *RevokedRemoteFS) WriteChunk(ctx context.Context, p pathalg.RemotePath, offset int64, rd io.Reader, length int64) error
func (*RevokedRemoteFS) WriteFileAtomic ¶ added in v1.4.0
func (r *RevokedRemoteFS) WriteFileAtomic(ctx context.Context, p pathalg.RemotePath, spec ports.RemoteWriteSpec, rd io.Reader) (out ports.RemoteFileStat, err error)
type SSHAgent ¶
type SSHAgent struct {
// contains filtered or unexported fields
}
SSHAgent 实现 ports.SSHAgentPort 的纯内存 SSH Agent 通道、公钥列举与签名仿真器。
func NewSSHAgent ¶
func NewSSHAgent(keys ...ports.PublicKeyInfo) *SSHAgent
NewSSHAgent 创建预置公钥且默认可用的 SSH Agent 仿真器。
func (*SSHAgent) AddKey ¶
func (a *SSHAgent) AddKey(pub ports.PublicKeyInfo)
func (*SSHAgent) Faults ¶
func (b *SSHAgent) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*SSHAgent) ListAgentKeys ¶
func (*SSHAgent) SetAvailable ¶
SetAvailable / AddKey 控制 Agent 可达状态与已加载公钥。
type ShellProbe ¶
type ShellProbe struct {
// contains filtered or unexported fields
}
ShellProbe 实现 ports.ShellProbePort 的两阶段远端 Shell 探测仿真器。
func NewShellProbe ¶
func NewShellProbe(result ports.ShellProbeResult) *ShellProbe
NewShellProbe 创建返回指定探测快照的仿真器(若传入零值则默认 POSIX sh 阶段 1 结果)。
func (*ShellProbe) Faults ¶
func (b *ShellProbe) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*ShellProbe) ProbeShell ¶
func (p *ShellProbe) ProbeShell( ctx context.Context, opener ports.SessionOpener, ) (out ports.ShellProbeResult, err error)
ProbeShell 借用 SessionOpener 执行确定性远端 Shell 探测(参数级 //xops:borrowed 静态审计零逃逸)。
func (*ShellProbe) SetResult ¶
func (p *ShellProbe) SetResult(res ports.ShellProbeResult)
SetResult 更新仿真探测返回结果。
type TerminalPort ¶ added in v1.4.0
type TerminalPort struct {
// contains filtered or unexported fields
}
TerminalPort 实现 ports.TerminalPort 与具名可选接口 ports.NativeTTYFDProvider 的纯内存仿真器, 其 WithRawTerminal 借出句柄同时实现 ports.SuspendableTerminalHandle。
func NewTerminalPort ¶ added in v1.4.0
func NewTerminalPort(interactive bool, cols, rows uint16) *TerminalPort
NewTerminalPort 创建纯内存终端仿真器(cols/rows 为 0 时默认 80x24)。
func (*TerminalPort) CanSuspendProcessGroup ¶ added in v1.4.0
func (t *TerminalPort) CanSuspendProcessGroup() (v security.Verdict, err error)
func (*TerminalPort) Faults ¶ added in v1.4.0
func (b *TerminalPort) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*TerminalPort) IsInteractive ¶ added in v1.4.0
func (t *TerminalPort) IsInteractive() bool
func (*TerminalPort) Output ¶ added in v1.4.0
func (t *TerminalPort) Output() []byte
func (*TerminalPort) QueueResize ¶ added in v1.4.0
func (t *TerminalPort) QueueResize(sizes ...ports.TerminalSize)
func (*TerminalPort) SetBlockInputAfterData ¶ added in v1.4.0
func (t *TerminalPort) SetBlockInputAfterData(block bool)
func (*TerminalPort) SetHandleSuspendErr ¶ added in v1.4.0
func (t *TerminalPort) SetHandleSuspendErr(err error)
func (*TerminalPort) SetInput ¶ added in v1.4.0
func (t *TerminalPort) SetInput(data []byte)
func (*TerminalPort) SetSuspendResult ¶ added in v1.4.0
func (t *TerminalPort) SetSuspendResult(v security.Verdict, err error)
SetSuspendResult / SetHandleSuspendErr / SuspendCount / SetInput / SetBlockInputAfterData / QueueResize / Output 配置测试夹具并观测终端状态。
func (*TerminalPort) Size ¶ added in v1.4.0
func (t *TerminalPort) Size() (out ports.TerminalSize, err error)
func (*TerminalPort) SuspendCount ¶ added in v1.4.0
func (t *TerminalPort) SuspendCount() uint64
func (*TerminalPort) WithNativeTTYFiles ¶ added in v1.4.0
func (t *TerminalPort) WithNativeTTYFiles(ctx context.Context, fn func(stdin, stdout, stderr *ports.NativeTTYFile) error) error
WithNativeTTYFiles 实现具名可选接口 ports.NativeTTYFDProvider;纯内存终端无真实 OS TTY 句柄,校验参数后失败关闭返回 ErrUnsupported。
func (*TerminalPort) WithRawTerminal ¶ added in v1.4.0
func (t *TerminalPort) WithRawTerminal(ctx context.Context, fn func(term ports.TerminalHandle) error) error
WithRawTerminal 在同步作用域内借出带失效哨兵、双向 Relay 与可挂起能力(SuspendableTerminalHandle)的 TerminalHandle,退出时关闭 ResizeEvents。
type VaultControlRouter ¶
type VaultControlRouter struct {
// contains filtered or unexported fields
}
VaultControlRouter 实现 ports.VaultControlRouter,按存储名路由至多个独立 VaultControlPort 仿真控制器(ADR-018)。
func NewVaultControlRouter ¶
func NewVaultControlRouter(stores map[string]ports.VaultControlPort) (*VaultControlRouter, error)
NewVaultControlRouter 构造按存储名路由的多库控制面仿真器;可选预注册 stores 映射。
func (*VaultControlRouter) ControlFor ¶
func (r *VaultControlRouter) ControlFor(store string) (ports.VaultControlPort, error)
ControlFor 按存储名路由并返回对应的 VaultControlPort(实现 ports.VaultControlRouter)。
func (*VaultControlRouter) ControlledStores ¶
func (r *VaultControlRouter) ControlledStores() []string
ControlledStores 返回按字典序升序排列的已注册存储名防御性副本(实现 ports.VaultControlRouter)。
func (*VaultControlRouter) Faults ¶
func (b *VaultControlRouter) Faults() *memtree.FaultInjector
Faults 返回适配器关联的并发安全确定性故障注入器;零值未初始化返回 nil。
func (*VaultControlRouter) Register ¶
func (r *VaultControlRouter) Register(store string, ctrl ports.VaultControlPort) error
Register 登记或替换指定存储名对应的 VaultControlPort 控制器(拒绝非法存储名或 nil 控制器)。