Documentation
¶
Index ¶
- func BootstrapConfig(settings config.Settings) ([]byte, error)
- func CompiledAssetDigest(ctx context.Context, goos, arch, tag, channel string) (string, error)
- func DetectVerifiedVersion(ctx context.Context, v *VerifiedCore, x VerifiedExecutor) (string, error)
- func DetectVersion(ctx context.Context, runner CommandRunner, binaryPath string) (string, error)
- func DownloadMigrationCore(ctx context.Context, client *http.Client, goos, arch, tag string) ([]byte, []byte, error)
- func EnsureRuntimeConfig(path string, settings config.Settings) error
- func ParseAlphaSHA(name string) string
- func ParseVersion(output string) (string, error)
- func RebuildMigrationCore(ctx context.Context, goos, arch, tag string, archive []byte) ([]byte, []byte, error)
- func RecoverProvenance(ctx context.Context, s ProvenanceStore) error
- func ValidateConfig(ctx context.Context, runner CommandRunner, ...) error
- func ValidateVerifiedConfig(ctx context.Context, v *VerifiedCore, c *ConfigCapability, x VerifiedExecutor) error
- func VerifyCompiledAssetDigest(ctx context.Context, goos, arch, tag, channel, digestHex string) error
- func WriteBootstrapConfig(path string, settings config.Settings) error
- type Asset
- type Candidate
- type CommandRunner
- type ConfigCapability
- type CoreCommand
- type CorePurpose
- type GeneratedConfig
- type InstallRequest
- type InstallResult
- type Installer
- func (i Installer) DetectVersion(ctx context.Context, binaryPath string) (string, error)
- func (i Installer) Download(ctx context.Context, asset Asset, destination string) error
- func (i Installer) Install(ctx context.Context, request InstallRequest) (InstallResult, error)
- func (i Installer) LatestRelease(ctx context.Context, channel string) (Release, error)
- func (i Installer) Prepare(ctx context.Context, request InstallRequest) (PreparedCore, error)
- type LocalCoreInfo
- type OSCommandRunner
- type OSVerifiedExecutor
- type PreparedCore
- type ProvenanceMutation
- type ProvenanceObject
- type ProvenanceReceipt
- type ProvenanceRole
- type ProvenanceStore
- type Release
- type ResourceActivation
- func (a *ResourceActivation) Close()
- func (a *ResourceActivation) Publish(ctx context.Context, resources *subscription.ResourceActivation) (*ConfigCapability, error)
- func (a *ResourceActivation) Restore(ctx context.Context, resources *subscription.ResourceActivation) (*ConfigCapability, error)
- func (a *ResourceActivation) Validate(ctx context.Context, resources *subscription.ResourceActivation) error
- type TrustedExecution
- func (t *TrustedExecution) BeginResourceActivation(ctx context.Context) (*ResourceActivation, error)
- func (t *TrustedExecution) BuildConfig(ctx context.Context, input subscription.PolicyInput) (*GeneratedConfig, error)
- func (t *TrustedExecution) CheckPaths(root, binary, configuration string) error
- func (t *TrustedExecution) CommittedConfig(ctx context.Context) (*ConfigCapability, error)
- func (t *TrustedExecution) InitializeConfig(ctx context.Context, settings config.Settings, input subscription.PolicyInput) error
- func (t *TrustedExecution) InstalledAvailable(ctx context.Context) (bool, error)
- func (t *TrustedExecution) Installer() Installer
- func (t *TrustedExecution) PrepareGenerated(ctx context.Context, output subscription.PolicyOutput) (*GeneratedConfig, error)
- func (t *TrustedExecution) PreviousConfig(ctx context.Context) ([]byte, error)
- func (t *TrustedExecution) Provenance() ProvenanceStore
- func (t *TrustedExecution) Publish(ctx context.Context, g *GeneratedConfig, expected [32]byte) (*ConfigCapability, error)
- func (t *TrustedExecution) RestoreConfig(ctx context.Context, previous []byte) (*ConfigCapability, error)
- func (t *TrustedExecution) RunCommand(ctx context.Context) (CoreCommand, func() error, error)
- type VerifiedCore
- type VerifiedExecutor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompiledAssetDigest ¶ added in v0.9.3
CompiledAssetDigest returns the compiled SHA-256 for one supported Unix core.
func DetectVerifiedVersion ¶ added in v0.9.3
func DetectVerifiedVersion(ctx context.Context, v *VerifiedCore, x VerifiedExecutor) (string, error)
DetectVerifiedVersion verifies the pair/candidate again immediately before -v.
func DetectVersion ¶
func DownloadMigrationCore ¶ added in v0.9.3
func DownloadMigrationCore(ctx context.Context, client *http.Client, goos, arch, tag string) ([]byte, []byte, error)
DownloadMigrationCore retrieves only the pinned supported asset, then derives a receipt from the independently compiled digest rather than a source receipt.
func ParseAlphaSHA ¶ added in v0.5.0
func ParseVersion ¶
func RebuildMigrationCore ¶ added in v0.9.3
func RebuildMigrationCore(ctx context.Context, goos, arch, tag string, archive []byte) ([]byte, []byte, error)
RebuildMigrationCore verifies a compressed artifact against the compiled Unix table and derives both core bytes and provenance. It never executes the core.
func RecoverProvenance ¶ added in v0.9.3
func RecoverProvenance(ctx context.Context, s ProvenanceStore) error
RecoverProvenance converges the entire pair before any core execution. The caller must hold the daemon/maintenance lifecycle lease with no core running.
func ValidateConfig ¶
func ValidateConfig(ctx context.Context, runner CommandRunner, binaryPath, dataDir, configPath string) error
func ValidateVerifiedConfig ¶ added in v0.9.3
func ValidateVerifiedConfig(ctx context.Context, v *VerifiedCore, c *ConfigCapability, x VerifiedExecutor) error
ValidateVerifiedConfig preserves the selected candidate identity and hash.
func VerifyCompiledAssetDigest ¶ added in v0.9.3
func VerifyCompiledAssetDigest(ctx context.Context, goos, arch, tag, channel, digestHex string) error
VerifyCompiledAssetDigest checks a digest against the compiled Unix core table. Callers must obtain the digest from an independent TLS checksum or a root-only offline manifest; a user-supplied request hash is not the trust root.
Types ¶
type Asset ¶
type Candidate ¶
type Candidate struct {
// contains filtered or unexported fields
}
func (*Candidate) Commit ¶
func (c *Candidate) Commit() (InstallResult, error)
type CommandRunner ¶
type ConfigCapability ¶ added in v0.9.3
type ConfigCapability struct {
// contains filtered or unexported fields
}
ConfigCapability binds a selected generated candidate or committed config.
func BindGeneratedConfig ¶ added in v0.9.3
func BindGeneratedConfig(ctx context.Context, data *platform.TrustedRoot, relative string, expectedSHA256 [32]byte) (*ConfigCapability, error)
BindGeneratedConfig borrows D and owns a held read descriptor and its parent. expectedSHA256 must be computed by Manager from fresh RootConfigPolicy output.
func (*ConfigCapability) Close ¶ added in v0.9.3
func (c *ConfigCapability) Close() error
type CoreCommand ¶ added in v0.9.3
CoreCommand is the complete command produced by verified capabilities.
type CorePurpose ¶ added in v0.9.3
type CorePurpose uint8
CorePurpose selects exactly one supported command shape.
const ( CoreVersion CorePurpose = iota CoreValidate CoreRun )
type GeneratedConfig ¶ added in v0.9.3
type GeneratedConfig struct {
// contains filtered or unexported fields
}
GeneratedConfig retains the exact policy output selected for validation.
func (*GeneratedConfig) Close ¶ added in v0.9.3
func (g *GeneratedConfig) Close() error
Close retires a generated candidate; identity mismatch leaves the object intact.
func (*GeneratedConfig) Hash ¶ added in v0.9.3
func (g *GeneratedConfig) Hash() [32]byte
Hash is the hash of the generated bytes, never a caller-supplied trust root.
type InstallRequest ¶
type InstallResult ¶
type Installer ¶
type Installer struct {
// Provenance selects the trusted root route; nil preserves legacy platforms.
Provenance ProvenanceStore
GeneratedConfig func(context.Context) (*ConfigCapability, error)
Executor VerifiedExecutor
HTTPClient *http.Client
APIBase string
Repository string
GOOS string
GOARCH string
Runner CommandRunner
CheckTimeout time.Duration // 包住"检查最新版"请求,默认 8s;下载仍用 httpClient 超时(design §4.3)
}
func (Installer) DetectVersion ¶ added in v0.2.0
DetectVersion 报告现有核心二进制的版本(运行 mihomo -v)。供 runtime 侧 setup 本地预检 复用,避免在 runtime.Manager 里另持 Runner;判据复用 DetectVersion(含 ParseVersion 版本 格式校验),与 Prepare 的同版本短路同一判据、DRY(design §4.3 实现位置)。
func (Installer) Download ¶ added in v0.2.0
Download 取 asset 并落盘到 destination,校验 asset.Digest 的 sha256:<hex> (bundler 复用入口,design §4.1 export 边界;绝不照 self.go 复刻——其无 Digest 校验)。 以 O_WRONLY|O_TRUNC 写入:调用方需先落盘目标文件(与 Prepare 内 CreateTemp 同契约)。
func (Installer) Install ¶
func (i Installer) Install(ctx context.Context, request InstallRequest) (InstallResult, error)
func (Installer) LatestRelease ¶ added in v0.2.0
LatestRelease 取 mihomo 最新 release(bundler 复用入口,design §4.1 export 边界)。 channel=="alpha" 走滚动 tag Prerelease-Alpha;其余(含空)走 /releases/latest。
func (Installer) Prepare ¶
func (i Installer) Prepare(ctx context.Context, request InstallRequest) (PreparedCore, error)
type LocalCoreInfo ¶ added in v0.4.0
LocalCoreInfo reports whether an existing local core binary satisfies setup without a network download. Ready mirrors the Install setup fast-path predicate (DetectVersion success + non-empty version), kept DRY with manager.Install (design §4.3). Read-only; never persists or mutates state.
type OSCommandRunner ¶
type OSCommandRunner struct{}
type OSVerifiedExecutor ¶ added in v0.9.3
type OSVerifiedExecutor struct{}
OSVerifiedExecutor explicitly assigns the allowlisted environment.
func (OSVerifiedExecutor) Execute ¶ added in v0.9.3
func (OSVerifiedExecutor) Execute(ctx context.Context, c CoreCommand) ([]byte, error)
type PreparedCore ¶
type PreparedCore interface {
Version() string
Updated() bool
Commit() (InstallResult, error)
Cleanup()
}
type ProvenanceMutation ¶ added in v0.9.3
type ProvenanceMutation struct {
Role, Source ProvenanceRole
Transaction string
Expected, SourceExpected ProvenanceObject
}
ProvenanceMutation replaces/removes one observed fixed-role object.
type ProvenanceObject ¶ added in v0.9.3
type ProvenanceObject struct {
Present bool `json:"present"`
SHA256 string `json:"sha256,omitempty"`
Identity string `json:"identity,omitempty"`
BootID string `json:"boot_id,omitempty"`
}
ProvenanceObject is an observation, not authority to bypass store checks.
type ProvenanceReceipt ¶ added in v0.9.3
type ProvenanceReceipt struct {
Schema string `json:"schema"`
PolicyID string `json:"policy_id"`
AssetSHA256 string `json:"asset_sha256"`
BinarySHA256 string `json:"binary_sha256"`
OS string `json:"os"`
Arch string `json:"arch"`
Tag string `json:"tag"`
}
ProvenanceReceipt records a binary derived from an immutable supported asset. Receipts are accepted only from the private store, never from a caller or migration tree.
type ProvenanceRole ¶ added in v0.9.3
type ProvenanceRole string
ProvenanceRole identifies a fixed object within the private data root.
const ( InstalledBinary ProvenanceRole = "binary" InstalledReceipt ProvenanceRole = "receipt" CandidateBinary ProvenanceRole = "candidate_binary" CandidateReceipt ProvenanceRole = "candidate_receipt" BackupBinary ProvenanceRole = "backup_binary" BackupReceipt ProvenanceRole = "backup_receipt" RestoreBinary ProvenanceRole = "restore_binary" RestoreReceipt ProvenanceRole = "restore_receipt" QuarantineBinary ProvenanceRole = "quarantine_binary" QuarantineReceipt ProvenanceRole = "quarantine_receipt" PairJournal ProvenanceRole = "journal" TransactionMarker ProvenanceRole = "transaction_marker" )
type ProvenanceStore ¶ added in v0.9.3
type ProvenanceStore interface {
Load(context.Context, ProvenanceRole, string) ([]byte, error)
Save(context.Context, ProvenanceRole, string, []byte) error
Apply(context.Context, ProvenanceMutation) error
Inspect(context.Context, ProvenanceRole, string) (ProvenanceObject, error)
Sync(context.Context) error
// contains filtered or unexported methods
}
ProvenanceStore is implemented by the core-owned Unix capability adapter. Its private method prevents callers from supplying an untrusted path/hash store.
func NewProvenanceStore ¶ added in v0.9.3
func NewProvenanceStore(ctx context.Context, data *platform.TrustedRoot) (ProvenanceStore, error)
NewProvenanceStore borrows a root-owned 0700 D capability. The caller keeps D and its lifecycle lease alive until all store/config/core capabilities close.
type ResourceActivation ¶
type ResourceActivation struct {
// contains filtered or unexported fields
}
ResourceActivation owns core execution while fixed home resources are staged. The supervisor must already have stopped and joined the managed child.
func (*ResourceActivation) Close ¶
func (a *ResourceActivation) Close()
Close releases execution after publication or complete rollback has converged.
func (*ResourceActivation) Publish ¶
func (a *ResourceActivation) Publish(ctx context.Context, resources *subscription.ResourceActivation) (*ConfigCapability, error)
Publish performs the WAL-owned config rename and binds the resulting fixed file as the only configuration capability accepted by future core starts.
func (*ResourceActivation) Restore ¶
func (a *ResourceActivation) Restore(ctx context.Context, resources *subscription.ResourceActivation) (*ConfigCapability, error)
Restore rolls the typed WAL back as one set and rebinds the exact previous config before execution ownership is released. Cancellation cannot detach it.
func (*ResourceActivation) Validate ¶
func (a *ResourceActivation) Validate(ctx context.Context, resources *subscription.ResourceActivation) error
Validate checks the exact policy-generated config against the fixed resource home.
type TrustedExecution ¶ added in v0.9.3
type TrustedExecution struct {
// contains filtered or unexported fields
}
TrustedExecution binds core and generated configuration IO to one trusted D. Unix construction borrows D; no public fields can replace its authorities.
func NewTrustedExecution ¶ added in v0.9.3
func NewTrustedExecution(ctx context.Context, data *platform.TrustedRoot, executor VerifiedExecutor) (*TrustedExecution, error)
NewTrustedExecution borrows the root-owned data capability and an optional test executor. The daemon closes all capabilities before releasing its lease.
func (*TrustedExecution) BeginResourceActivation ¶
func (t *TrustedExecution) BeginResourceActivation(ctx context.Context) (*ResourceActivation, error)
BeginResourceActivation excludes commands and core installation until Close.
func (*TrustedExecution) BuildConfig ¶
func (t *TrustedExecution) BuildConfig(ctx context.Context, input subscription.PolicyInput) (*GeneratedConfig, error)
BuildConfig runs the immutable typed policy before a byte can become a root candidate.
func (*TrustedExecution) CheckPaths ¶ added in v0.9.3
func (t *TrustedExecution) CheckPaths(root, binary, configuration string) error
CheckPaths prevents a root assembly from mixing capabilities with another tree.
func (*TrustedExecution) CommittedConfig ¶ added in v0.9.3
func (t *TrustedExecution) CommittedConfig(ctx context.Context) (*ConfigCapability, error)
CommittedConfig requires the hash accepted by initialization or publication.
func (*TrustedExecution) InitializeConfig ¶ added in v0.9.3
func (t *TrustedExecution) InitializeConfig(ctx context.Context, settings config.Settings, input subscription.PolicyInput) error
InitializeConfig applies the typed policy to persisted bytes before accepting them. Missing configuration uses a policy-generated bootstrap. Provider/Geo resources are supplied by the resource preparation owner before this call.
func (*TrustedExecution) InstalledAvailable ¶ added in v0.9.3
func (t *TrustedExecution) InstalledAvailable(ctx context.Context) (bool, error)
InstalledAvailable distinguishes a true green install from a broken pair.
func (*TrustedExecution) Installer ¶ added in v0.9.3
func (t *TrustedExecution) Installer() Installer
Installer returns the root installer; path/args Runner is never used.
func (*TrustedExecution) PrepareGenerated ¶ added in v0.9.3
func (t *TrustedExecution) PrepareGenerated(ctx context.Context, output subscription.PolicyOutput) (*GeneratedConfig, error)
PrepareGenerated receives only fresh policy output from Manager's generator. The caller's revision check remains in the mutation coordinator.
func (*TrustedExecution) PreviousConfig ¶ added in v0.9.3
func (t *TrustedExecution) PreviousConfig(ctx context.Context) ([]byte, error)
PreviousConfig captures the last bound bytes for rollback under the mutation lease.
func (*TrustedExecution) Provenance ¶ added in v0.9.3
func (t *TrustedExecution) Provenance() ProvenanceStore
Provenance returns the fixed-role store for startup recovery under the lease.
func (*TrustedExecution) Publish ¶ added in v0.9.3
func (t *TrustedExecution) Publish(ctx context.Context, g *GeneratedConfig, expected [32]byte) (*ConfigCapability, error)
Publish verifies the selected candidate again and atomically writes those same bytes. Manager invokes this only after its mutation/revision check, then reloads.
func (*TrustedExecution) RestoreConfig ¶ added in v0.9.3
func (t *TrustedExecution) RestoreConfig(ctx context.Context, previous []byte) (*ConfigCapability, error)
RestoreConfig reinstalls bytes captured through PreviousConfig, then rebinds.
func (*TrustedExecution) RunCommand ¶ added in v0.9.3
func (t *TrustedExecution) RunCommand(ctx context.Context) (CoreCommand, func() error, error)
RunCommand obtains a fresh installed pair plus committed configuration for Start. release must run after OS Start, including any failed Start path.
type VerifiedCore ¶ added in v0.9.3
type VerifiedCore struct {
// contains filtered or unexported fields
}
VerifiedCore holds the installed pair or a private, authenticated candidate. Its zero value is unusable; callers cannot fill in trust identities.
func OpenInstalledCore ¶ added in v0.9.3
func OpenInstalledCore(ctx context.Context, s ProvenanceStore) (*VerifiedCore, error)
OpenInstalledCore verifies the recovered installed receipt and binary before opening an execution capability. It never recovers while a process may run.
func (*VerifiedCore) Close ¶ added in v0.9.3
func (c *VerifiedCore) Close() error
func (*VerifiedCore) Command ¶ added in v0.9.3
func (c *VerifiedCore) Command(ctx context.Context, purpose CorePurpose, configuration *ConfigCapability) (CoreCommand, error)
type VerifiedExecutor ¶ added in v0.9.3
type VerifiedExecutor interface {
Execute(context.Context, CoreCommand) ([]byte, error)
}
VerifiedExecutor consumes only a complete capability-generated command. Injected executors in tests record calls without starting an actual core.