Documentation
¶
Overview ¶
Package assembly 承担 core/engine 构造期(Engine.New)与运行期底层基础设施的组件装配与依赖接线职责: 包括主机密钥信任只读观测器(HostTrustObserver)、默认协议端口补齐(sshnet/*)、 拨号器适配链(ControlMaster 复用与可选 RemoteFS 覆写)、ControlMaster 活跃事件桥接(MuxActivityHub)、 入站原生 OpenSSH Mux 晚绑定门控授权桥接(NativeMuxAuthHub,ADR-019 D3)、 安全门控接线(BuildGate)、在途操作生命周期管理(OpLifecycle)、6 大用例服务装配, 以及 Engine/MCP 配置规格与公开安全策略值类型(PolicyProfile/NoElicitFallback/SSHPolicyPlan/HaltInfo)。
本包属 LayerCoreEngine 装配与基础设施子包,生产源码严格零导入 core/ports/tck 与 core/internal/sim。
Index ¶
- func BuildGate(in GateWireInput) (*gate.Gate, error)
- func ToPoolConfigInput(cfg Config, d ports.DialerPort, bus *events.SystemBus) engineutil.PoolConfigInput
- func ValidateBaseConfig(cfg Config) (gate.PolicyProfileKind, gate.GuardrailPolicy, error)
- type AssembledServices
- type Config
- type DialContextFunc
- type GateWireInput
- type GuardrailConfig
- type HaltInfo
- type HostTrustObserver
- func (o *HostTrustObserver) Lookup(ep netaddr.Endpoint) (inventory.KeyFingerprint, bool)
- func (o *HostTrustObserver) PreferredAlgorithms(ctx context.Context, ep netaddr.Endpoint, kh option.KnownHostsList) ([]string, error)
- func (o *HostTrustObserver) PreferredAlgorithmsWithGlobal(ctx context.Context, ep netaddr.Endpoint, ...) ([]string, error)
- func (o *HostTrustObserver) RecordHostKey(ctx context.Context, ep netaddr.Endpoint, key ports.PublicKeyInfo, ...) error
- func (o *HostTrustObserver) RecordHostKeyWithHash(ctx context.Context, ep netaddr.Endpoint, key ports.PublicKeyInfo, ...) error
- func (o *HostTrustObserver) VerifyHostKey(ctx context.Context, req ports.HostTrustRequest) (ports.HostTrustCheck, error)
- func (o *HostTrustObserver) VerifyHostKeyWithPolicy(ctx context.Context, req ports.HostTrustRequest, ...) (ports.HostTrustCheck, error)
- type MCPConfig
- type MuxActivityHub
- func (h *MuxActivityHub) Bind(svc *ucsess.Service)
- func (h *MuxActivityHub) Clear()
- func (h *MuxActivityHub) Notify(ctx context.Context, socketAddr string, kind mux.SocketActivityKind)
- func (h *MuxActivityHub) Register(socketPath string, handle plan.ManagedHandle[plan.KindMux], ...)
- func (h *MuxActivityHub) UnregisterHandle(handle plan.ManagedHandle[plan.KindMux])
- type NativeMuxAuthHub
- func (h *NativeMuxAuthHub) BindGate(g *gate.Gate)
- func (h *NativeMuxAuthHub) Clear()
- func (h *NativeMuxAuthHub) MarkMCPAttached()
- func (h *NativeMuxAuthHub) WithAuthorizedSession(ctx context.Context, req mux.NativeSessionRequest, ...) error
- func (h *NativeMuxAuthHub) WithAuthorizedStdioFwd(ctx context.Context, req mux.NativeStdioFwdRequest, ...) error
- type NoElicitFallback
- type OnHaltFunc
- type OpLifecycle
- func (l *OpLifecycle) BeginOp(ctx context.Context) (context.Context, func(), error)
- func (l *OpLifecycle) BeginShutdown(onClose func()) <-chan struct{}
- func (l *OpLifecycle) Cancel(cause error)
- func (l *OpLifecycle) IsClosed() bool
- func (l *OpLifecycle) WaitDrain(ctx context.Context, waitCh <-chan struct{}) error
- func (l *OpLifecycle) WithLock(fn func(closing bool) error) error
- type PolicyProfile
- type PortsWireInput
- type RemoteFSFunc
- type ResolvedPorts
- type SSHPolicyPlan
- func (p SSHPolicyPlan) AutoSpawnControlMaster() bool
- func (p SSHPolicyPlan) EscapeChar() option.EscapeCharSpec
- func (p SSHPolicyPlan) ExitOnForwardFailure() bool
- func (p SSHPolicyPlan) ForkAfterAuth() bool
- func (p SSHPolicyPlan) Forwards() []ports.ForwardSpec
- func (p SSHPolicyPlan) IsValid() bool
- func (p SSHPolicyPlan) IsZero() bool
- func (p SSHPolicyPlan) RemoteCommand() algebraic.Option[string]
- func (p SSHPolicyPlan) RequestTTY() engineutil.RequestTTYMode
- func (p SSHPolicyPlan) SessionType() option.SessionTypeMode
- func (p SSHPolicyPlan) SetEnv() map[string]string
- func (p SSHPolicyPlan) StdinNull() bool
- type ServicesWireInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildGate ¶
func BuildGate(in GateWireInput) (*gate.Gate, error)
BuildGate 构造 gate.Gate 并将不可逆 Halted 熔断回调第一时间接线至 pool.GateHalted(ADR-008/ADR-009), 随后触发调用方可选外部熔断通知。
func ToPoolConfigInput ¶ added in v1.4.0
func ToPoolConfigInput(cfg Config, d ports.DialerPort, bus *events.SystemBus) engineutil.PoolConfigInput
ToPoolConfigInput 将公开 Config 投影为连接池构造输入。
func ValidateBaseConfig ¶ added in v1.4.0
func ValidateBaseConfig(cfg Config) (gate.PolicyProfileKind, gate.GuardrailPolicy, error)
ValidateBaseConfig 校验策略配置档、护栏回退与核心基础设施端口,编译不可变 gate.GuardrailPolicy(任一失败即失败关闭)。
Types ¶
type AssembledServices ¶
type AssembledServices struct {
Inventory *ucinv.Service
Credential *uccred.Service
Session *ucsess.Service
MCPSession *ucsess.Service
Transfer *uctrans.Service
MCPTransfer *uctrans.Service
Automation *ucauto.Service
MCPAutomation *ucauto.Service
Observability *ucobs.Service
}
AssembledServices 保存已完整接线的 6 大用例服务及物理沙箱隔离(0 OperatorReadFS / 0 ForwardAgent)的 MCP 视图。
func AssembleServices ¶
func AssembleServices(in ServicesWireInput) (AssembledServices, error)
AssembleServices 按依赖顺序装配 credential、inventory、session、transfer、automation 与 observability 全部用例服务。
type Config ¶ added in v1.4.0
type Config struct {
Profile PolicyProfile
Guardrail GuardrailConfig
// 核心基础设施端口:Clock / Entropy / AuditSink 为必填(ADR-008 零 nil 逃生口);Reconciler 供启动期 O(1) 崩溃对账。
Clock ports.Clock
Entropy ports.Entropy
AuditSink ports.AuditSink
Reconciler ports.AuditReconciler
// 双模态本地文件系统与主机信任库(未注入 HostTrust 时必须提供 ScopedFS 以装配真实 KnownHostsDB)。
ScopedFS ports.ScopedRootFS
PermissionTightener ports.PermissionTightener // 可选:句柄级最小权限收敛端口(为 nil 且 ScopedFS 实现该端口时自动接线,ADR-020)
OperatorReadFS ports.OperatorReadFS
HostTrust ports.HostTrustPort
KnownHostsDir, HomeDir algebraic.Option[pathalg.LocalDir]
KnownHostsFileName string
KnownHostsMaxBytes int64
HashKnownHosts bool
SSHFPLookup ports.SSHFPLookupPort
// 可选本机/交互/凭据/资产/传输/隧道/复用与底层拨号端口(Phase 3/4 解耦注入槽位)。
Env ports.EnvPort
Terminal ports.TerminalPort
Process ports.ProcessPort
OpenSSH ports.OpenSSHConfigSource
CanonicalResolver ports.CanonicalResolverPort // 可选:只读主机名/CNAME 解析端口,供非离线 CLI 目标两轮规范化(ADR-019 E1)
DiagnosticSink ports.DiagnosticSink // 可选:面向 -v/-vv/-vvv 的轻量脱敏诊断通道(严禁持锁调用,ADR-019 C3)
DisallowForwardAgent bool // 可选:物理禁止 SSH Agent 转发(默认 false;strict_agent/MCP 自动强制 true,ADR-019 A2)
Interaction ports.InteractionPort
Vault ports.SecretVault
KeySigner ports.KeySignerPort // 为 nil 且已注入 OperatorReadFS/Agent 时默认装配真实 sshnet/dial.NewKeySigner
Agent ports.SSHAgentPort
VaultControl ports.VaultControlPort
VaultControlRouter ports.VaultControlRouter // 可选:按存储名路由的多离线凭据库控制面路由器(与 VaultControl 向后兼容共存)
RequireExplicitVaultStore bool // 可选:为 true 且 VaultControl==nil 时,缺省空 Store 强制返回 ErrInvalidRequest 要求显式 --store
VaultUnlockConfigSyncer uccred.VaultUnlockConfigSyncer // 可选:Rewrap 切换解锁模式后 CAS 同步持久化配置(ADR-020)
DefaultVaultStore string // 可选:默认凭据库逻辑名称(供 Rewrap 配置同步与 DoctorFix 使用)
DoctorConfigDir algebraic.Option[pathalg.LocalDir]
DoctorConfigFile algebraic.Option[pathalg.LocalRootedDest]
DoctorVaultDirs []uccred.VaultDirSpec
DoctorRunDir algebraic.Option[pathalg.LocalDir]
InventoryStore ports.InventoryStore
JournalStore ports.JournalStore
Importers []ports.FormatImporter
KnownStores []string
DefaultEnrollTTL algebraic.Option[algebraic.Duration]
DefaultExecution algebraic.Option[execution.LaunchProfile] // 可选:全局默认远端启动配置(6 级 execution 继承链 Global 层)
LegacyConfigDetectedPath string // 可选:由组合根经无条件文件名级只读 Lstat 双通道探测注入的旧版配置路径提示(无论 config.yaml 是否存在均注入供 Doctor 共存诊断;纯数据,引擎不触旧文件)
PrivilegeEscalation ports.PrivilegeEscalationPort // 为 nil 时默认装配真实 sshnet/priv.NewEscalator
PrivilegedRemoteFS ports.PrivilegedRemoteFSPort // 为 nil 且 Escalator 满足 PrivilegedStreamPort 时默认装配 sshnet/sftp.NewPrivilegedRemoteFSOpener(ADR-020)
ShellProbe ports.ShellProbePort // 为 nil 时默认装配真实 sshnet/probe.NewProber
Forwarder ports.ForwarderPort // 为 nil 时默认装配真实 sshnet/forward.NewForwarder
TUNDevice ports.TUNDevicePort
MuxSocket ports.MuxSocketPort // 为 nil 时默认装配真实 sshnet/mux.NewMuxSocket
Dialer ports.DialerPort // 为 nil 时默认装配真实 sshnet/dial(含 sftp.Open)+ sshnet/hostkey
RemoteFS RemoteFSFunc // 仅用于外部自定义/仿真 Dialer 覆写 OpenRemoteFS;真实路径由 BuildDialerPort 注入 sftp.Open
// 拨号、全局选项、跳板深度、转发安全开关、限流分片、事件总线与连接池调优参数(全可选,0/false/None 取安全失败关闭默认值)。
DialContext DialContextFunc
ClientVersion string
GlobalOptions option.OptionLayer
ForwardAllowGatewayPorts, ForwardReplaceStaleUnix bool // 默认 false:遵循 GatewayPorts=no 且不自动接管过期本地 Unix 转发套接字
MaxJumpDepth, TransferDefaultConcurrency, AutomationDefaultConcurrency int
TransferDefaultChunkSize, TransferDefaultMaxReadBytes int64
AutomationMaxScriptBytes, AutomationMaxTemplateBytes, AutomationMaxCopyBytes int64
SystemBus *events.SystemBus
SystemBusBuffer, PoolAcquireBuffer, PoolMaxConns, PoolMaxHandles int
PoolTeardownGrace, PoolIdleTTL, PoolKeepaliveInterval algebraic.Option[algebraic.Duration]
OnHalt OnHaltFunc // 熔断后触发至多一次(位于 pool.GateHalted 之后)
}
Config 定义 Engine 的全显式依赖注入配置(零全局单例、零隐式 OS/环境变量读取);由父包 core/engine 以类型别名重导出。
type DialContextFunc ¶
DialContextFunc 与 RemoteFSFunc 定义底层网络拨号与外置自定义/仿真传输的远端文件系统工厂签名,用于构造底层拨号适配链; 由父包 core/engine 以类型别名重导出。注意:RemoteFSFunc 仅接收协议无关的 ports.TransportConn(不可访问未导出 *ssh.Client), 专用于自定义或仿真 Dialer 覆写;真实 sshnet/sftp 已在 BuildDialerPort 中直接经 dial.Config.OpenRemoteFS 注入 sftp.Open。
type GateWireInput ¶
type GateWireInput struct {
Profile gate.PolicyProfileKind
Policy gate.GuardrailPolicy
AuditSink ports.AuditSink
Reconciler ports.AuditReconciler
Interaction ports.InteractionPort
Clock ports.Clock
Entropy ports.Entropy
SystemBus *events.SystemBus
Pool *pool.Pool
OnHalt func(gate.HaltInfo)
}
GateWireInput 封装构造 Engine 内部安全门控与连接池熔断联动所需的全部构造期参数。
type GuardrailConfig ¶ added in v1.4.0
type GuardrailConfig struct {
ApprovalThreshold security.RiskLevel // 必填:全局基础审批风险阈值(如 RiskModerate)
NoElicitFallback NoElicitFallback // 不可交互审批回退策略(零值为 Deny)
NodeOverrides algebraic.Option[security.NodeOverrides] // 可选:节点通配符覆写格
BlockedCommands algebraic.Option[security.BlockedCommandMatcher] // 可选:已编译 UTF-8 Glob 命令黑名单匹配器(Some(零值) 失败关闭)
BlockedPatterns []string // 可选:原始 UTF-8 Glob 命令黑名单模式串(与 BlockedCommands 并半格收紧合并)
ProtectedRules []pathalg.ProtectedRule // 可选:已编译受保护路径规则
ProtectedPatterns []string // 可选:原始受保护路径模式串
ProtectedPathRisk algebraic.Option[security.RiskLevel] // 可选:命中受保护路径最低风险(默认 RiskDangerous)
ApprovalTTL algebraic.Option[algebraic.Duration] // 可选:审批信封有效期(默认 5m)
MaxPendingChallenges, MaxReplayHistory int // 可选:挂起审批挑战与防重放容量
}
GuardrailConfig 描述 Engine 内部能力门控(gate.GuardrailPolicy)的公开构造规格; 所有时长字段统一使用 algebraic.Duration,零值默认触发失败关闭校验。由父包 core/engine 以类型别名重导出。
type HaltInfo ¶ added in v1.4.0
type HaltInfo struct {
// contains filtered or unexported fields
}
HaltInfo 描述 Engine 底层安全门控首次进入不可逆 Halted 熔断态时的只读诊断快照(ADR-008);零值恒无效并失败关闭。 由父包 core/engine 以类型别名零拷贝重导出。
func HaltInfoFromGate ¶ added in v1.4.0
HaltInfoFromGate 将门控层熔断快照包装为公开 HaltInfo(无效输入返回失败关闭零值)。
func (HaltInfo) OperationID ¶ added in v1.4.0
func (h HaltInfo) OperationID() algebraic.Option[security.OperationID]
type HostTrustObserver ¶
type HostTrustObserver struct {
// contains filtered or unexported fields
}
HostTrustObserver 在 ports.HostTrustPort 外层只读记录最近经校验通过或合法登记的 (Endpoint -> KeyFingerprint), 遇冲突或吊销立即驱逐旧记录,支撑 INV-F2 首连暂存探测返回真实服务端指纹(零伪造)。
func BuildDialerPort ¶
func BuildDialerPort(in PortsWireInput, rp ResolvedPorts) (ports.DialerPort, *HostTrustObserver, error)
BuildDialerPort 构造完整拨号器链(含主机信任观测器、透明 ControlMaster 客户端复用与可选 RemoteFS 覆写)。
func NewHostTrustObserver ¶
func NewHostTrustObserver(inner ports.HostTrustPort) *HostTrustObserver
NewHostTrustObserver 包装底层 HostTrustPort 并建立主机指纹只读观测表。
func (*HostTrustObserver) Lookup ¶
func (o *HostTrustObserver) Lookup(ep netaddr.Endpoint) (inventory.KeyFingerprint, bool)
Lookup 查询指定端点最近观测到的可信服务端主机密钥指纹。
func (*HostTrustObserver) PreferredAlgorithms ¶
func (o *HostTrustObserver) PreferredAlgorithms(ctx context.Context, ep netaddr.Endpoint, kh option.KnownHostsList) ([]string, error)
PreferredAlgorithms 透传至底层主机信任库。
func (*HostTrustObserver) PreferredAlgorithmsWithGlobal ¶
func (o *HostTrustObserver) PreferredAlgorithmsWithGlobal(ctx context.Context, ep netaddr.Endpoint, userKH, globalKH option.KnownHostsList) ([]string, error)
PreferredAlgorithmsWithGlobal 在底层主机信任库支持只读全局 known_hosts 时透传查询,否则回退用户 known_hosts 查询。
func (*HostTrustObserver) RecordHostKey ¶
func (o *HostTrustObserver) RecordHostKey(ctx context.Context, ep netaddr.Endpoint, key ports.PublicKeyInfo, kh option.KnownHostsList) error
RecordHostKey 透传记录已知主机密钥并在成功时缓存其指纹。
func (*HostTrustObserver) RecordHostKeyWithHash ¶
func (o *HostTrustObserver) RecordHostKeyWithHash(ctx context.Context, ep netaddr.Endpoint, key ports.PublicKeyInfo, kh option.KnownHostsList, hashHostnames bool) error
RecordHostKeyWithHash 在底层主机信任库支持单次 hash_known_hosts 策略时透传落盘并同步缓存其指纹。
func (*HostTrustObserver) VerifyHostKey ¶
func (o *HostTrustObserver) VerifyHostKey(ctx context.Context, req ports.HostTrustRequest) (ports.HostTrustCheck, error)
VerifyHostKey 透传校验并按结果更新或驱逐观测缓存。
func (*HostTrustObserver) VerifyHostKeyWithPolicy ¶
func (o *HostTrustObserver) VerifyHostKeyWithPolicy(ctx context.Context, req ports.HostTrustRequest, globalKH option.KnownHostsList, verifyDNS option.VerifyHostKeyDNSMode) (ports.HostTrustCheck, error)
VerifyHostKeyWithPolicy 在底层主机信任库支持全局 known_hosts 与 VerifyHostKeyDNS 策略时透传校验并同步更新观测缓存。
type MCPConfig ¶ added in v1.4.0
type MCPConfig struct {
ServerName, ServerVersion, Instructions string
TransferRoot, ArtifactRoot algebraic.Option[pathalg.LocalDir]
MaxMessageBytes, HTTPChunkSize int64
MaxTrackedHandles, MaxHTTPSessions, MaxAuthConcurrency int
AllowNonLoopbackHTTP, PruneSupersededJournals, FailOnCorruptJournal, AllowOptionalReconciler bool
PublicURL string
TokenVerifier func(ctx context.Context, token []byte) (bool, error)
HTTPAllowedOrigins, HTTPAllowedHosts []string
HTTPReadHeaderTimeout, HTTPShutdownTimeout algebraic.Option[algebraic.Duration]
}
MCPConfig 定义从 Engine 派生 MCPServer 时的安全传输与沙箱参数(物理零 OperatorReadFS);由父包 core/engine 以类型别名重导出。
type MuxActivityHub ¶
type MuxActivityHub struct {
// contains filtered or unexported fields
}
MuxActivityHub 将默认 sshnet/mux 控制套接字上的客户端进入/活跃/离开与监听关闭事件 安全桥接至 session.Service.TouchControlMasterActivity,保活活跃会话并在监听退出时零泄漏清理索引。
func NewMuxActivityHub ¶
func NewMuxActivityHub() *MuxActivityHub
NewMuxActivityHub 构造初始为空的 ControlMaster 控制套接字活跃事件桥接器。
func (*MuxActivityHub) Bind ¶
func (h *MuxActivityHub) Bind(svc *ucsess.Service)
Bind 绑定负责接收保活续期通知的 session.Service 实例。
func (*MuxActivityHub) Notify ¶
func (h *MuxActivityHub) Notify(ctx context.Context, socketAddr string, kind mux.SocketActivityKind)
Notify 响应 sshnet/mux 回调:监听关闭时无条件清理索引,其余活跃事件转发至 session.Service 保活。
func (*MuxActivityHub) Register ¶
func (h *MuxActivityHub) Register(socketPath string, handle plan.ManagedHandle[plan.KindMux], doneCh <-chan struct{})
Register 登记套接字路径与 ManagedHandle[KindMux] 的映射;若 doneCh 已关闭则跳过登记以规避快速退出竞态残留。
func (*MuxActivityHub) UnregisterHandle ¶
func (h *MuxActivityHub) UnregisterHandle(handle plan.ManagedHandle[plan.KindMux])
UnregisterHandle 按句柄精确注销其关联的全部控制套接字映射条目。
type NativeMuxAuthHub ¶
type NativeMuxAuthHub struct {
// contains filtered or unexported fields
}
NativeMuxAuthHub 是入站原生 OpenSSH PROTOCOL.mux v4(NEW_SESSION / NEW_STDIO_FWD)的原子晚绑定作用域门控授权中心(ADR-019 v2.2 S3-Q3):
- 解决 ResolveDefaultPorts 早于 BuildGate 与 NewMCPServer 的构造顺序,且与 Engine 级 DisallowForwardAgent 解耦(由单实例 MuxServeOptions 独立管控 want_agent);
- 仅当 Engine 为 PolicyProfileDirectOperator、未附着任何 MCPServer 且 Gate 未熔断时放行;
- 每次放行强制经 //xops:syncclosure 同步作用域回调 gate.WithAuthorized[CapExecute|CapTunnel] 包裹完整执行生命周期, 携带单实例 (NodeID, Endpoint, PlanDigest) 强制生效 NodeOverrides 拒绝规则与 blocked_patterns 校验, 并在真实会话/转发退出后通过 auth.ReportOutcome 落盘终态审计与 .lock 注销(维持 O(1) 崩溃对账)。
func NewNativeMuxAuthHub ¶
func NewNativeMuxAuthHub(allowNative bool) *NativeMuxAuthHub
NewNativeMuxAuthHub 构造初始未绑定 Gate(默认失败关闭)的原生 Mux 授权晚绑定桥接器。
func (*NativeMuxAuthHub) BindGate ¶
func (h *NativeMuxAuthHub) BindGate(g *gate.Gate)
BindGate 在 BuildGate 完成后原子绑定权威 Gate 实例。
func (*NativeMuxAuthHub) Clear ¶
func (h *NativeMuxAuthHub) Clear()
Clear 在 Engine 停机阶段永久关闭并清空 Gate 引用,确保后续入站请求严格失败关闭。
func (*NativeMuxAuthHub) MarkMCPAttached ¶
func (h *NativeMuxAuthHub) MarkMCPAttached()
MarkMCPAttached 在 MCPServer 完成校验与登记后不可逆置位,立即对全部入站原生 OpenSSH Mux 请求失败关闭。
func (*NativeMuxAuthHub) WithAuthorizedSession ¶
func (h *NativeMuxAuthHub) WithAuthorizedSession( ctx context.Context, req mux.NativeSessionRequest, run func(authCtx context.Context) (execution.ExecutionOutcome, error), ) error
WithAuthorizedSession 以同步作用域闭包授权并包裹入站原生 OpenSSH MUX_C_NEW_SESSION 完整生命周期, 携带单实例 (NodeID, Endpoint, PlanDigest) 强制经 CapExecute、NodeOverrides 与 blocked_patterns 校验, 执行完毕后经 auth.ReportOutcome 上报真实 ExecutionOutcome 并在退出闭包时落盘 AuditPhaseFinalized。
func (*NativeMuxAuthHub) WithAuthorizedStdioFwd ¶
func (h *NativeMuxAuthHub) WithAuthorizedStdioFwd( ctx context.Context, req mux.NativeStdioFwdRequest, run func(authCtx context.Context) error, ) error
WithAuthorizedStdioFwd 以同步作用域闭包授权并包裹入站原生 OpenSSH MUX_C_NEW_STDIO_FWD 完整生命周期, 携带单实例 (NodeID, Endpoint, PlanDigest) 强制经 CapTunnel 与 NodeOverrides 校验, 执行完毕后方退出 gate.WithAuthorized 落盘 AuditPhaseFinalized 与 .lock 注销。
type NoElicitFallback ¶ added in v1.4.0
type NoElicitFallback uint8
NoElicitFallback 定义护栏要求人工审批但运行环境不可交互时的回退行为;零值恒为 Deny(失败关闭)。 由父包 core/engine 以类型别名零拷贝重导出。
const ( NoElicitFallbackDeny NoElicitFallback = iota // 零值失败关闭:不可交互时直接拒绝并写入审计 NoElicitFallbackChallenge // 两步挑战模式:签发绑定审批信封供调用方二次提交核验 )
func ParseNoElicitFallback ¶ added in v1.4.0
func ParseNoElicitFallback(raw string) (NoElicitFallback, error)
func (NoElicitFallback) AppendText ¶ added in v1.4.0
func (f NoElicitFallback) AppendText(b []byte) ([]byte, error)
func (NoElicitFallback) IsValid ¶ added in v1.4.0
func (f NoElicitFallback) IsValid() bool
func (NoElicitFallback) IsZero ¶ added in v1.4.0
func (f NoElicitFallback) IsZero() bool
func (NoElicitFallback) MarshalText ¶ added in v1.4.0
func (f NoElicitFallback) MarshalText() ([]byte, error)
func (NoElicitFallback) String ¶ added in v1.4.0
func (f NoElicitFallback) String() string
func (*NoElicitFallback) UnmarshalText ¶ added in v1.4.0
func (f *NoElicitFallback) UnmarshalText(t []byte) error
type OnHaltFunc ¶ added in v1.4.0
type OnHaltFunc func(info HaltInfo)
OnHaltFunc 是 Engine 进入不可逆 Halted 熔断态且已通知连接池吊销全部句柄后触发至多一次的可选外部回调。
type OpLifecycle ¶
type OpLifecycle struct {
// contains filtered or unexported fields
}
OpLifecycle 管理 Engine 在途操作的取消桥接、并发排空计数与停机状态锁;零值恒失败关闭。
func (*OpLifecycle) BeginShutdown ¶
func (l *OpLifecycle) BeginShutdown(onClose func()) <-chan struct{}
BeginShutdown 原子置 closing=true、持锁执行 onClose 收集派生资源,并返回可选的在途排空通道。
func (*OpLifecycle) Cancel ¶
func (l *OpLifecycle) Cancel(cause error)
Cancel 触发生命周期根上下文取消,用于 Engine 停机或构造失败回滚。
type PolicyProfile ¶ added in v1.4.0
type PolicyProfile uint8
PolicyProfile 标识 Engine 能力门控的安全策略配置档(RFC §3.1 / §4.2 / ADR-008);零值恒失败关闭。 由父包 core/engine 以类型别名零拷贝重导出。
const ( PolicyProfileInvalid PolicyProfile = iota // 零值无效配置档(失败关闭默认态) PolicyProfileDirectOperator // CLI 直接人工操作员模式(保留审计闭环与显式 Deny 拦截) PolicyProfileStrictOperator // CLI 严格护栏模式(--policy=strict) PolicyProfileStrictAgent // MCP / AI Agent 严格熔断模式(终态审计失败立即 Halted) )
func ParsePolicyProfile ¶ added in v1.4.0
func ParsePolicyProfile(raw string) (PolicyProfile, error)
ParsePolicyProfile / ParseNoElicitFallback 严格解析公开枚举文本(零堆分配)。
func (PolicyProfile) AppendText ¶ added in v1.4.0
func (p PolicyProfile) AppendText(b []byte) ([]byte, error)
func (PolicyProfile) IsValid ¶ added in v1.4.0
func (p PolicyProfile) IsValid() bool
PolicyProfile / NoElicitFallback 只读校验、文本序列化与内部映射方法。
func (PolicyProfile) IsZero ¶ added in v1.4.0
func (p PolicyProfile) IsZero() bool
func (PolicyProfile) MarshalText ¶ added in v1.4.0
func (p PolicyProfile) MarshalText() ([]byte, error)
func (PolicyProfile) String ¶ added in v1.4.0
func (p PolicyProfile) String() string
func (*PolicyProfile) UnmarshalText ¶ added in v1.4.0
func (p *PolicyProfile) UnmarshalText(t []byte) error
type PortsWireInput ¶
type PortsWireInput struct {
Clock ports.Clock
Entropy ports.Entropy
ScopedFS ports.ScopedRootFS
OperatorReadFS ports.OperatorReadFS
HostTrust ports.HostTrustPort
KnownHostsDir algebraic.Option[pathalg.LocalDir]
HomeDir algebraic.Option[pathalg.LocalDir]
KnownHostsFileName string
KnownHostsMaxBytes int64
HashKnownHosts bool
SSHFPLookup ports.SSHFPLookupPort
Env ports.EnvPort
Terminal ports.TerminalPort
Process ports.ProcessPort
Interaction ports.InteractionPort
Vault ports.SecretVault
KeySigner ports.KeySignerPort
Agent ports.SSHAgentPort
DiagnosticSink ports.DiagnosticSink
DisallowForwardAgent bool
GlobalOptions option.OptionLayer
AllowNativeUncheckedSessions bool
NativeMuxAuth *NativeMuxAuthHub
PrivilegeEscalation ports.PrivilegeEscalationPort
PrivilegedRemoteFS ports.PrivilegedRemoteFSPort
ShellProbe ports.ShellProbePort
Forwarder ports.ForwarderPort
TUNDevice ports.TUNDevicePort
MuxSocket ports.MuxSocketPort
Dialer ports.DialerPort
RemoteFS RemoteFSFunc
DialContext DialContextFunc
ClientVersion string
ForwardAllowGatewayPorts bool
ForwardReplaceStaleUnix bool
OnMuxSocketActivity func(context.Context, string, mux.SocketActivityKind)
}
PortsWireInput 封装装配默认协议端口与真实拨号链所需的全量配置参数。
func ToPortsWireInput ¶ added in v1.4.0
func ToPortsWireInput(cfg Config, activity *MuxActivityHub, disallowFA, allowNative bool, nativeAuth *NativeMuxAuthHub) PortsWireInput
ToPortsWireInput 将公开 Config 投影为默认协议端口与真实拨号链装配输入。
type RemoteFSFunc ¶
type RemoteFSFunc func(ctx context.Context, conn ports.TransportConn) (ports.RemoteFSPort, error)
DialContextFunc 与 RemoteFSFunc 定义底层网络拨号与外置自定义/仿真传输的远端文件系统工厂签名,用于构造底层拨号适配链; 由父包 core/engine 以类型别名重导出。注意:RemoteFSFunc 仅接收协议无关的 ports.TransportConn(不可访问未导出 *ssh.Client), 专用于自定义或仿真 Dialer 覆写;真实 sshnet/sftp 已在 BuildDialerPort 中直接经 dial.Config.OpenRemoteFS 注入 sftp.Open。
type ResolvedPorts ¶
type ResolvedPorts struct {
KeySigner ports.KeySignerPort
Escalator ports.PrivilegeEscalationPort
PrivilegedRemoteFS ports.PrivilegedRemoteFSPort
ShellProbe ports.ShellProbePort
Forwarder ports.ForwarderPort
MCPForwarder ports.ForwarderPort
MuxSocket ports.MuxSocketPort
}
ResolvedPorts 保存经默认补齐后的全部协议出站端口实例(含物理隔离的 MCPForwarder)。
func ResolveDefaultPorts ¶
func ResolveDefaultPorts(in PortsWireInput) (rp ResolvedPorts, err error)
ResolveDefaultPorts 为未显式注入的可选协议端口装配真实 sshnet/* 生产默认实现。
type SSHPolicyPlan ¶ added in v1.4.0
type SSHPolicyPlan struct {
// contains filtered or unexported fields
}
SSHPolicyPlan 封装从 option.EffectivePolicy 投影得到的不可变显式 CLI ssh 激活规划(零 core/internal 依赖); 零值恒无效并严格失败关闭。由父包 core/engine 以类型别名零拷贝重导出。
func SSHPolicyPlanFromSession ¶ added in v1.4.0
func SSHPolicyPlanFromSession(p ucsess.SSHPolicyPlan) SSHPolicyPlan
SSHPolicyPlanFromSession 将会话用例层激活规划包装为公开 SSHPolicyPlan(无效输入返回失败关闭零值)。
func (SSHPolicyPlan) AutoSpawnControlMaster ¶ added in v1.4.0
func (p SSHPolicyPlan) AutoSpawnControlMaster() bool
func (SSHPolicyPlan) EscapeChar ¶ added in v1.4.0
func (p SSHPolicyPlan) EscapeChar() option.EscapeCharSpec
func (SSHPolicyPlan) ExitOnForwardFailure ¶ added in v1.4.0
func (p SSHPolicyPlan) ExitOnForwardFailure() bool
func (SSHPolicyPlan) ForkAfterAuth ¶ added in v1.4.0
func (p SSHPolicyPlan) ForkAfterAuth() bool
func (SSHPolicyPlan) Forwards ¶ added in v1.4.0
func (p SSHPolicyPlan) Forwards() []ports.ForwardSpec
func (SSHPolicyPlan) IsValid ¶ added in v1.4.0
func (p SSHPolicyPlan) IsValid() bool
SSHPolicyPlan 零值安全只读访问器(切片与映射均返回防御性拷贝)。
func (SSHPolicyPlan) IsZero ¶ added in v1.4.0
func (p SSHPolicyPlan) IsZero() bool
func (SSHPolicyPlan) RemoteCommand ¶ added in v1.4.0
func (p SSHPolicyPlan) RemoteCommand() algebraic.Option[string]
func (SSHPolicyPlan) RequestTTY ¶ added in v1.4.0
func (p SSHPolicyPlan) RequestTTY() engineutil.RequestTTYMode
func (SSHPolicyPlan) SessionType ¶ added in v1.4.0
func (p SSHPolicyPlan) SessionType() option.SessionTypeMode
func (SSHPolicyPlan) SetEnv ¶ added in v1.4.0
func (p SSHPolicyPlan) SetEnv() map[string]string
func (SSHPolicyPlan) StdinNull ¶ added in v1.4.0
func (p SSHPolicyPlan) StdinNull() bool
type ServicesWireInput ¶
type ServicesWireInput struct {
Gate *gate.Gate
Pool *pool.Pool
Bus *events.SystemBus
Clock ports.Clock
Entropy ports.Entropy
ScopedFS ports.ScopedRootFS
PermissionTightener ports.PermissionTightener
OperatorReadFS ports.OperatorReadFS
Env ports.EnvPort
Terminal ports.TerminalPort
Process ports.ProcessPort
OpenSSH ports.OpenSSHConfigSource
CanonicalResolver ports.CanonicalResolverPort
DiagnosticSink ports.DiagnosticSink
DisallowForwardAgent bool
Interaction ports.InteractionPort
Vault ports.SecretVault
VaultControl ports.VaultControlPort
VaultControlRouter ports.VaultControlRouter
RequireExplicitVaultStore bool
VaultUnlockConfigSyncer uccred.VaultUnlockConfigSyncer
DefaultVaultStore string
DoctorConfigDir algebraic.Option[pathalg.LocalDir]
DoctorConfigFile algebraic.Option[pathalg.LocalRootedDest]
DoctorVaultDirs []uccred.VaultDirSpec
DoctorRunDir algebraic.Option[pathalg.LocalDir]
InventoryStore ports.InventoryStore
JournalStore ports.JournalStore
Importers []ports.FormatImporter
KnownStores []string
DefaultEnrollTTL algebraic.Option[algebraic.Duration]
DefaultExecution algebraic.Option[execution.LaunchProfile]
LegacyConfigDetectedPath string
TUNDevice ports.TUNDevicePort
GlobalOptions option.OptionLayer
MaxJumpDepth int
TransferDefaultConcurrency int
TransferDefaultChunkSize int64
TransferDefaultMaxReadBytes int64
AutomationDefaultConcurrency int
AutomationMaxScriptBytes int64
AutomationMaxTemplateBytes int64
AutomationMaxCopyBytes int64
Ports ResolvedPorts
}
ServicesWireInput 封装装配 Engine 全部 6 大用例服务所需的运行期依赖与参数。
func ToServicesWireInput ¶ added in v1.4.0
func ToServicesWireInput(cfg Config, g *gate.Gate, p *pool.Pool, bus *events.SystemBus, rp ResolvedPorts, disallowFA bool) ServicesWireInput
ToServicesWireInput 将公开 Config 与已建门控、连接池、事件总线投影为 6 大用例服务装配输入。