Documentation
¶
Overview ¶
Package option 提供 XOps v2 纯函数领域核的 OpenSSH 四层选项幺半群、协议级 %C 哈希与唯一纯策略求解器。
本包恪守 100% 纯数学与零副作用铁律(零 os、零 net、零 context、零 sync/sync/atomic、零反射), 并经 archbound 独占获准导入标准库 crypto/sha1 专供 OpenSSH ssh_config(5) %C 连接哈希计算。
核心代数结构(严格对齐校准后 RFC §3.6):
- (PathList, Compose, Unset):专用于 IdentityFile/CertificateFile 单指令单路径多行累积的三态路径幺半群;
- (KnownHostsList, Compose, Unset):专用于 UserKnownHostsFile 的独立不透明 FirstWins 幺半群;
- (AlgoPolicy, Compose, Unset):单指令算法算子(exact/+/-(独占通配)/^),跨指令与跨层按 FirstWins 合并;
- (ProxyRoute, ComposeProxyRoute, ProxyUnset):封闭和类型与双槽遮蔽代数(ProxyJump 与 ProxyCommand);
- (ControlPolicy, Compose, Unset):三槽 FirstWins 直积幺半群(!Path().IsEnabled() 时运行期投影归零);
- (EnvFilter, Compose, Unset):SendEnv 模式列表与 -PATTERN 通配减法幺半群;
- (OptionLayer, Compose, Unset) 与唯一纯求解入口 ResolveEffectivePolicy(origin, endpoint, t1, t2, t3, t4)。
Index ¶
- Constants
- Variables
- func ComputeConnectionHash(localHost, targetHost string, port uint16, user, jumpHost string) (string, error)
- func ComputePercentC(localHost, targetHost string, port uint16, user string) (string, error)
- func DefaultCiphers() []string
- func DefaultHostKeyAlgorithms() []string
- func DefaultKexAlgorithms() []string
- func DefaultMACs() []string
- func EqualProxyRoute(a, b ProxyRoute) bool
- func ExpandPathTokens(template string, ctx TokenContext) (string, error)
- func ExpandTokens(template string, ctx TokenContext) (string, error)
- func MarshalProxyRouteTo(enc *jsontext.Encoder, route ProxyRoute) error
- func ValidateProxyRoute(route ProxyRoute) error
- type AlgoOp
- type AlgoPolicy
- func (p AlgoPolicy) Apply(defaults []string) ([]string, error)
- func (p AlgoPolicy) Compose(lower AlgoPolicy) AlgoPolicy
- func (p AlgoPolicy) Equal(o AlgoPolicy) bool
- func (p AlgoPolicy) IsExact() bool
- func (p AlgoPolicy) IsIdentity() bool
- func (p AlgoPolicy) IsUnset() bool
- func (p AlgoPolicy) IsZero() bool
- func (p AlgoPolicy) MarshalJSONTo(enc *jsontext.Encoder) error
- func (p AlgoPolicy) Op() AlgoOp
- func (p AlgoPolicy) String() string
- func (p AlgoPolicy) Tokens() []string
- func (p AlgoPolicy) Transform(defaults []string) []string
- func (p *AlgoPolicy) UnmarshalJSONFrom(d *jsontext.Decoder) error
- type ControlMasterMode
- type ControlPathKind
- type ControlPathSpec
- func (s ControlPathSpec) Equal(o ControlPathSpec) bool
- func (s ControlPathSpec) IsDisabled() bool
- func (s ControlPathSpec) IsEnabled() bool
- func (s ControlPathSpec) IsLiteral() bool
- func (s ControlPathSpec) IsUnset() bool
- func (s ControlPathSpec) Kind() ControlPathKind
- func (s ControlPathSpec) String() string
- type ControlPersistKind
- type ControlPersistSpec
- func (p ControlPersistSpec) AppendText(b []byte) ([]byte, error)
- func (p ControlPersistSpec) Equal(o ControlPersistSpec) bool
- func (p ControlPersistSpec) IsEnabled() bool
- func (p ControlPersistSpec) IsIndefinite() bool
- func (p ControlPersistSpec) IsUnset() bool
- func (p ControlPersistSpec) Kind() ControlPersistKind
- func (p ControlPersistSpec) MarshalText() ([]byte, error)
- func (p ControlPersistSpec) String() string
- func (p ControlPersistSpec) Timeout() (algebraic.Duration, bool)
- func (p *ControlPersistSpec) UnmarshalText(text []byte) error
- type ControlPolicy
- func (c ControlPolicy) Compose(lower ControlPolicy) ControlPolicy
- func (c ControlPolicy) EffectiveMaster() ControlMasterMode
- func (c ControlPolicy) EffectivePersist() ControlPersistSpec
- func (c ControlPolicy) Equal(o ControlPolicy) bool
- func (c ControlPolicy) IsDisabled() bool
- func (c ControlPolicy) IsEnabled() bool
- func (c ControlPolicy) IsUnset() bool
- func (c ControlPolicy) IsZero() bool
- func (c ControlPolicy) MarshalJSONTo(e *jsontext.Encoder) error
- func (c ControlPolicy) Master() ControlMasterMode
- func (c ControlPolicy) Path() ControlPathSpec
- func (c ControlPolicy) Persist() ControlPersistSpec
- func (c *ControlPolicy) UnmarshalJSONFrom(d *jsontext.Decoder) error
- func (c ControlPolicy) WithMaster(m ControlMasterMode) ControlPolicy
- func (c ControlPolicy) WithPath(p ControlPathSpec) ControlPolicy
- func (c ControlPolicy) WithPersist(p ControlPersistSpec) ControlPolicy
- type EffectivePolicy
- func (p EffectivePolicy) BatchMode() bool
- func (p EffectivePolicy) CertificateFiles() PathList
- func (p EffectivePolicy) Ciphers() []string
- func (p EffectivePolicy) ConnectTimeout() algebraic.Option[algebraic.Duration]
- func (p EffectivePolicy) Control() ControlPolicy
- func (p EffectivePolicy) Endpoint() netaddr.Endpoint
- func (p EffectivePolicy) Equal(o EffectivePolicy) bool
- func (p EffectivePolicy) ForwardAgent() bool
- func (p EffectivePolicy) HostKeyAlgorithms() []string
- func (p EffectivePolicy) IdentitiesOnly() bool
- func (p EffectivePolicy) IdentityFiles() PathList
- func (p EffectivePolicy) IsValid() bool
- func (p EffectivePolicy) KexAlgorithms() []string
- func (p EffectivePolicy) LocalCommand() algebraic.Option[SanitizedCmd]
- func (p EffectivePolicy) MACs() []string
- func (p EffectivePolicy) MarshalJSONTo(enc *jsontext.Encoder) error
- func (p EffectivePolicy) Options() OptionLayer
- func (p EffectivePolicy) Origin() OriginKind
- func (p EffectivePolicy) OriginalHost() OriginalHostSpec
- func (p EffectivePolicy) PercentC(localHost, fallbackUser string) (string, error)
- func (p EffectivePolicy) PermitLocalCommand() bool
- func (p EffectivePolicy) Proxy() ProxyRoute
- func (p EffectivePolicy) SendEnv() EnvFilter
- func (p EffectivePolicy) ServerAliveCountMax() uint32
- func (p EffectivePolicy) ServerAliveInterval() algebraic.Duration
- func (p EffectivePolicy) StrictHostKeyChecking() StrictHostKeyCheckingMode
- func (p *EffectivePolicy) UnmarshalJSONFrom(dec *jsontext.Decoder) error
- func (p EffectivePolicy) User() algebraic.Option[Username]
- func (p EffectivePolicy) UserKnownHostsFiles() KnownHostsList
- type EnvFilter
- func (f EnvFilter) ClearPatterns() []string
- func (f EnvFilter) Compose(lower EnvFilter) EnvFilter
- func (f EnvFilter) Equal(o EnvFilter) bool
- func (f EnvFilter) Filter(env map[string]string) map[string]string
- func (f EnvFilter) FilterNames(names []string) []string
- func (f EnvFilter) FilterSorted(env map[string]string) []string
- func (f EnvFilter) IsUnset() bool
- func (f EnvFilter) IsZero() bool
- func (f EnvFilter) MarshalJSONTo(e *jsontext.Encoder) error
- func (f EnvFilter) Match(envName string) bool
- func (f EnvFilter) Patterns() []string
- func (f *EnvFilter) UnmarshalJSONFrom(d *jsontext.Decoder) error
- type HopTarget
- func (h HopTarget) AppendText(b []byte) ([]byte, error)
- func (h HopTarget) Equal(o HopTarget) bool
- func (h HopTarget) Host() string
- func (h HopTarget) IsValid() bool
- func (h HopTarget) IsZero() bool
- func (h HopTarget) MarshalText() ([]byte, error)
- func (h HopTarget) Port() (uint16, bool)
- func (h HopTarget) String() string
- func (h *HopTarget) UnmarshalText(text []byte) error
- func (h HopTarget) User() string
- type HostNameSpec
- func (h HostNameSpec) AppendText(b []byte) ([]byte, error)
- func (h HostNameSpec) Equal(o HostNameSpec) bool
- func (t HostNameSpec) IsValid() bool
- func (t HostNameSpec) IsZero() bool
- func (h HostNameSpec) MarshalText() ([]byte, error)
- func (h HostNameSpec) ResolveHost(origHost netaddr.CanonicalHost) (z netaddr.CanonicalHost, err error)
- func (h HostNameSpec) ResolveHostFor(origHost OriginalHostSpec) (z netaddr.CanonicalHost, err error)
- func (t HostNameSpec) String() string
- func (h *HostNameSpec) UnmarshalText(t []byte) error
- type KnownHostsList
- func (k KnownHostsList) Compose(lower KnownHostsList) KnownHostsList
- func (b KnownHostsList) DefaultsAllowed() bool
- func (k KnownHostsList) Equal(o KnownHostsList) bool
- func (b KnownHostsList) IsDisabled() bool
- func (b KnownHostsList) IsSet() bool
- func (b KnownHostsList) IsUnset() bool
- func (b KnownHostsList) IsZero() bool
- func (b KnownHostsList) Items() []PathEntry
- func (k KnownHostsList) MarshalJSONTo(e *jsontext.Encoder) error
- func (b KnownHostsList) RawItems() []string
- func (b KnownHostsList) State() PathListState
- func (k *KnownHostsList) UnmarshalJSONFrom(d *jsontext.Decoder) error
- type OptionClass
- type OptionKey
- type OptionLayer
- func (l OptionLayer) ApplyParsedOption(opt ParsedOption) OptionLayer
- func (l OptionLayer) BatchMode() algebraic.Option[bool]
- func (l OptionLayer) CertificateFiles() PathList
- func (l OptionLayer) Ciphers() AlgoPolicy
- func (l OptionLayer) Compose(lower OptionLayer) OptionLayer
- func (l OptionLayer) ConnectTimeout() algebraic.Option[algebraic.Duration]
- func (l OptionLayer) Control() ControlPolicy
- func (l OptionLayer) Equal(o OptionLayer) bool
- func (l OptionLayer) FilterForNonOpenSSHOrigin() OptionLayer
- func (l OptionLayer) ForwardAgent() algebraic.Option[bool]
- func (l OptionLayer) HostKeyAlgorithms() AlgoPolicy
- func (l OptionLayer) HostName() algebraic.Option[HostNameSpec]
- func (l OptionLayer) IdentitiesOnly() algebraic.Option[bool]
- func (l OptionLayer) IdentityFiles() PathList
- func (l OptionLayer) IsUnset() bool
- func (l OptionLayer) IsZero() bool
- func (l OptionLayer) KexAlgorithms() AlgoPolicy
- func (l OptionLayer) LocalCommand() algebraic.Option[SanitizedCmd]
- func (l OptionLayer) MACs() AlgoPolicy
- func (l OptionLayer) MarshalJSONTo(enc *jsontext.Encoder) error
- func (l OptionLayer) PermitLocalCommand() algebraic.Option[bool]
- func (l OptionLayer) Port() algebraic.Option[uint16]
- func (l OptionLayer) Proxy() ProxyRoute
- func (l OptionLayer) SendEnv() EnvFilter
- func (l OptionLayer) ServerAliveCountMax() algebraic.Option[uint32]
- func (l OptionLayer) ServerAliveInterval() algebraic.Option[algebraic.Duration]
- func (l OptionLayer) StrictHostKeyChecking() algebraic.Option[StrictHostKeyCheckingMode]
- func (l *OptionLayer) UnmarshalJSONFrom(dec *jsontext.Decoder) error
- func (l OptionLayer) User() algebraic.Option[Username]
- func (l OptionLayer) UserKnownHostsFiles() KnownHostsList
- func (l OptionLayer) Validate() error
- func (l OptionLayer) WithBatchMode(v bool) OptionLayer
- func (l OptionLayer) WithCertificateFiles(p PathList) OptionLayer
- func (l OptionLayer) WithCiphers(p AlgoPolicy) OptionLayer
- func (l OptionLayer) WithConnectTimeout(d algebraic.Duration) OptionLayer
- func (l OptionLayer) WithControlPolicy(c ControlPolicy) OptionLayer
- func (l OptionLayer) WithForwardAgent(v bool) OptionLayer
- func (l OptionLayer) WithHostKeyAlgorithms(p AlgoPolicy) OptionLayer
- func (l OptionLayer) WithHostName(h HostNameSpec) OptionLayer
- func (l OptionLayer) WithIdentitiesOnly(v bool) OptionLayer
- func (l OptionLayer) WithIdentityFiles(p PathList) OptionLayer
- func (l OptionLayer) WithKexAlgorithms(p AlgoPolicy) OptionLayer
- func (l OptionLayer) WithLocalCommand(c SanitizedCmd) OptionLayer
- func (l OptionLayer) WithMACs(p AlgoPolicy) OptionLayer
- func (l OptionLayer) WithPermitLocalCommand(v bool) OptionLayer
- func (l OptionLayer) WithPort(p uint16) OptionLayer
- func (l OptionLayer) WithProxyRoute(r ProxyRoute) OptionLayer
- func (l OptionLayer) WithSendEnv(f EnvFilter) OptionLayer
- func (l OptionLayer) WithServerAliveCountMax(n uint32) OptionLayer
- func (l OptionLayer) WithServerAliveInterval(d algebraic.Duration) OptionLayer
- func (l OptionLayer) WithStrictHostKeyChecking(m StrictHostKeyCheckingMode) OptionLayer
- func (l OptionLayer) WithUser(u Username) OptionLayer
- func (l OptionLayer) WithUserKnownHostsFiles(p KnownHostsList) OptionLayer
- type OptionSpec
- type OriginKind
- type OriginalHostSpec
- func (h OriginalHostSpec) AppendText(b []byte) ([]byte, error)
- func (h OriginalHostSpec) CanonicalHost() (netaddr.CanonicalHost, bool)
- func (h OriginalHostSpec) Equal(o OriginalHostSpec) bool
- func (t OriginalHostSpec) IsValid() bool
- func (t OriginalHostSpec) IsZero() bool
- func (h OriginalHostSpec) MarshalText() ([]byte, error)
- func (t OriginalHostSpec) String() string
- func (h *OriginalHostSpec) UnmarshalText(t []byte) error
- type ParsedOption
- type PathEntry
- func (e PathEntry) AppendText(b []byte) ([]byte, error)
- func (e PathEntry) Equal(o PathEntry) bool
- func (e PathEntry) IsTemplate() bool
- func (e PathEntry) IsValid() bool
- func (e PathEntry) IsZero() bool
- func (e PathEntry) Kind() PathEntryKind
- func (e PathEntry) MarshalText() ([]byte, error)
- func (e PathEntry) String() string
- func (e *PathEntry) UnmarshalText(text []byte) error
- type PathEntryKind
- type PathList
- func (p PathList) Compose(lower PathList) PathList
- func (b PathList) DefaultsAllowed() bool
- func (p PathList) Equal(o PathList) bool
- func (b PathList) IsDisabled() bool
- func (b PathList) IsSet() bool
- func (b PathList) IsUnset() bool
- func (b PathList) IsZero() bool
- func (b PathList) Items() []PathEntry
- func (p PathList) MarshalJSONTo(e *jsontext.Encoder) error
- func (b PathList) RawItems() []string
- func (b PathList) State() PathListState
- func (p PathList) Terminated() bool
- func (p *PathList) UnmarshalJSONFrom(d *jsontext.Decoder) error
- type PathListState
- type ProxyCommandSpec
- type ProxyDisabled
- type ProxyJumpChain
- type ProxyRoute
- type ProxyUnset
- type SanitizedCmd
- func (c SanitizedCmd) AppendText(b []byte) ([]byte, error)
- func (c SanitizedCmd) Equal(o SanitizedCmd) bool
- func (t SanitizedCmd) IsValid() bool
- func (t SanitizedCmd) IsZero() bool
- func (c SanitizedCmd) MarshalText() ([]byte, error)
- func (t SanitizedCmd) String() string
- func (c *SanitizedCmd) UnmarshalText(text []byte) error
- type StrictHostKeyCheckingMode
- type TokenContext
- type Username
Constants ¶
const DefaultServerAliveCountMax uint32 = 3
DefaultServerAliveCountMax 是 OpenSSH 默认保活探测最大允许丢失次数。
Variables ¶
var ( ErrInvalidOption = errors.New("option: 无效的 OpenSSH 选项") ErrUnknownOption = errors.New("option: 未知或不支持的 OpenSSH 选项") ErrInvalidOrigin = errors.New("option: 无效的策略来源分类") ErrInvalidEndpoint = errors.New("option: 无效的目标端点") ErrInvalidPathList = errors.New("option: 无效的路径列表") ErrInvalidAlgoPolicy = errors.New("option: 无效的算法策略") ErrEmptyAlgorithmList = errors.New("option: 求解后的算法列表为空") ErrInvalidProxyRoute = errors.New("option: 无效的代理路由") ErrInvalidControlPolicy = errors.New("option: 无效的多路复用策略") ErrInvalidEnvFilter = errors.New("option: 无效的环境变量过滤规则") ErrInvalidPercentInput = errors.New("option: 无效的 OpenSSH 令牌或 %C 哈希输入") ErrNilReceiver = errors.New("option: 编解码目标或编码器不能为 nil") )
包级哨兵错误:所有无效输入、未知选项与零值访问均严格失败关闭。
Functions ¶
func ComputeConnectionHash ¶
func ComputePercentC ¶
ComputePercentC 与 ComputeConnectionHash 计算 OpenSSH ssh_config(5) 协议级 %C 40 位小写十六进制 SHA-1 哈希(SHA1(%l%h%p%r%j)); localHost、targetHost、user 必须非空且 port 位于 [1, 65535],jumpHost 无跳板时可为空串。
func DefaultCiphers ¶
func DefaultCiphers() []string
DefaultCiphers、DefaultMACs、DefaultKexAlgorithms 与 DefaultHostKeyAlgorithms 返回现代安全默认算法列表副本。
func DefaultHostKeyAlgorithms ¶
func DefaultHostKeyAlgorithms() []string
func DefaultKexAlgorithms ¶
func DefaultKexAlgorithms() []string
func DefaultMACs ¶
func DefaultMACs() []string
func EqualProxyRoute ¶
func EqualProxyRoute(a, b ProxyRoute) bool
func ExpandPathTokens ¶
func ExpandPathTokens(template string, ctx TokenContext) (string, error)
func ExpandTokens ¶
func ExpandTokens(template string, ctx TokenContext) (string, error)
ExpandTokens 与 ExpandPathTokens 对 OpenSSH 模板执行确定性单遍 % token 展开; 非 %j 令牌字段为空均失败关闭,ExpandPathTokens 额外禁止非 %d 令牌注入路径分隔符或目录穿越段。
func MarshalProxyRouteTo ¶
func MarshalProxyRouteTo(enc *jsontext.Encoder, route ProxyRoute) error
MarshalProxyRouteTo 与 UnmarshalProxyRouteFrom 为封闭接口 ProxyRoute 提供多态 json/v2 确定性编解码(失败严格返回 (nil, err))。
func ValidateProxyRoute ¶
func ValidateProxyRoute(route ProxyRoute) error
ValidateProxyRoute、ComposeProxyRoute、FoldProxyRoutes 与 EqualProxyRoute 提供 ProxyRoute 校验、双槽复合、折叠与等价判定。
Types ¶
type AlgoPolicy ¶
type AlgoPolicy struct {
// contains filtered or unexported fields
}
AlgoPolicy 表示校准后的 OpenSSH 算法列表策略: 单条指令表达列表算子 Unset | Exact | Append(+) | Remove(-, 独占支持 */? 通配) | Prepend(^), 跨指令与跨层合并严格遵循 FirstWins 幺半群(非 Unset 左吸收低层),仅在求解边界对默认集单次 Apply。
func FoldAlgoPolicies ¶
func FoldAlgoPolicies(layers ...AlgoPolicy) AlgoPolicy
func IdentityAlgoPolicy ¶
func IdentityAlgoPolicy() AlgoPolicy
func ParseAlgoPolicy ¶
func ParseAlgoPolicy(raw string) (AlgoPolicy, error)
ParseAlgoPolicy 解析单条 OpenSSH 算法策略("a,b"、"+a,b"、"-a,*-cbc"、"^a,b")。 仅当算子为 AlgoOpRemove('-')时允许 ASCII '*' 与 '?' 通配符;Exact/Append/Prepend 严格禁止通配符。
func UnsetAlgoPolicy ¶
func UnsetAlgoPolicy() AlgoPolicy
UnsetAlgoPolicy 与 IdentityAlgoPolicy 均返回未设置单位元(零值)。
func (AlgoPolicy) Compose ¶
func (p AlgoPolicy) Compose(lower AlgoPolicy) AlgoPolicy
func (AlgoPolicy) Equal ¶
func (p AlgoPolicy) Equal(o AlgoPolicy) bool
func (AlgoPolicy) IsExact ¶
func (p AlgoPolicy) IsExact() bool
func (AlgoPolicy) IsIdentity ¶
func (p AlgoPolicy) IsIdentity() bool
func (AlgoPolicy) IsUnset ¶
func (p AlgoPolicy) IsUnset() bool
func (AlgoPolicy) IsZero ¶
func (p AlgoPolicy) IsZero() bool
func (AlgoPolicy) MarshalJSONTo ¶
func (p AlgoPolicy) MarshalJSONTo(enc *jsontext.Encoder) error
func (AlgoPolicy) String ¶
func (p AlgoPolicy) String() string
func (AlgoPolicy) Tokens ¶
func (p AlgoPolicy) Tokens() []string
func (AlgoPolicy) Transform ¶
func (p AlgoPolicy) Transform(defaults []string) []string
func (*AlgoPolicy) UnmarshalJSONFrom ¶
func (p *AlgoPolicy) UnmarshalJSONFrom(d *jsontext.Decoder) error
type ControlMasterMode ¶
type ControlMasterMode uint8
const ( ControlMasterUnset ControlMasterMode = iota ControlMasterNo ControlMasterYes ControlMasterAsk ControlMasterAuto ControlMasterAutoAsk )
func ParseControlMasterMode ¶
func ParseControlMasterMode(raw string) (ControlMasterMode, error)
ParseControlMasterMode 解析 ControlMaster(no/false/yes/true/ask/auto/autoask)。
func (ControlMasterMode) AppendText ¶
func (m ControlMasterMode) AppendText(b []byte) ([]byte, error)
func (ControlMasterMode) IsSet ¶
func (m ControlMasterMode) IsSet() bool
func (ControlMasterMode) MarshalText ¶
func (m ControlMasterMode) MarshalText() ([]byte, error)
func (ControlMasterMode) String ¶
func (m ControlMasterMode) String() string
func (*ControlMasterMode) UnmarshalText ¶
func (m *ControlMasterMode) UnmarshalText(t []byte) error
type ControlPathKind ¶
type ControlPathKind uint8
const ( ControlPathUnset ControlPathKind = iota ControlPathDisabled ControlPathTemplate ControlPathLiteral )
type ControlPathSpec ¶
type ControlPathSpec struct {
// contains filtered or unexported fields
}
ControlPathSpec 表示不可变的 ControlPath 规格值对象。
func DisabledControlPath ¶
func DisabledControlPath() ControlPathSpec
func NewLiteralControlPath ¶
func NewLiteralControlPath(raw string) (ControlPathSpec, error)
func ParseControlPath ¶
func ParseControlPath(raw string) (ControlPathSpec, error)
func UnsetControlPath ¶
func UnsetControlPath() ControlPathSpec
UnsetControlPath、DisabledControlPath、ParseControlPath、NewLiteralControlPath 及只读访问器。
func (ControlPathSpec) Equal ¶
func (s ControlPathSpec) Equal(o ControlPathSpec) bool
func (ControlPathSpec) IsDisabled ¶
func (s ControlPathSpec) IsDisabled() bool
func (ControlPathSpec) IsEnabled ¶
func (s ControlPathSpec) IsEnabled() bool
func (ControlPathSpec) IsLiteral ¶
func (s ControlPathSpec) IsLiteral() bool
func (ControlPathSpec) IsUnset ¶
func (s ControlPathSpec) IsUnset() bool
func (ControlPathSpec) Kind ¶
func (s ControlPathSpec) Kind() ControlPathKind
func (ControlPathSpec) String ¶
func (s ControlPathSpec) String() string
type ControlPersistKind ¶
type ControlPersistKind uint8
const ( ControlPersistUnset ControlPersistKind = iota ControlPersistNo ControlPersistIndefinite ControlPersistTimeout )
type ControlPersistSpec ¶
type ControlPersistSpec struct {
// contains filtered or unexported fields
}
ControlPersistSpec 表示不可变的 ControlPersist 规格,严格使用 algebraic.Duration(零裸 time.Duration)。
func DisabledControlPersist ¶
func DisabledControlPersist() ControlPersistSpec
func IndefiniteControlPersist ¶
func IndefiniteControlPersist() ControlPersistSpec
func ParseControlPersist ¶
func ParseControlPersist(raw string) (ControlPersistSpec, error)
func TimeoutControlPersist ¶
func TimeoutControlPersist(d algebraic.Duration) (ControlPersistSpec, error)
func UnsetControlPersist ¶
func UnsetControlPersist() ControlPersistSpec
UnsetControlPersist、DisabledControlPersist、IndefiniteControlPersist、TimeoutControlPersist 与 ParseControlPersist 构造驻留规格。
func (ControlPersistSpec) AppendText ¶
func (p ControlPersistSpec) AppendText(b []byte) ([]byte, error)
func (ControlPersistSpec) Equal ¶
func (p ControlPersistSpec) Equal(o ControlPersistSpec) bool
func (ControlPersistSpec) IsEnabled ¶
func (p ControlPersistSpec) IsEnabled() bool
func (ControlPersistSpec) IsIndefinite ¶
func (p ControlPersistSpec) IsIndefinite() bool
func (ControlPersistSpec) IsUnset ¶
func (p ControlPersistSpec) IsUnset() bool
func (ControlPersistSpec) Kind ¶
func (p ControlPersistSpec) Kind() ControlPersistKind
ControlPersistSpec 只读访问器与文本编解码方法。
func (ControlPersistSpec) MarshalText ¶
func (p ControlPersistSpec) MarshalText() ([]byte, error)
func (ControlPersistSpec) String ¶
func (p ControlPersistSpec) String() string
func (ControlPersistSpec) Timeout ¶
func (p ControlPersistSpec) Timeout() (algebraic.Duration, bool)
func (*ControlPersistSpec) UnmarshalText ¶
func (p *ControlPersistSpec) UnmarshalText(text []byte) error
type ControlPolicy ¶
type ControlPolicy struct {
// contains filtered or unexported fields
}
ControlPolicy 表示多路复用策略三槽 FirstWins 直积幺半群(ControlMaster × ControlPath × ControlPersist)。 Compose 保留原始三槽维持结合律与 ssh -G 对齐;运行期投影 EffectiveMaster/EffectivePersist 在 !IsEnabled() 时一律归零。
func FoldControlPolicies ¶
func FoldControlPolicies(layers ...ControlPolicy) ControlPolicy
func UnsetControlPolicy ¶
func UnsetControlPolicy() ControlPolicy
UnsetControlPolicy 及不可变槽位构造器、只读访问器、运行期投影、Compose 与 FoldControlPolicies。
func (ControlPolicy) Compose ¶
func (c ControlPolicy) Compose(lower ControlPolicy) ControlPolicy
func (ControlPolicy) EffectiveMaster ¶
func (c ControlPolicy) EffectiveMaster() ControlMasterMode
func (ControlPolicy) EffectivePersist ¶
func (c ControlPolicy) EffectivePersist() ControlPersistSpec
func (ControlPolicy) Equal ¶
func (c ControlPolicy) Equal(o ControlPolicy) bool
func (ControlPolicy) IsDisabled ¶
func (c ControlPolicy) IsDisabled() bool
func (ControlPolicy) IsEnabled ¶
func (c ControlPolicy) IsEnabled() bool
func (ControlPolicy) IsUnset ¶
func (c ControlPolicy) IsUnset() bool
func (ControlPolicy) IsZero ¶
func (c ControlPolicy) IsZero() bool
func (ControlPolicy) MarshalJSONTo ¶
func (c ControlPolicy) MarshalJSONTo(e *jsontext.Encoder) error
func (ControlPolicy) Master ¶
func (c ControlPolicy) Master() ControlMasterMode
func (ControlPolicy) Path ¶
func (c ControlPolicy) Path() ControlPathSpec
func (ControlPolicy) Persist ¶
func (c ControlPolicy) Persist() ControlPersistSpec
func (*ControlPolicy) UnmarshalJSONFrom ¶
func (c *ControlPolicy) UnmarshalJSONFrom(d *jsontext.Decoder) error
func (ControlPolicy) WithMaster ¶
func (c ControlPolicy) WithMaster(m ControlMasterMode) ControlPolicy
func (ControlPolicy) WithPath ¶
func (c ControlPolicy) WithPath(p ControlPathSpec) ControlPolicy
func (ControlPolicy) WithPersist ¶
func (c ControlPolicy) WithPersist(p ControlPersistSpec) ControlPolicy
type EffectivePolicy ¶
type EffectivePolicy struct {
// contains filtered or unexported fields
}
EffectivePolicy 表示经唯一纯求解入口 ResolveEffectivePolicy 计算得到的不可变生效策略快照;零值恒无效。
func ResolveEffectivePolicy ¶
func ResolveEffectivePolicy(origin OriginKind, endpoint netaddr.Endpoint, t1, t2, t3, t4 OptionLayer) (EffectivePolicy, error)
ResolveEffectivePolicy 是全平面共用的唯一纯四层 OpenSSH 策略求解入口。 优先级严格固定为 t1(CLI) > t2(托管节点) > t3(XOps 全局配置) > t4(OpenSSH ~/.ssh/config) + DefaultOptionLayer(); 非 OpenSSH 来源按 INV-D2 仅对 t4 裁剪(严格保留 OptionClassMux ∪ OptionClassTransport,完整保留 t1/t2/t3), 随后求值端点、对默认集单次应用获胜算法策略并门控 LocalCommand。
func ResolveEffectivePolicyWithOriginalHost ¶
func ResolveEffectivePolicyWithOriginalHost(origin OriginKind, originalHost OriginalHostSpec, defaultPort uint16, t1, t2, t3, t4 OptionLayer) (EffectivePolicy, error)
ResolveEffectivePolicyWithOriginalHost 支持以经校验的 OpenSSH 别名(如 "prod_db"、"bastion.01") 作为 OriginalHost(保留 %n 语义)执行四层策略求解;最终拨号端点 Endpoint 仍严格校验为 netaddr.Endpoint。
func (EffectivePolicy) BatchMode ¶
func (p EffectivePolicy) BatchMode() bool
func (EffectivePolicy) CertificateFiles ¶
func (p EffectivePolicy) CertificateFiles() PathList
func (EffectivePolicy) Ciphers ¶
func (p EffectivePolicy) Ciphers() []string
func (EffectivePolicy) ConnectTimeout ¶
func (p EffectivePolicy) ConnectTimeout() algebraic.Option[algebraic.Duration]
func (EffectivePolicy) Control ¶
func (p EffectivePolicy) Control() ControlPolicy
func (EffectivePolicy) Endpoint ¶
func (p EffectivePolicy) Endpoint() netaddr.Endpoint
func (EffectivePolicy) Equal ¶
func (p EffectivePolicy) Equal(o EffectivePolicy) bool
Equal 判断两个有效 EffectivePolicy 是否完全相等(无效零值永不相等)。
func (EffectivePolicy) ForwardAgent ¶
func (p EffectivePolicy) ForwardAgent() bool
func (EffectivePolicy) HostKeyAlgorithms ¶
func (p EffectivePolicy) HostKeyAlgorithms() []string
func (EffectivePolicy) IdentitiesOnly ¶
func (p EffectivePolicy) IdentitiesOnly() bool
func (EffectivePolicy) IdentityFiles ¶
func (p EffectivePolicy) IdentityFiles() PathList
func (EffectivePolicy) IsValid ¶
func (p EffectivePolicy) IsValid() bool
EffectivePolicy 只读访问器(切片均返回防御性副本,未授权 LocalCommand 恒为 None)。
func (EffectivePolicy) KexAlgorithms ¶
func (p EffectivePolicy) KexAlgorithms() []string
func (EffectivePolicy) LocalCommand ¶
func (p EffectivePolicy) LocalCommand() algebraic.Option[SanitizedCmd]
func (EffectivePolicy) MACs ¶
func (p EffectivePolicy) MACs() []string
func (EffectivePolicy) MarshalJSONTo ¶
func (p EffectivePolicy) MarshalJSONTo(enc *jsontext.Encoder) error
func (EffectivePolicy) Options ¶
func (p EffectivePolicy) Options() OptionLayer
func (EffectivePolicy) Origin ¶
func (p EffectivePolicy) Origin() OriginKind
func (EffectivePolicy) OriginalHost ¶
func (p EffectivePolicy) OriginalHost() OriginalHostSpec
func (EffectivePolicy) PercentC ¶
func (p EffectivePolicy) PercentC(localHost, fallbackUser string) (string, error)
PercentC 基于已求解策略(Endpoint、生效 User 与活跃 ProxyJump 末跳主机名 %j)计算 OpenSSH %C 哈希。
func (EffectivePolicy) PermitLocalCommand ¶
func (p EffectivePolicy) PermitLocalCommand() bool
func (EffectivePolicy) Proxy ¶
func (p EffectivePolicy) Proxy() ProxyRoute
func (EffectivePolicy) SendEnv ¶
func (p EffectivePolicy) SendEnv() EnvFilter
func (EffectivePolicy) ServerAliveCountMax ¶
func (p EffectivePolicy) ServerAliveCountMax() uint32
func (EffectivePolicy) ServerAliveInterval ¶
func (p EffectivePolicy) ServerAliveInterval() algebraic.Duration
func (EffectivePolicy) StrictHostKeyChecking ¶
func (p EffectivePolicy) StrictHostKeyChecking() StrictHostKeyCheckingMode
func (*EffectivePolicy) UnmarshalJSONFrom ¶
func (p *EffectivePolicy) UnmarshalJSONFrom(dec *jsontext.Decoder) error
func (EffectivePolicy) UserKnownHostsFiles ¶
func (p EffectivePolicy) UserKnownHostsFiles() KnownHostsList
type EnvFilter ¶
type EnvFilter struct {
// contains filtered or unexported fields
}
EnvFilter 表示 OpenSSH SendEnv 模式列表及 -PATTERN 减法语义的结合律幺半群。 正规形式 (clear, added) 在 Compose(higher, lower) 下先应用 lower 再应用 higher,满足结合律与单位元律。
func FoldEnvFilters ¶
func ParseEnvFilter ¶
ParseEnvFilter 解析空白分隔的一条或多条 SendEnv 模式(支持 PATTERN 与 -PATTERN)。
func ParseEnvFilterTokens ¶
ParseEnvFilterTokens 按序应用 SendEnv 令牌序列构造规范 EnvFilter。
func (EnvFilter) ClearPatterns ¶
func (EnvFilter) FilterNames ¶
type HopTarget ¶
type HopTarget struct {
// contains filtered or unexported fields
}
HopTarget 表示经严格校验的单个 ProxyJump 跳板目标([user@]host[:port] 或别名);零值恒无效。 IPv6 字面量必须使用方括号包裹,规范化输出保留方括号而 Host() 返回无方括号规范主机名供 %j 使用。
func ParseHopTarget ¶
ParseHopTarget 校验并规范化单个 ProxyJump 跳板目标,复用 ParseUsername 校验用户段并强制 IPv6 方括号语法。
func (HopTarget) MarshalText ¶
func (*HopTarget) UnmarshalText ¶
type HostNameSpec ¶
type HostNameSpec struct {
// contains filtered or unexported fields
}
HostNameSpec 表示 OpenSSH HostName 指令值(规范字面主机或 %h 模板,字面 '%' 统一按 '%%' 规范化存储);零值恒无效。
func HostNameSpecFromHost ¶
func HostNameSpecFromHost(host netaddr.CanonicalHost) (HostNameSpec, error)
HostNameSpecFromHost 由已校验字面 netaddr.CanonicalHost 构造 HostNameSpec(% -> %% 规范存储,保证带区 IPv6 双射往返)。
func ParseHostNameSpec ¶
func ParseHostNameSpec(raw string) (HostNameSpec, error)
ParseHostNameSpec 按 OpenSSH 模板语法解析 HostName(仅允许 %% 与 %h;含 %h 时探针校验,字面主机经 % -> %% 规范存储)。
func (HostNameSpec) AppendText ¶
func (h HostNameSpec) AppendText(b []byte) ([]byte, error)
func (HostNameSpec) Equal ¶
func (h HostNameSpec) Equal(o HostNameSpec) bool
func (HostNameSpec) MarshalText ¶
func (h HostNameSpec) MarshalText() ([]byte, error)
func (HostNameSpec) ResolveHost ¶
func (h HostNameSpec) ResolveHost(origHost netaddr.CanonicalHost) (z netaddr.CanonicalHost, err error)
ResolveHost 与 ResolveHostFor 基于规范主机或 OpenSSH 别名展开 HostNameSpec 为 netaddr.CanonicalHost。
func (HostNameSpec) ResolveHostFor ¶
func (h HostNameSpec) ResolveHostFor(origHost OriginalHostSpec) (z netaddr.CanonicalHost, err error)
func (*HostNameSpec) UnmarshalText ¶
func (h *HostNameSpec) UnmarshalText(t []byte) error
type KnownHostsList ¶
type KnownHostsList struct {
// contains filtered or unexported fields
}
KnownHostsList 表示专用于 OpenSSH UserKnownHostsFile 的独立不透明 FirstWins 幺半群。 单条指令支持空白分隔多路径或独立 "none"(禁止混用);跨指令与跨层严格 FirstWins,杜绝 HostKey 信任锚点跨层污染。
func DisabledKnownHostsList ¶
func DisabledKnownHostsList() KnownHostsList
func FoldKnownHostsLists ¶
func FoldKnownHostsLists(layers ...KnownHostsList) KnownHostsList
func NewKnownHostsList ¶
func NewKnownHostsList(entries ...PathEntry) (KnownHostsList, error)
func ParseKnownHostsList ¶
func ParseKnownHostsList(rawItems []string) (KnownHostsList, error)
func UnsetKnownHostsList ¶
func UnsetKnownHostsList() KnownHostsList
UnsetKnownHostsList、DisabledKnownHostsList、NewKnownHostsList 与 ParseKnownHostsList 构造 KnownHostsList。
func (KnownHostsList) Compose ¶
func (k KnownHostsList) Compose(lower KnownHostsList) KnownHostsList
func (KnownHostsList) DefaultsAllowed ¶
func (b KnownHostsList) DefaultsAllowed() bool
func (KnownHostsList) Equal ¶
func (k KnownHostsList) Equal(o KnownHostsList) bool
func (KnownHostsList) IsDisabled ¶
func (b KnownHostsList) IsDisabled() bool
func (KnownHostsList) MarshalJSONTo ¶
func (k KnownHostsList) MarshalJSONTo(e *jsontext.Encoder) error
func (KnownHostsList) State ¶
func (b KnownHostsList) State() PathListState
func (*KnownHostsList) UnmarshalJSONFrom ¶
func (k *KnownHostsList) UnmarshalJSONFrom(d *jsontext.Decoder) error
type OptionClass ¶
type OptionClass uint8
const ( OptionClassInvalid OptionClass = iota OptionClassTarget OptionClassMux OptionClassTransport OptionClassAuth OptionClassTrust OptionClassForward OptionClassSession OptionClassLocalExec )
type OptionKey ¶
type OptionKey string
const ( OptionKeyInvalid OptionKey = "" KeyHostName OptionKey = "hostname" KeyPort OptionKey = "port" KeyUser OptionKey = "user" KeyProxyJump OptionKey = "proxy_jump" KeyProxyCommand OptionKey = "proxy_command" KeyControlMaster OptionKey = "control_master" KeyControlPath OptionKey = "control_path" KeyControlPersist OptionKey = "control_persist" KeyConnectTimeout OptionKey = "connect_timeout" KeyServerAliveInterval OptionKey = "server_alive_interval" KeyServerAliveCountMax OptionKey = "server_alive_count_max" KeyCiphers OptionKey = "ciphers" KeyMACs OptionKey = "macs" KeyKexAlgorithms OptionKey = "kex_algorithms" KeyHostKeyAlgorithms OptionKey = "host_key_algorithms" KeyIdentityFile OptionKey = "identity_file" KeyCertificateFile OptionKey = "certificate_file" KeyIdentitiesOnly OptionKey = "identities_only" KeyBatchMode OptionKey = "batch_mode" KeyStrictHostKeyChecking OptionKey = "strict_host_key_checking" KeyUserKnownHostsFile OptionKey = "user_known_hosts_file" KeyForwardAgent OptionKey = "forward_agent" KeySendEnv OptionKey = "send_env" KeyPermitLocalCommand OptionKey = "permit_local_command" KeyLocalCommand OptionKey = "local_command" )
func CanonicalOptionKey ¶
CanonicalOptionKey 与 LookupOptionSpec 提供已注册 OpenSSH 选项的归一化与元数据查询。
func (OptionKey) MarshalText ¶
func (*OptionKey) UnmarshalText ¶
type OptionLayer ¶
type OptionLayer struct {
// contains filtered or unexported fields
}
OptionLayer 表示四层 OpenSSH 选项总幺半群 (OptionLayer, Compose, Unset) 的不可变层值对象。 零值代表单位元 UnsetOptionLayer;Compose 按正交分量复合,严格满足结合律与双侧单位元律。
func DefaultOptionLayer ¶
func DefaultOptionLayer() OptionLayer
DefaultOptionLayer 返回内置安全默认兜底层(位于四层 t1..t4 之后)。
func FoldOptionLayers ¶
func FoldOptionLayers(layers ...OptionLayer) OptionLayer
FoldOptionLayers 按从高优先级到低优先级顺序折叠多个 OptionLayer。
func ParseOptionLayer ¶
func ParseOptionLayer(directives ...string) (OptionLayer, error)
func (OptionLayer) ApplyParsedOption ¶
func (l OptionLayer) ApplyParsedOption(opt ParsedOption) OptionLayer
ApplyParsedOption 按同层自上而下 OpenSSH 语义将单条已解析选项合入当前层。
func (OptionLayer) CertificateFiles ¶
func (l OptionLayer) CertificateFiles() PathList
func (OptionLayer) Ciphers ¶
func (l OptionLayer) Ciphers() AlgoPolicy
func (OptionLayer) Compose ¶
func (l OptionLayer) Compose(lower OptionLayer) OptionLayer
Compose 执行高优先级 l 覆合低优先级 lower 的总幺半群运算(l ⊕ lower)。
func (OptionLayer) ConnectTimeout ¶
func (l OptionLayer) ConnectTimeout() algebraic.Option[algebraic.Duration]
func (OptionLayer) Control ¶
func (l OptionLayer) Control() ControlPolicy
func (OptionLayer) Equal ¶
func (l OptionLayer) Equal(o OptionLayer) bool
Equal 判断两个 OptionLayer 是否代表同一总幺半群元素。
func (OptionLayer) FilterForNonOpenSSHOrigin ¶
func (l OptionLayer) FilterForNonOpenSSHOrigin() OptionLayer
FilterForNonOpenSSHOrigin 按 INV-D2 对非 OpenSSH 来源节点的 t4(~/.ssh/config 层)执行安全裁剪: 严格仅保留 OptionClassMux ∪ OptionClassTransport(多路复用、超时/保活与算法协商), 完整剥离 Target、Auth(含 BatchMode 与 IdentitiesOnly)、Trust、Forward、Session 与 LocalExec。
func (OptionLayer) ForwardAgent ¶
func (l OptionLayer) ForwardAgent() algebraic.Option[bool]
func (OptionLayer) HostKeyAlgorithms ¶
func (l OptionLayer) HostKeyAlgorithms() AlgoPolicy
func (OptionLayer) HostName ¶
func (l OptionLayer) HostName() algebraic.Option[HostNameSpec]
OptionLayer 只读访问器(容器字段返回防御性拷贝,Proxy 永不返回 nil)。
func (OptionLayer) IdentitiesOnly ¶
func (l OptionLayer) IdentitiesOnly() algebraic.Option[bool]
func (OptionLayer) IdentityFiles ¶
func (l OptionLayer) IdentityFiles() PathList
func (OptionLayer) IsUnset ¶
func (l OptionLayer) IsUnset() bool
func (OptionLayer) IsZero ¶
func (l OptionLayer) IsZero() bool
func (OptionLayer) KexAlgorithms ¶
func (l OptionLayer) KexAlgorithms() AlgoPolicy
func (OptionLayer) LocalCommand ¶
func (l OptionLayer) LocalCommand() algebraic.Option[SanitizedCmd]
func (OptionLayer) MACs ¶
func (l OptionLayer) MACs() AlgoPolicy
func (OptionLayer) MarshalJSONTo ¶
func (l OptionLayer) MarshalJSONTo(enc *jsontext.Encoder) error
MarshalJSONTo 与 UnmarshalJSONFrom 实现 OptionLayer 与 EffectivePolicy 的 encoding/json/v2 确定性编解码。
func (OptionLayer) PermitLocalCommand ¶
func (l OptionLayer) PermitLocalCommand() algebraic.Option[bool]
func (OptionLayer) Proxy ¶
func (l OptionLayer) Proxy() ProxyRoute
func (OptionLayer) SendEnv ¶
func (l OptionLayer) SendEnv() EnvFilter
func (OptionLayer) ServerAliveCountMax ¶
func (l OptionLayer) ServerAliveCountMax() algebraic.Option[uint32]
func (OptionLayer) ServerAliveInterval ¶
func (l OptionLayer) ServerAliveInterval() algebraic.Option[algebraic.Duration]
func (OptionLayer) StrictHostKeyChecking ¶
func (l OptionLayer) StrictHostKeyChecking() algebraic.Option[StrictHostKeyCheckingMode]
func (*OptionLayer) UnmarshalJSONFrom ¶
func (l *OptionLayer) UnmarshalJSONFrom(dec *jsontext.Decoder) error
func (OptionLayer) UserKnownHostsFiles ¶
func (l OptionLayer) UserKnownHostsFiles() KnownHostsList
func (OptionLayer) WithBatchMode ¶
func (l OptionLayer) WithBatchMode(v bool) OptionLayer
func (OptionLayer) WithCertificateFiles ¶
func (l OptionLayer) WithCertificateFiles(p PathList) OptionLayer
func (OptionLayer) WithCiphers ¶
func (l OptionLayer) WithCiphers(p AlgoPolicy) OptionLayer
func (OptionLayer) WithConnectTimeout ¶
func (l OptionLayer) WithConnectTimeout(d algebraic.Duration) OptionLayer
func (OptionLayer) WithControlPolicy ¶
func (l OptionLayer) WithControlPolicy(c ControlPolicy) OptionLayer
func (OptionLayer) WithForwardAgent ¶
func (l OptionLayer) WithForwardAgent(v bool) OptionLayer
func (OptionLayer) WithHostKeyAlgorithms ¶
func (l OptionLayer) WithHostKeyAlgorithms(p AlgoPolicy) OptionLayer
func (OptionLayer) WithHostName ¶
func (l OptionLayer) WithHostName(h HostNameSpec) OptionLayer
OptionLayer 不可变构造器链:所有 With* 返回新副本,绝不修改接收者。
func (OptionLayer) WithIdentitiesOnly ¶
func (l OptionLayer) WithIdentitiesOnly(v bool) OptionLayer
func (OptionLayer) WithIdentityFiles ¶
func (l OptionLayer) WithIdentityFiles(p PathList) OptionLayer
func (OptionLayer) WithKexAlgorithms ¶
func (l OptionLayer) WithKexAlgorithms(p AlgoPolicy) OptionLayer
func (OptionLayer) WithLocalCommand ¶
func (l OptionLayer) WithLocalCommand(c SanitizedCmd) OptionLayer
func (OptionLayer) WithMACs ¶
func (l OptionLayer) WithMACs(p AlgoPolicy) OptionLayer
func (OptionLayer) WithPermitLocalCommand ¶
func (l OptionLayer) WithPermitLocalCommand(v bool) OptionLayer
func (OptionLayer) WithPort ¶
func (l OptionLayer) WithPort(p uint16) OptionLayer
func (OptionLayer) WithProxyRoute ¶
func (l OptionLayer) WithProxyRoute(r ProxyRoute) OptionLayer
func (OptionLayer) WithSendEnv ¶
func (l OptionLayer) WithSendEnv(f EnvFilter) OptionLayer
func (OptionLayer) WithServerAliveCountMax ¶
func (l OptionLayer) WithServerAliveCountMax(n uint32) OptionLayer
func (OptionLayer) WithServerAliveInterval ¶
func (l OptionLayer) WithServerAliveInterval(d algebraic.Duration) OptionLayer
func (OptionLayer) WithStrictHostKeyChecking ¶
func (l OptionLayer) WithStrictHostKeyChecking(m StrictHostKeyCheckingMode) OptionLayer
func (OptionLayer) WithUser ¶
func (l OptionLayer) WithUser(u Username) OptionLayer
func (OptionLayer) WithUserKnownHostsFiles ¶
func (l OptionLayer) WithUserKnownHostsFiles(p KnownHostsList) OptionLayer
type OptionSpec ¶
type OptionSpec struct {
Key OptionKey // 规范化 snake_case 键名
OpenSSHName string // 标准 OpenSSH ssh_config(5) 关键字
Class OptionClass // 所属安全与功能分类
WholeLineCommand bool // 指示值保留整行命令语义
}
OptionSpec 描述单个已注册 OpenSSH 选项的元数据。
func LookupOptionSpec ¶
func LookupOptionSpec(key OptionKey) (OptionSpec, bool)
type OriginKind ¶
type OriginKind uint8
OriginKind 标识目标连接的来源分类(与 inventory.NodeOrigin 语义同构而零循环依赖);零值 OriginInvalid 失败关闭。
const ( OriginInvalid OriginKind = iota // 未初始化/非法来源(零值失败关闭) OriginManaged // XOps 托管资产节点(按 INV-D2 仅对 t4 执行安全裁剪) OriginOpenSSHVirtual // ~/.ssh/config 只读虚拟节点(完整应用 t4) OriginOpenSSHDerived // 纯 OpenSSH Host 派生节点(完整应用 t4) OriginAdHoc // 临时 user@host 或未持久化派生会话(按 INV-D2 仅对 t4 执行安全裁剪) )
func ParseOriginKind ¶
func ParseOriginKind(raw string) (OriginKind, error)
ParseOriginKind 解析规范策略来源分类文本,严格拒绝控制与格式字符。
func (OriginKind) AllowsFullOpenSSHConfig ¶
func (o OriginKind) AllowsFullOpenSSHConfig() bool
func (OriginKind) AppendText ¶
func (o OriginKind) AppendText(b []byte) ([]byte, error)
func (OriginKind) IsValid ¶
func (o OriginKind) IsValid() bool
func (OriginKind) MarshalText ¶
func (o OriginKind) MarshalText() ([]byte, error)
func (OriginKind) String ¶
func (o OriginKind) String() string
func (*OriginKind) UnmarshalText ¶
func (o *OriginKind) UnmarshalText(text []byte) error
type OriginalHostSpec ¶
type OriginalHostSpec struct {
// contains filtered or unexported fields
}
OriginalHostSpec 表示经严格校验的 SSH 原始主机名、IP 或 OpenSSH Host 别名(供 %n 展开与审计留痕)。 允许规范 IP(含带区 IPv6)、规范 DNS 及合法非 IP OpenSSH/NodeID 别名(保留大小写,如 "prod_db"、"bastion.01"); 严格拒绝控制/空白/Shell 元字符、保留字 "none"、前导 '-'、尾随 '.' 与畸形数值 SSRF IP 形态;零值恒无效。
func OriginalHostFromCanonical ¶
func OriginalHostFromCanonical(host netaddr.CanonicalHost) (OriginalHostSpec, error)
OriginalHostFromCanonical 由已校验的 netaddr.CanonicalHost 构造 OriginalHostSpec。
func ParseOriginalHost ¶
func ParseOriginalHost(raw string) (OriginalHostSpec, error)
ParseOriginalHost 校验并构造原始主机/别名值对象(IP 字面量规范化,非 IP 别名保留大小写)。
func (OriginalHostSpec) AppendText ¶
func (h OriginalHostSpec) AppendText(b []byte) ([]byte, error)
func (OriginalHostSpec) CanonicalHost ¶
func (h OriginalHostSpec) CanonicalHost() (netaddr.CanonicalHost, bool)
func (OriginalHostSpec) Equal ¶
func (h OriginalHostSpec) Equal(o OriginalHostSpec) bool
OriginalHostSpec 只读访问器与文本编解码方法。
func (OriginalHostSpec) MarshalText ¶
func (h OriginalHostSpec) MarshalText() ([]byte, error)
func (*OriginalHostSpec) UnmarshalText ¶
func (h *OriginalHostSpec) UnmarshalText(t []byte) error
type ParsedOption ¶
type ParsedOption struct {
// contains filtered or unexported fields
}
ParsedOption 表示经严格语法与值域校验的单条 OpenSSH 选项解析结果;零值恒无效。
func ParseOption ¶
func ParseOption(directive string) (ParsedOption, error)
ParseOption、ParseOptionKV 与 ParseOptionLayer 严格解析并折叠单条或多条 OpenSSH 指令(大小写无关,未知/畸形/注入一律失败关闭)。
func ParseOptionKV ¶
func ParseOptionKV(key, value string) (ParsedOption, error)
func (ParsedOption) IsValid ¶
func (p ParsedOption) IsValid() bool
IsValid、Key、Spec、RawValue 与 Layer 为 ParsedOption 只读访问器。
func (ParsedOption) Key ¶
func (p ParsedOption) Key() OptionKey
func (ParsedOption) Layer ¶
func (p ParsedOption) Layer() OptionLayer
func (ParsedOption) RawValue ¶
func (p ParsedOption) RawValue() string
func (ParsedOption) Spec ¶
func (p ParsedOption) Spec() OptionSpec
type PathEntry ¶
type PathEntry struct {
// contains filtered or unexported fields
}
PathEntry 表示经校验的单个 OpenSSH 路径配置项;零值恒无效。
func ParsePathEntry ¶
ParsePathEntry 严格校验并构造 PathEntry;拒绝空串、控制字符、非法占位符与保留字 "none"。
func (PathEntry) IsTemplate ¶
func (PathEntry) Kind ¶
func (e PathEntry) Kind() PathEntryKind
func (PathEntry) MarshalText ¶
func (*PathEntry) UnmarshalText ¶
type PathEntryKind ¶
type PathEntryKind uint8
PathEntryKind 与 PathListState 分别为路径项形态与路径集合状态枚举;零值代表无效或未设置单位元。
const ( PathEntryInvalid PathEntryKind = iota // 无效路径项(零值失败关闭) PathEntryLiteral // 字面路径 PathEntryTemplate // 含 OpenSSH % 或 ${VAR} 的模板路径 )
func (PathEntryKind) String ¶
func (k PathEntryKind) String() string
String 返回 PathEntryKind 与 PathListState 的可读名称。
type PathList ¶
type PathList struct {
// contains filtered or unexported fields
}
PathList 表示专用于 OpenSSH IdentityFile / CertificateFile 的三态累积路径幺半群 (PathList, Compose, Unset)。 Unset 为单位元,Disabled("none") 作为左零元吸收一切低优先级层,terminated 右封口位严格保证结合律。
func DisabledPathList ¶
func DisabledPathList() PathList
func FoldPathLists ¶
func NewPathList ¶
func ParsePathListEntries ¶
func UnsetPathList ¶
func UnsetPathList() PathList
UnsetPathList、DisabledPathList、NewPathList 与 ParsePathListEntries 构造 PathList。
func (PathList) DefaultsAllowed ¶
func (b PathList) DefaultsAllowed() bool
func (PathList) IsDisabled ¶
func (b PathList) IsDisabled() bool
func (PathList) MarshalJSONTo ¶
MarshalJSONTo 与 UnmarshalJSONFrom 实现 PathList、KnownHostsList、AlgoPolicy、EnvFilter 与 ControlPolicy 的 json/v2 确定性编解码。
func (PathList) State ¶
func (b PathList) State() PathListState
type PathListState ¶
type PathListState uint8
const ( PathListUnset PathListState = iota // 未设置(单位元,允许默认路径回退) PathListDisabled // 显式 "none" 禁用(吸收低优先级右操作数) PathListSet // 含至少一个有序去重路径项 )
func (PathListState) String ¶
func (s PathListState) String() string
type ProxyCommandSpec ¶
type ProxyCommandSpec struct {
// contains filtered or unexported fields
}
func NewProxyCommandSpec ¶
func NewProxyCommandSpec(cmd SanitizedCmd) (*ProxyCommandSpec, error)
func (*ProxyCommandSpec) Command ¶
func (c *ProxyCommandSpec) Command() SanitizedCmd
func (*ProxyCommandSpec) IsValid ¶
func (c *ProxyCommandSpec) IsValid() bool
func (ProxyCommandSpec) MarshalJSONTo ¶
func (c ProxyCommandSpec) MarshalJSONTo(e *jsontext.Encoder) error
type ProxyDisabled ¶
type ProxyDisabled struct {
// contains filtered or unexported fields
}
func NewProxyDisabled ¶
func NewProxyDisabled() *ProxyDisabled
func NewProxyJumpDisabled ¶
func NewProxyJumpDisabled() *ProxyDisabled
func (*ProxyDisabled) IsFullDisable ¶
func (d *ProxyDisabled) IsFullDisable() bool
func (*ProxyDisabled) IsJumpOnly ¶
func (d *ProxyDisabled) IsJumpOnly() bool
func (ProxyDisabled) MarshalJSONTo ¶
func (d ProxyDisabled) MarshalJSONTo(e *jsontext.Encoder) error
type ProxyJumpChain ¶
type ProxyJumpChain struct {
// contains filtered or unexported fields
}
func NewProxyJumpChain ¶
func NewProxyJumpChain(hops algebraic.NonEmpty[HopTarget]) (*ProxyJumpChain, error)
func (*ProxyJumpChain) IsValid ¶
func (j *ProxyJumpChain) IsValid() bool
func (ProxyJumpChain) MarshalJSONTo ¶
func (j ProxyJumpChain) MarshalJSONTo(e *jsontext.Encoder) error
type ProxyRoute ¶
type ProxyRoute interface {
// contains filtered or unexported methods
}
ProxyRoute 表示 OpenSSH ProxyJump / ProxyCommand 路由配置的封闭和类型(Sealed Sum Type)。 四变体:*ProxyUnset、*ProxyDisabled(全禁用或仅禁跳板)、*ProxyJumpChain(含遮蔽命令槽)、*ProxyCommandSpec。
func ComposeProxyRoute ¶
func ComposeProxyRoute(higher, lower ProxyRoute) ProxyRoute
func FoldProxyRoutes ¶
func FoldProxyRoutes(layers ...ProxyRoute) ProxyRoute
func ParseProxyCommand ¶
func ParseProxyCommand(raw string) (ProxyRoute, error)
func ParseProxyJump ¶
func ParseProxyJump(raw string) (ProxyRoute, error)
ParseProxyJump 与 ParseProxyCommand 解析 OpenSSH 代理路由指令。
func UnmarshalProxyRouteFrom ¶
func UnmarshalProxyRouteFrom(dec *jsontext.Decoder) (ProxyRoute, error)
type ProxyUnset ¶
type ProxyUnset struct{}
ProxyUnset、ProxyDisabled、ProxyJumpChain 与 ProxyCommandSpec 为 ProxyRoute 全部封闭变体。
func NewProxyUnset ¶
func NewProxyUnset() *ProxyUnset
func (ProxyUnset) MarshalJSONTo ¶
func (u ProxyUnset) MarshalJSONTo(e *jsontext.Encoder) error
MarshalJSONTo 为四个具体 ProxyRoute 变体提供值接收者 json/v2 编码(无效零值失败关闭)。
type SanitizedCmd ¶
type SanitizedCmd struct {
// contains filtered or unexported fields
}
SanitizedCmd 表示经单行与安全字符校验的命令模板(ProxyCommand / LocalCommand);零值恒无效。
func NewLocalSanitizedCmd ¶
func NewLocalSanitizedCmd(raw string) (SanitizedCmd, error)
func NewProxySanitizedCmd ¶
func NewProxySanitizedCmd(raw string) (SanitizedCmd, error)
func NewSanitizedCmd ¶
func NewSanitizedCmd(raw string) (SanitizedCmd, error)
NewSanitizedCmd、NewProxySanitizedCmd 与 NewLocalSanitizedCmd 构造并校验单行命令模板。 NewSanitizedCmd 默认强制 INV-D4 占位符白名单(%%/%C/%d/%h/%i/%j/%L/%l/%n/%p/%r/%u); NewProxySanitizedCmd 进一步收紧为 ssh_config(5) ProxyCommand 占位符(%%/%h/%n/%p/%r)。
func (SanitizedCmd) AppendText ¶
func (c SanitizedCmd) AppendText(b []byte) ([]byte, error)
func (SanitizedCmd) Equal ¶
func (c SanitizedCmd) Equal(o SanitizedCmd) bool
func (SanitizedCmd) MarshalText ¶
func (c SanitizedCmd) MarshalText() ([]byte, error)
func (*SanitizedCmd) UnmarshalText ¶
func (c *SanitizedCmd) UnmarshalText(text []byte) error
type StrictHostKeyCheckingMode ¶
type StrictHostKeyCheckingMode uint8
const ( StrictHostKeyCheckingUnset StrictHostKeyCheckingMode = iota StrictHostKeyCheckingYes StrictHostKeyCheckingNo StrictHostKeyCheckingAsk StrictHostKeyCheckingAcceptNew )
func ParseStrictHostKeyChecking ¶
func ParseStrictHostKeyChecking(raw string) (StrictHostKeyCheckingMode, error)
ParseStrictHostKeyChecking 解析 StrictHostKeyChecking(yes/no/ask/accept-new),拒绝控制与格式字符。
func (StrictHostKeyCheckingMode) AppendText ¶
func (m StrictHostKeyCheckingMode) AppendText(b []byte) ([]byte, error)
func (StrictHostKeyCheckingMode) MarshalText ¶
func (m StrictHostKeyCheckingMode) MarshalText() ([]byte, error)
func (StrictHostKeyCheckingMode) String ¶
func (m StrictHostKeyCheckingMode) String() string
func (*StrictHostKeyCheckingMode) UnmarshalText ¶
func (m *StrictHostKeyCheckingMode) UnmarshalText(text []byte) error
type TokenContext ¶
type TokenContext struct {
LocalHost string // 本机完整主机名(%l,%L 取首个 '.' 之前前缀)
TargetHost string // 规范化远端目标主机名或 IP(%h)
Port uint16 // 目标 SSH 端口(%p,位于 [1, 65535])
RemoteUser string // 远端用户名(%r,空时回退至 LocalUser)
OriginalHost string // 原始主机或别名(%n,空时回退至 TargetHost)
LocalUser string // 本机用户名(%u)
LocalUID string // 本机数值 UID(%i)
HomeDir string // 本机用户主目录(%d)
JumpHost string // 活跃 ProxyJump 末跳无方括号规范主机名(%j,无跳板时为空串)
}
TokenContext 为 OpenSSH % token 纯字符串展开提供全部显式输入(零 os.Hostname / os/user 隐式访问)。
type Username ¶
type Username struct {
// contains filtered or unexported fields
}
Username 表示经严格校验的 SSH 用户名值对象;零值恒无效。
func ParseUsername ¶
ParseUsername 校验 SSH 用户名(拒绝空白、控制字符、'.'/'..'、'/'、':'、'['、']'、'@'、前导 '-' 与 Shell 元字符)。