Documentation
¶
Index ¶
- func BootstrapConfig(settings config.Settings) ([]byte, error)
- func DetectVersion(ctx context.Context, runner CommandRunner, binaryPath string) (string, error)
- func EnsureRuntimeConfig(path string, settings config.Settings) error
- func ParseVersion(output string) (string, error)
- func ValidateConfig(ctx context.Context, runner CommandRunner, ...) error
- func WriteBootstrapConfig(path string, settings config.Settings) error
- type Asset
- type Candidate
- type CommandRunner
- 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) (Release, error)
- func (i Installer) Prepare(ctx context.Context, request InstallRequest) (PreparedCore, error)
- type OSCommandRunner
- type PreparedCore
- type Release
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectVersion ¶
func ParseVersion ¶
func ValidateConfig ¶
func ValidateConfig(ctx context.Context, runner CommandRunner, binaryPath, dataDir, configPath string) error
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 InstallRequest ¶
type InstallResult ¶
type Installer ¶
type Installer struct {
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 边界)。
func (Installer) Prepare ¶
func (i Installer) Prepare(ctx context.Context, request InstallRequest) (PreparedCore, error)
type OSCommandRunner ¶
type OSCommandRunner struct{}
type PreparedCore ¶
type PreparedCore interface {
Version() string
Updated() bool
Commit() (InstallResult, error)
Cleanup()
}