Documentation
¶
Overview ¶
Package plan 提供 XOps v2 纯函数领域核的 Merkle 链式连接计划与世代句柄模型。
本包恪守 100% 纯数学与零副作用铁律(零 os、零 net、零 context、零 sync/sync/atomic、零反射):
- HopDigest 与 PlanDigest:不透明 32 字节 SHA-256 摘要值对象(常量时间 Equal + TextAppender);
- TransportPolicySpec 与 HopSpec:冻结每跳连接安全与传输策略投影(零明文凭据), 全部经 //xops:canonicalhash 由 xopsvet/digestcover 在编译期静态验证 WriteCanonical 100% 全字段覆盖;
- SealedConnectionPlan:不可变多跳 Merkle 链式连接计划,上游任意跳板变动均必然级联刷新全部下游 HopDigest 与 PlanDigest,保障连接池缓存隔离与共享堡垒机前缀安全复用(INV-C1 / ADR-009);
- ManagedHandle[K]:按封闭句柄类别 K 参数化的世代句柄(id、gen>=1、planDigest、binding、valid), 零值失败关闭,阻断跨类别、陈旧世代或绑定漂移重放。
Index ¶
- Variables
- func AuthMethodDigest(auth inventory.AuthMethod) (security.Digest, error)
- type HandleID
- func (id HandleID) AppendText(b []byte) ([]byte, error)
- func (id HandleID) Compare(o HandleID) int
- func (id HandleID) Equal(o HandleID) bool
- func (id HandleID) IsValid() bool
- func (id HandleID) IsZero() bool
- func (id HandleID) MarshalText() ([]byte, error)
- func (id HandleID) String() string
- func (id *HandleID) UnmarshalText(text []byte) error
- type HandleKind
- type HandleKindCode
- type HopDigest
- func (d HopDigest) AppendText(b []byte) ([]byte, error)
- func (d HopDigest) Bytes() ([sha256.Size]byte, bool)
- func (d HopDigest) Compare(other HopDigest) int
- func (d HopDigest) Equal(other HopDigest) bool
- func (d HopDigest) Hex() string
- func (d HopDigest) IsValid() bool
- func (d HopDigest) IsZero() bool
- func (d HopDigest) MarshalText() ([]byte, error)
- func (d HopDigest) SecurityDigest() security.Digest
- func (d HopDigest) String() string
- func (d *HopDigest) UnmarshalText(text []byte) error
- type HopSpec
- func (h HopSpec) Auth() inventory.AuthMethod
- func (h HopSpec) AuthDigest() security.Digest
- func (h HopSpec) AuthKind() inventory.AuthMethodKind
- func (h HopSpec) CanonicalHost() algebraic.Option[netaddr.CanonicalHost]
- func (h HopSpec) EffectiveDialEndpoint() netaddr.Endpoint
- func (h HopSpec) Endpoint() netaddr.Endpoint
- func (h HopSpec) Equal(o HopSpec) bool
- func (h HopSpec) HopIndex() uint32
- func (h HopSpec) IsValid() bool
- func (h HopSpec) IsZero() bool
- func (h HopSpec) MarshalJSONTo(enc *jsontext.Encoder) error
- func (h HopSpec) NodeID() string
- func (h HopSpec) Origin() option.OriginKind
- func (h HopSpec) OriginalHost() option.OriginalHostSpec
- func (h HopSpec) ResolvedEndpoint() algebraic.Option[netaddr.Endpoint]
- func (h HopSpec) StripForIntermediateHop() HopSpec
- func (h HopSpec) Transport() TransportPolicySpec
- func (h *HopSpec) UnmarshalJSONFrom(dec *jsontext.Decoder) error
- func (h HopSpec) Username() option.Username
- func (h HopSpec) WithFrozenCanonical(canonicalHost algebraic.Option[netaddr.CanonicalHost], ...) (HopSpec, error)
- func (h HopSpec) WriteCanonical(w io.Writer) error
- type HopSpecInput
- type KindMux
- type KindPTY
- type KindSession
- type KindTransfer
- type KindTunnel
- type ManagedHandle
- func (h ManagedHandle[K]) AppendText(b []byte) ([]byte, error)
- func (h ManagedHandle[K]) Binding() security.OperationBinding
- func (h ManagedHandle[K]) Equal(o ManagedHandle[K]) bool
- func (h ManagedHandle[K]) Generation() uint64
- func (h ManagedHandle[K]) ID() HandleID
- func (h ManagedHandle[K]) IsValid() bool
- func (h ManagedHandle[K]) IsZero() bool
- func (h ManagedHandle[K]) Kind() HandleKindCode
- func (h ManagedHandle[K]) MarshalJSONTo(enc *jsontext.Encoder) error
- func (h ManagedHandle[K]) MarshalText() ([]byte, error)
- func (h ManagedHandle[K]) MatchesGeneration(gen uint64) bool
- func (h ManagedHandle[K]) MatchesPlan(pd PlanDigest) bool
- func (h ManagedHandle[K]) PlanDigest() PlanDigest
- func (h ManagedHandle[K]) String() string
- func (h *ManagedHandle[K]) UnmarshalJSONFrom(dec *jsontext.Decoder) error
- func (h ManagedHandle[K]) WriteCanonical(w io.Writer) error
- type PlanDigest
- func (d PlanDigest) AppendText(b []byte) ([]byte, error)
- func (d PlanDigest) Bytes() ([sha256.Size]byte, bool)
- func (d PlanDigest) Compare(other PlanDigest) int
- func (d PlanDigest) Equal(other PlanDigest) bool
- func (d PlanDigest) Hex() string
- func (d PlanDigest) IsValid() bool
- func (d PlanDigest) IsZero() bool
- func (d PlanDigest) MarshalText() ([]byte, error)
- func (d PlanDigest) SecurityDigest() security.Digest
- func (d PlanDigest) String() string
- func (d *PlanDigest) UnmarshalText(text []byte) error
- type SealedConnectionPlan
- func (p SealedConnectionPlan) CanonicalJSON() ([]byte, error)
- func (p SealedConnectionPlan) Equal(o SealedConnectionPlan) bool
- func (p SealedConnectionPlan) HopAt(index int) (HopSpec, bool)
- func (p SealedConnectionPlan) HopDigestAt(index int) (HopDigest, bool)
- func (p SealedConnectionPlan) HopDigests() []HopDigest
- func (p SealedConnectionPlan) HopSlice() []HopSpec
- func (p SealedConnectionPlan) Hops() algebraic.NonEmpty[HopSpec]
- func (p SealedConnectionPlan) IsValid() bool
- func (p SealedConnectionPlan) IsZero() bool
- func (p SealedConnectionPlan) Len() int
- func (p SealedConnectionPlan) MarshalJSONTo(enc *jsontext.Encoder) error
- func (p SealedConnectionPlan) PlanDigest() PlanDigest
- func (p SealedConnectionPlan) Prefix(count int) (SealedConnectionPlan, error)
- func (p SealedConnectionPlan) Target() (HopSpec, bool)
- func (p *SealedConnectionPlan) UnmarshalJSONFrom(dec *jsontext.Decoder) error
- func (p SealedConnectionPlan) WithoutForwardAgent() (SealedConnectionPlan, error)
- func (p SealedConnectionPlan) WithoutLeafControlPolicy() (SealedConnectionPlan, error)
- func (p SealedConnectionPlan) WriteCanonical(w io.Writer) error
- type TransportPolicySpec
- func (t TransportPolicySpec) AddressFamily() option.AddressFamily
- func (t TransportPolicySpec) BatchMode() bool
- func (t TransportPolicySpec) CertificateFiles() option.PathList
- func (t TransportPolicySpec) Ciphers() []string
- func (t TransportPolicySpec) ConnectTimeout() algebraic.Option[algebraic.Duration]
- func (t TransportPolicySpec) ControlPolicy() option.ControlPolicy
- func (t TransportPolicySpec) Equal(o TransportPolicySpec) bool
- func (t TransportPolicySpec) ForwardAgent() bool
- func (t TransportPolicySpec) GlobalKnownHostsFiles() option.KnownHostsList
- func (t TransportPolicySpec) HashKnownHosts() bool
- func (t TransportPolicySpec) HostKeyAlgos() []string
- func (t TransportPolicySpec) IdentitiesOnly() bool
- func (t TransportPolicySpec) IdentityAgent() algebraic.Option[option.IdentityAgentSpec]
- func (t TransportPolicySpec) IdentityFiles() option.PathList
- func (t TransportPolicySpec) IsValid() bool
- func (t TransportPolicySpec) IsZero() bool
- func (t TransportPolicySpec) KbdInteractiveAuthentication() bool
- func (t TransportPolicySpec) KexAlgorithms() []string
- func (t TransportPolicySpec) LocalCommand() algebraic.Option[option.SanitizedCmd]
- func (t TransportPolicySpec) MACs() []string
- func (t TransportPolicySpec) MarshalJSONTo(enc *jsontext.Encoder) error
- func (t TransportPolicySpec) PasswordAuthentication() bool
- func (t TransportPolicySpec) PermitLocalCommand() bool
- func (t TransportPolicySpec) PreferredAuthentications() algebraic.Option[option.PreferredAuthList]
- func (t TransportPolicySpec) ProxyRoute() option.ProxyRoute
- func (t TransportPolicySpec) PubkeyAuthentication() bool
- func (t TransportPolicySpec) SendEnv() option.EnvFilter
- func (t TransportPolicySpec) ServerAliveCountMax() uint32
- func (t TransportPolicySpec) ServerAliveInterval() algebraic.Duration
- func (t TransportPolicySpec) StrictHostKeyChecking() option.StrictHostKeyCheckingMode
- func (t TransportPolicySpec) StripForIntermediateHop() TransportPolicySpec
- func (t TransportPolicySpec) TCPKeepAlive() bool
- func (t *TransportPolicySpec) UnmarshalJSONFrom(dec *jsontext.Decoder) error
- func (t TransportPolicySpec) UserKnownHostsFiles() option.KnownHostsList
- func (t TransportPolicySpec) VerifyHostKeyDNS() option.VerifyHostKeyDNSMode
- func (t TransportPolicySpec) WriteCanonical(w io.Writer) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidDigest = domi18n.Sentinel(domi18n.KeyPlanInvalidDigest) ErrInvalidTransportPolicy = domi18n.Sentinel(domi18n.KeyPlanInvalidTransportPolicy) ErrInvalidHopSpec = domi18n.Sentinel(domi18n.KeyPlanInvalidHopSpec) ErrInvalidConnectionPlan = domi18n.Sentinel(domi18n.KeyPlanInvalidConnectionPlan) ErrTamperedPlanDigest = domi18n.Sentinel(domi18n.KeyPlanTamperedPlanDigest) ErrInvalidHandleKind = domi18n.Sentinel(domi18n.KeyPlanInvalidHandleKind) ErrInvalidHandleID = domi18n.Sentinel(domi18n.KeyPlanInvalidHandleID) ErrInvalidManagedHandle = domi18n.Sentinel(domi18n.KeyPlanInvalidManagedHandle) ErrNilEntropy = domi18n.Sentinel(domi18n.KeyPlanNilEntropy) ErrNilWriter = domi18n.Sentinel(domi18n.KeyPlanNilWriter) ErrNilReceiver = domi18n.Sentinel(domi18n.KeyPlanNilReceiver) )
本包导出的规范哨兵错误,所有非法字段、篡改摘要、JSON null 及零值访问均严格失败关闭。
Functions ¶
func AuthMethodDigest ¶
func AuthMethodDigest(auth inventory.AuthMethod) (security.Digest, error)
AuthMethodDigest 计算 inventory.AuthMethod 的零明文确定性 SHA-256 摘要,供 HopSpec 绑定认证身份。
Types ¶
type HandleID ¶
type HandleID struct {
// contains filtered or unexported fields
}
HandleID 表示跨请求托管资源的不可变唯一槽位标识符;零值恒无效并失败关闭。
func HandleIDFromBytes ¶
HandleIDFromBytes 将 16 字节原始熵确定性编码为 32 位小写十六进制 HandleID。
func NewHandleIDFrom ¶
NewHandleIDFrom 从显式注入的熵源 io.Reader 读取 16 字节构造 HandleID(零隐式 crypto/rand)。
func ParseHandleID ¶
ParseHandleID 校验并构造 HandleID(长度 1..128 的可打印非空白非冒号 ASCII)。
func (HandleID) MarshalText ¶
func (*HandleID) UnmarshalText ¶
type HandleKind ¶
type HandleKind interface {
// contains filtered or unexported methods
}
HandleKind 是长生命周期 SlotMap 世代句柄的编译期封闭幻影类型约束(ADR-009), 借助泛型参数 K 物理隔离 PTY、Tunnel、Transfer、Mux 与 Session 句柄,杜绝跨类别误用。
type HandleKindCode ¶
type HandleKindCode uint8
HandleKindCode 是幻影类型集 HandleKind 对应的可序列化枚举;零值 HandleKindInvalid 失败关闭。
const ( HandleKindInvalid HandleKindCode = iota // 无效句柄类别(零值失败关闭) HandleKindPTY // 对应 KindPTY HandleKindTunnel // 对应 KindTunnel HandleKindTransfer // 对应 KindTransfer HandleKindMux // 对应 KindMux HandleKindSession // 对应 KindSession )
func HandleKindOf ¶
func HandleKindOf[K HandleKind]() HandleKindCode
HandleKindOf 在编译期类型参数 K 与运行期 HandleKindCode 间建立穷尽映射;接口零值返回 HandleKindInvalid。
func ParseHandleKindCode ¶
func ParseHandleKindCode(raw string) (HandleKindCode, error)
ParseHandleKindCode 严格解析规范小写句柄类别(pty/tunnel/transfer/mux/session)。
func (HandleKindCode) AppendText ¶
func (c HandleKindCode) AppendText(b []byte) ([]byte, error)
func (HandleKindCode) IsValid ¶
func (c HandleKindCode) IsValid() bool
func (HandleKindCode) IsZero ¶
func (c HandleKindCode) IsZero() bool
func (HandleKindCode) MarshalText ¶
func (c HandleKindCode) MarshalText() ([]byte, error)
func (HandleKindCode) String ¶
func (c HandleKindCode) String() string
func (*HandleKindCode) UnmarshalText ¶
func (c *HandleKindCode) UnmarshalText(text []byte) error
type HopDigest ¶
type HopDigest struct {
// contains filtered or unexported fields
}
HopDigest 表示多跳 Merkle 连接计划中单跳(含全部上游祖先跳板)的不可变 32 字节 SHA-256 摘要; 零值恒无效,Equal 采用常量时间比较,供连接池按跳隔离与共享前缀复用。
func HopDigestFromSHA256 ¶
HopDigestFromSHA256 将 32 字节 SHA-256 摘要封装为不可变 HopDigest。
func ParseHopDigest ¶
ParseHopDigest 严格解析规范 SHA-256 文本("sha256:<64位小写十六进制>")为 HopDigest。
func (HopDigest) MarshalText ¶
func (HopDigest) SecurityDigest ¶
SecurityDigest 将有效 HopDigest 无损投影为 security.Digest;无效零值返回零值 security.Digest。
func (*HopDigest) UnmarshalText ¶
type HopSpec ¶
type HopSpec struct {
// contains filtered or unexported fields
}
HopSpec 表示多跳 SSH 连接计划中单跳的不可变规范规格(零明文、零反射); 直接内嵌不可变 inventory.AuthMethod 并在构造期派生 authKind 与 authDigest 以杜绝三者漂移, 同时支持冻结 E1 两轮 DNS 规范化 FQDN 与解析终点并参与 Merkle 摘要; 经 //xops:canonicalhash 由 xopsvet/digestcover 校验 WriteCanonical 100% 全字段覆盖。
func NewHopSpec ¶
func NewHopSpec(in HopSpecInput) (HopSpec, error)
NewHopSpec 校验全部单跳规格字段并在内部由 Auth 派生 AuthKind 与 AuthDigest,构造不可变 HopSpec。
func NewHopSpecFromAuth ¶
func NewHopSpecFromAuth(hopIndex uint32, nodeID string, user option.Username, auth inventory.AuthMethod, policy option.EffectivePolicy) (HopSpec, error)
NewHopSpecFromAuth 直接结合已求解 EffectivePolicy 与封闭 AuthMethod 构造不可变 HopSpec。
func NewIntermediateHopSpecFromAuth ¶ added in v1.3.0
func NewIntermediateHopSpecFromAuth(hopIndex uint32, nodeID string, user option.Username, auth inventory.AuthMethod, policy option.EffectivePolicy) (HopSpec, error)
NewIntermediateHopSpecFromAuth 按 INV-D2 剥离全部 Forward/Session/LocalExec 选项后构造中间跳不可变 HopSpec。
func (HopSpec) Auth ¶
func (h HopSpec) Auth() inventory.AuthMethod
func (HopSpec) AuthDigest ¶
func (HopSpec) AuthKind ¶
func (h HopSpec) AuthKind() inventory.AuthMethodKind
func (HopSpec) CanonicalHost ¶ added in v1.3.0
func (h HopSpec) CanonicalHost() algebraic.Option[netaddr.CanonicalHost]
func (HopSpec) EffectiveDialEndpoint ¶ added in v1.3.0
EffectiveDialEndpoint 返回本跳实际拨号终点(存在冻结解析终点时优先使用以防两步审批 DNS 漂移,否则回退 Endpoint)。
func (HopSpec) MarshalJSONTo ¶
MarshalJSONTo 实现 HopSpec 的 json/v2 确定性编码。
func (HopSpec) Origin ¶
func (h HopSpec) Origin() option.OriginKind
func (HopSpec) OriginalHost ¶
func (h HopSpec) OriginalHost() option.OriginalHostSpec
func (HopSpec) ResolvedEndpoint ¶ added in v1.3.0
func (HopSpec) StripForIntermediateHop ¶ added in v1.3.0
StripForIntermediateHop 返回按 INV-D2 剥离全部 Forward/Session/LocalExec 策略后的中间跳 HopSpec 副本。
func (HopSpec) Transport ¶
func (h HopSpec) Transport() TransportPolicySpec
func (*HopSpec) UnmarshalJSONFrom ¶
UnmarshalJSONFrom 实现 HopSpec 的失败关闭 json/v2 解码,强制核验 auth 与派生 auth_kind/auth_digest 一致。
type HopSpecInput ¶
type HopSpecInput struct {
HopIndex uint32
NodeID string
Origin option.OriginKind
Endpoint netaddr.Endpoint
OriginalHost option.OriginalHostSpec
CanonicalHost algebraic.Option[netaddr.CanonicalHost] // 可选:E1 两轮 DNS 规范化冻结的规范 FQDN
ResolvedEndpoint algebraic.Option[netaddr.Endpoint] // 可选:E1 冻结的解析拨号终点(防两步审批 DNS 漂移)
Username option.Username
Auth inventory.AuthMethod
Transport TransportPolicySpec
}
HopSpecInput 是构造不可变 HopSpec 的显式入参规格(仅携带零明文 inventory.AuthMethod,内部派生 AuthKind 与 AuthDigest 防止漂移)。
type KindMux ¶
type KindMux struct {
// contains filtered or unexported fields
}
KindMux 表示 ControlMaster / ControlPersist 多路复用守护句柄类别。
type KindPTY ¶
type KindPTY struct {
// contains filtered or unexported fields
}
KindPTY 表示持久交互终端会话句柄类别。
type KindSession ¶
type KindSession struct {
// contains filtered or unexported fields
}
KindSession 表示通用托管连接会话句柄类别。
type KindTransfer ¶
type KindTransfer struct {
// contains filtered or unexported fields
}
KindTransfer 表示可恢复文件传输 / SFTP 工作区句柄类别。
type KindTunnel ¶
type KindTunnel struct {
// contains filtered or unexported fields
}
KindTunnel 表示端口转发 / StreamLocal / TUN 隧道句柄类别。
type ManagedHandle ¶
type ManagedHandle[K HandleKind] struct { // contains filtered or unexported fields }
ManagedHandle 表示按封闭句柄类别 K 参数化的不可变世代槽位句柄(ADR-009): 内置正向门控 valid bool 与单调非零世代 gen >= 1,强绑定 Merkle PlanDigest 与 security.OperationBinding; 零值恒无效并失败关闭,且经 //xops:canonicalhash 校验 WriteCanonical 100% 全字段覆盖。
func NewManagedHandle ¶
func NewManagedHandle[K HandleKind](id HandleID, gen uint64, planDigest PlanDigest, binding security.OperationBinding) (ManagedHandle[K], error)
NewManagedHandle 校验句柄类别 K、HandleID、非零世代 gen>=1、PlanDigest 与 OperationBinding 一致性, 构造不可变 ManagedHandle[K]。遵循 INV-E4,binding 必须显式携带且严格匹配 planDigest。
func (ManagedHandle[K]) AppendText ¶
func (h ManagedHandle[K]) AppendText(b []byte) ([]byte, error)
AppendText 实现 encoding.TextAppender(值接收者),输出紧凑不可伪造句柄令牌;零值失败关闭。
func (ManagedHandle[K]) Binding ¶
func (h ManagedHandle[K]) Binding() security.OperationBinding
func (ManagedHandle[K]) Equal ¶
func (h ManagedHandle[K]) Equal(o ManagedHandle[K]) bool
Equal 严格比对两个同类别 ManagedHandle[K] 是否均有效且全部字段完全一致。
func (ManagedHandle[K]) Generation ¶
func (h ManagedHandle[K]) Generation() uint64
func (ManagedHandle[K]) ID ¶
func (h ManagedHandle[K]) ID() HandleID
func (ManagedHandle[K]) IsValid ¶
func (h ManagedHandle[K]) IsValid() bool
func (ManagedHandle[K]) IsZero ¶
func (h ManagedHandle[K]) IsZero() bool
func (ManagedHandle[K]) Kind ¶
func (h ManagedHandle[K]) Kind() HandleKindCode
func (ManagedHandle[K]) MarshalJSONTo ¶
func (h ManagedHandle[K]) MarshalJSONTo(enc *jsontext.Encoder) error
MarshalJSONTo 实现 ManagedHandle[K] 的 Go 1.27 encoding/json/v2 完整确定性编码;零值失败关闭。
func (ManagedHandle[K]) MarshalText ¶
func (h ManagedHandle[K]) MarshalText() ([]byte, error)
MarshalText 实现 encoding.TextMarshaler(值接收者)。
func (ManagedHandle[K]) MatchesGeneration ¶
func (h ManagedHandle[K]) MatchesGeneration(gen uint64) bool
MatchesGeneration 判断句柄是否有效且处于预期世代 gen。
func (ManagedHandle[K]) MatchesPlan ¶
func (h ManagedHandle[K]) MatchesPlan(pd PlanDigest) bool
MatchesPlan 判断句柄是否有效且绑定至预期 PlanDigest。
func (ManagedHandle[K]) PlanDigest ¶
func (h ManagedHandle[K]) PlanDigest() PlanDigest
func (ManagedHandle[K]) String ¶
func (h ManagedHandle[K]) String() string
String 返回紧凑句柄标识文本 "<kind>:<id>:g<gen>:<plan_digest>";无效零值返回空串。
func (*ManagedHandle[K]) UnmarshalJSONFrom ¶
func (h *ManagedHandle[K]) UnmarshalJSONFrom(dec *jsontext.Decoder) error
UnmarshalJSONFrom 实现 ManagedHandle[K] 的失败关闭解码,强制校验 kind == HandleKindOf[K]() 杜绝跨类别混淆。
func (ManagedHandle[K]) WriteCanonical ¶
func (h ManagedHandle[K]) WriteCanonical(w io.Writer) error
WriteCanonical 以零反射、长度前缀与域分离方式将 ManagedHandle[K] 全字段写入 w(受 digestcover 校验)。
type PlanDigest ¶
type PlanDigest struct {
// contains filtered or unexported fields
}
PlanDigest 表示整条不可变 SealedConnectionPlan 的顶层 32 字节 Merkle SHA-256 摘要; 零值恒无效,Equal 采用常量时间比较,并可无损投影至 security.OperationBinding.PlanDigest。
func ParsePlanDigest ¶
func ParsePlanDigest(raw string) (PlanDigest, error)
ParsePlanDigest 严格解析规范 SHA-256 文本("sha256:<64位小写十六进制>")为 PlanDigest。
func PlanDigestFromSHA256 ¶
func PlanDigestFromSHA256(sum [sha256.Size]byte) PlanDigest
PlanDigestFromSHA256 将 32 字节 SHA-256 摘要封装为不可变 PlanDigest。
func (PlanDigest) AppendText ¶
func (d PlanDigest) AppendText(b []byte) ([]byte, error)
func (PlanDigest) Compare ¶
func (d PlanDigest) Compare(other PlanDigest) int
Compare 定义 PlanDigest 上的确定性全序关系(无效零值排在有效值之前)。
func (PlanDigest) Equal ¶
func (d PlanDigest) Equal(other PlanDigest) bool
Equal 以常量时间比对两个 PlanDigest 是否均有效且字节完全一致(无效零值永不相等)。
func (PlanDigest) Hex ¶
func (d PlanDigest) Hex() string
func (PlanDigest) IsValid ¶
func (d PlanDigest) IsValid() bool
func (PlanDigest) IsZero ¶
func (d PlanDigest) IsZero() bool
func (PlanDigest) MarshalText ¶
func (d PlanDigest) MarshalText() ([]byte, error)
func (PlanDigest) SecurityDigest ¶
func (d PlanDigest) SecurityDigest() security.Digest
SecurityDigest 将有效 PlanDigest 无损投影为 security.Digest;无效零值返回零值 security.Digest。
func (PlanDigest) String ¶
func (d PlanDigest) String() string
func (*PlanDigest) UnmarshalText ¶
func (d *PlanDigest) UnmarshalText(text []byte) error
type SealedConnectionPlan ¶
type SealedConnectionPlan struct {
// contains filtered or unexported fields
}
SealedConnectionPlan 表示不可变的多跳 Merkle 链式 SSH 连接计划(INV-C1 / ADR-009):
- HopDigest[0] = SHA256(merkleHopDomainTag || 0 || HopSpec[0].WriteCanonical)
- HopDigest[i] = SHA256(merkleHopDomainTag || HopDigest[i-1] || HopSpec[i].WriteCanonical)
- PlanDigest = SHA256(sealedPlanDomainTag || len(hops) || HopDigest[n-1])
任意上游跳板的任一字段变更均必然级联刷新所有下游 HopDigest 与 PlanDigest,而共享完全相同上游前缀的 两条计划则天然共享相同前缀 HopDigest;经 //xops:canonicalhash 校验 WriteCanonical 100% 全字段覆盖。
func NewSealedConnectionPlan ¶
func NewSealedConnectionPlan(hops algebraic.NonEmpty[HopSpec]) (SealedConnectionPlan, error)
NewSealedConnectionPlan 校验全部跳板规格及其连续索引 [0..n-1],按 INV-D2 对全部中间跳剥离 Forward/Session/LocalExec, 并计算 Merkle 跳板摘要链与顶层 PlanDigest。
func SealConnectionPlan ¶
func SealConnectionPlan(hops ...HopSpec) (SealedConnectionPlan, error)
SealConnectionPlan 便捷封装可变长跳板序列并构造 Merkle 链式 SealedConnectionPlan。
func (SealedConnectionPlan) CanonicalJSON ¶
func (p SealedConnectionPlan) CanonicalJSON() ([]byte, error)
CanonicalJSON 使用 Go 1.27 encoding/json/v2 Deterministic(true) 编码确定性 JSON。
func (SealedConnectionPlan) Equal ¶
func (p SealedConnectionPlan) Equal(o SealedConnectionPlan) bool
Equal 严格比对两份 SealedConnectionPlan 是否均有效、摘要匹配且全部跳板规格一致。
func (SealedConnectionPlan) HopAt ¶
func (p SealedConnectionPlan) HopAt(index int) (HopSpec, bool)
HopAt 返回第 index 跳的不可变 HopSpec;越界或计划无效返回 (零值, false)。
func (SealedConnectionPlan) HopDigestAt ¶
func (p SealedConnectionPlan) HopDigestAt(index int) (HopDigest, bool)
HopDigestAt 返回第 index 跳的 Merkle HopDigest;越界或计划无效返回 (零值, false)。
func (SealedConnectionPlan) HopDigests ¶
func (p SealedConnectionPlan) HopDigests() []HopDigest
func (SealedConnectionPlan) HopSlice ¶
func (p SealedConnectionPlan) HopSlice() []HopSpec
func (SealedConnectionPlan) IsValid ¶
func (p SealedConnectionPlan) IsValid() bool
func (SealedConnectionPlan) IsZero ¶
func (p SealedConnectionPlan) IsZero() bool
func (SealedConnectionPlan) Len ¶
func (p SealedConnectionPlan) Len() int
func (SealedConnectionPlan) MarshalJSONTo ¶
func (p SealedConnectionPlan) MarshalJSONTo(enc *jsontext.Encoder) error
MarshalJSONTo 实现 SealedConnectionPlan 的 json/v2 确定性编码。
func (SealedConnectionPlan) PlanDigest ¶
func (p SealedConnectionPlan) PlanDigest() PlanDigest
func (SealedConnectionPlan) Prefix ¶
func (p SealedConnectionPlan) Prefix(count int) (SealedConnectionPlan, error)
Prefix 返回前 count 跳(1 <= count <= Len())对应的子连接计划,严格保持前缀每跳 HopDigest 完全一致, 供连接池多跳拨号逐级缓存并安全复用公共堡垒机前缀。
func (SealedConnectionPlan) Target ¶
func (p SealedConnectionPlan) Target() (HopSpec, bool)
Target 返回计划末跳(最终目标主机)规格;无效零值返回 (零值, false)。
func (*SealedConnectionPlan) UnmarshalJSONFrom ¶
func (p *SealedConnectionPlan) UnmarshalJSONFrom(dec *jsontext.Decoder) error
UnmarshalJSONFrom 实现 SealedConnectionPlan 的防篡改 json/v2 解码: 必须完整携带 hop_digests 与 plan_digest 且与依据 hops 重算的 Merkle 链严格一致,缺失/null/篡改一律失败关闭。
func (SealedConnectionPlan) WithoutForwardAgent ¶ added in v1.3.0
func (p SealedConnectionPlan) WithoutForwardAgent() (SealedConnectionPlan, error)
WithoutForwardAgent 返回在全部跳板上剥离 ForwardAgent(置为 false,保留 IdentityAgent 与其余策略不变) 并重算 HopDigest 与 PlanDigest 的不可变计划副本,供 Playbook / MCP 对预解析计划实施确定性裁剪(ADR-019 v2.2)。
func (SealedConnectionPlan) WithoutLeafControlPolicy ¶ added in v1.3.0
func (p SealedConnectionPlan) WithoutLeafControlPolicy() (SealedConnectionPlan, error)
WithoutLeafControlPolicy 返回仅剥离末跳 ControlPolicy(重置为默认禁用态 ControlMaster=no、ControlPath/ControlPersist 未设) 并重算末跳 HopDigest 与顶层 PlanDigest 的不可变计划副本;全部中间跳 0..n-2 规格与前缀 HopDigest 保持比特级不变, 供 ControlMaster=auto/autoask 不兼容回退或自定义 AgentSpec 直连复用公共堡垒机前缀且零每路径摘要碎片化(ADR-019 v2.2 S3-Q2)。
func (SealedConnectionPlan) WriteCanonical ¶
func (p SealedConnectionPlan) WriteCanonical(w io.Writer) error
WriteCanonical 以零反射、长度前缀与域分离方式将 SealedConnectionPlan 全字段写入 w(受 digestcover 校验)。
type TransportPolicySpec ¶
type TransportPolicySpec struct {
// contains filtered or unexported fields
}
TransportPolicySpec 是从 option.EffectivePolicy 完整提取的不可变连接传输与安全策略投影; 100% 覆盖算法协商、地址族、TCP 保活、主机密钥与 DNS 信任、认证控制、多路复用、代理与末跳会话选项, 并经 //xops:canonicalhash 由 xopsvet/digestcover 在编译期静态验证 WriteCanonical 全字段覆盖。
func TransportPolicyFromEffective ¶
func TransportPolicyFromEffective(ep option.EffectivePolicy) (TransportPolicySpec, error)
TransportPolicyFromEffective 从已求解的有效策略提取不可变 TransportPolicySpec。
func (TransportPolicySpec) AddressFamily ¶ added in v1.3.0
func (t TransportPolicySpec) AddressFamily() option.AddressFamily
func (TransportPolicySpec) BatchMode ¶
func (t TransportPolicySpec) BatchMode() bool
func (TransportPolicySpec) CertificateFiles ¶
func (t TransportPolicySpec) CertificateFiles() option.PathList
func (TransportPolicySpec) Ciphers ¶
func (t TransportPolicySpec) Ciphers() []string
func (TransportPolicySpec) ConnectTimeout ¶
func (t TransportPolicySpec) ConnectTimeout() algebraic.Option[algebraic.Duration]
func (TransportPolicySpec) ControlPolicy ¶
func (t TransportPolicySpec) ControlPolicy() option.ControlPolicy
func (TransportPolicySpec) Equal ¶
func (t TransportPolicySpec) Equal(o TransportPolicySpec) bool
Equal 严格比对两份 TransportPolicySpec 是否均有效且全部字段完全一致。
func (TransportPolicySpec) ForwardAgent ¶
func (t TransportPolicySpec) ForwardAgent() bool
func (TransportPolicySpec) GlobalKnownHostsFiles ¶ added in v1.3.0
func (t TransportPolicySpec) GlobalKnownHostsFiles() option.KnownHostsList
func (TransportPolicySpec) HashKnownHosts ¶ added in v1.3.0
func (t TransportPolicySpec) HashKnownHosts() bool
func (TransportPolicySpec) HostKeyAlgos ¶
func (t TransportPolicySpec) HostKeyAlgos() []string
func (TransportPolicySpec) IdentitiesOnly ¶
func (t TransportPolicySpec) IdentitiesOnly() bool
func (TransportPolicySpec) IdentityAgent ¶ added in v1.3.0
func (t TransportPolicySpec) IdentityAgent() algebraic.Option[option.IdentityAgentSpec]
func (TransportPolicySpec) IdentityFiles ¶
func (t TransportPolicySpec) IdentityFiles() option.PathList
func (TransportPolicySpec) IsValid ¶
func (t TransportPolicySpec) IsValid() bool
func (TransportPolicySpec) IsZero ¶
func (t TransportPolicySpec) IsZero() bool
func (TransportPolicySpec) KbdInteractiveAuthentication ¶ added in v1.3.0
func (t TransportPolicySpec) KbdInteractiveAuthentication() bool
func (TransportPolicySpec) KexAlgorithms ¶
func (t TransportPolicySpec) KexAlgorithms() []string
func (TransportPolicySpec) LocalCommand ¶
func (t TransportPolicySpec) LocalCommand() algebraic.Option[option.SanitizedCmd]
func (TransportPolicySpec) MACs ¶
func (t TransportPolicySpec) MACs() []string
func (TransportPolicySpec) MarshalJSONTo ¶
func (t TransportPolicySpec) MarshalJSONTo(enc *jsontext.Encoder) error
MarshalJSONTo 实现 TransportPolicySpec 的 json/v2 确定性编码。
func (TransportPolicySpec) PasswordAuthentication ¶ added in v1.3.0
func (t TransportPolicySpec) PasswordAuthentication() bool
func (TransportPolicySpec) PermitLocalCommand ¶
func (t TransportPolicySpec) PermitLocalCommand() bool
func (TransportPolicySpec) PreferredAuthentications ¶ added in v1.3.0
func (t TransportPolicySpec) PreferredAuthentications() algebraic.Option[option.PreferredAuthList]
func (TransportPolicySpec) ProxyRoute ¶
func (t TransportPolicySpec) ProxyRoute() option.ProxyRoute
func (TransportPolicySpec) PubkeyAuthentication ¶ added in v1.3.0
func (t TransportPolicySpec) PubkeyAuthentication() bool
func (TransportPolicySpec) SendEnv ¶
func (t TransportPolicySpec) SendEnv() option.EnvFilter
func (TransportPolicySpec) ServerAliveCountMax ¶
func (t TransportPolicySpec) ServerAliveCountMax() uint32
func (TransportPolicySpec) ServerAliveInterval ¶
func (t TransportPolicySpec) ServerAliveInterval() algebraic.Duration
func (TransportPolicySpec) StrictHostKeyChecking ¶
func (t TransportPolicySpec) StrictHostKeyChecking() option.StrictHostKeyCheckingMode
func (TransportPolicySpec) StripForIntermediateHop ¶ added in v1.3.0
func (t TransportPolicySpec) StripForIntermediateHop() TransportPolicySpec
StripForIntermediateHop 按 INV-D2 剥离中间跳板禁止生效的全部 Forward、Session 与 LocalExec 策略, 完整保留 Transport、Trust、Auth、Target 与 Mux 字段以确保连接池摘要隔离与安全前缀复用。
func (TransportPolicySpec) TCPKeepAlive ¶ added in v1.3.0
func (t TransportPolicySpec) TCPKeepAlive() bool
func (*TransportPolicySpec) UnmarshalJSONFrom ¶
func (t *TransportPolicySpec) UnmarshalJSONFrom(dec *jsontext.Decoder) error
UnmarshalJSONFrom 实现 TransportPolicySpec 的失败关闭 json/v2 解码。
func (TransportPolicySpec) UserKnownHostsFiles ¶
func (t TransportPolicySpec) UserKnownHostsFiles() option.KnownHostsList
func (TransportPolicySpec) VerifyHostKeyDNS ¶ added in v1.3.0
func (t TransportPolicySpec) VerifyHostKeyDNS() option.VerifyHostKeyDNSMode
func (TransportPolicySpec) WriteCanonical ¶
func (t TransportPolicySpec) WriteCanonical(w io.Writer) error
WriteCanonical 以零反射、长度前缀与域分离方式写入 TransportPolicySpec 全字段(受 digestcover 校验)。