core

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: GPL-3.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootstrapConfig

func BootstrapConfig(settings config.Settings) ([]byte, error)

func DetectVersion

func DetectVersion(ctx context.Context, runner CommandRunner, binaryPath string) (string, error)

func EnsureRuntimeConfig

func EnsureRuntimeConfig(path string, settings config.Settings) error

func ParseAlphaSHA added in v0.5.0

func ParseAlphaSHA(name string) string

func ParseVersion

func ParseVersion(output string) (string, error)

func ValidateConfig

func ValidateConfig(ctx context.Context, runner CommandRunner, binaryPath, dataDir, configPath string) error

func WriteBootstrapConfig

func WriteBootstrapConfig(path string, settings config.Settings) error

Types

type Asset

type Asset struct {
	Name   string `json:"name"`
	URL    string `json:"browser_download_url"`
	Size   int64  `json:"size"`
	Digest string `json:"digest"`
}

func SelectAsset

func SelectAsset(release Release, goos, goarch, channel string) (Asset, error)

type Candidate

type Candidate struct {
	// contains filtered or unexported fields
}

func (*Candidate) Cleanup

func (c *Candidate) Cleanup()

func (*Candidate) Commit

func (c *Candidate) Commit() (InstallResult, error)

func (*Candidate) Updated

func (c *Candidate) Updated() bool

func (*Candidate) Version

func (c *Candidate) Version() string

type CommandRunner

type CommandRunner interface {
	Run(context.Context, string, ...string) ([]byte, error)
}

type InstallRequest

type InstallRequest struct {
	BinaryPath     string
	DataDir        string
	ConfigPath     string
	StagingDir     string
	CurrentVersion string
	Channel        string
	AlphaSHA       string
}

type InstallResult

type InstallResult struct {
	Version  string
	Updated  bool
	AlphaSHA string
}

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

func (i Installer) DetectVersion(ctx context.Context, binaryPath string) (string, error)

DetectVersion 报告现有核心二进制的版本(运行 mihomo -v)。供 runtime 侧 setup 本地预检 复用,避免在 runtime.Manager 里另持 Runner;判据复用 DetectVersion(含 ParseVersion 版本 格式校验),与 Prepare 的同版本短路同一判据、DRY(design §4.3 实现位置)。

func (Installer) Download added in v0.2.0

func (i Installer) Download(ctx context.Context, asset Asset, destination string) error

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

func (i Installer) LatestRelease(ctx context.Context, channel string) (Release, error)

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

type LocalCoreInfo struct {
	Ready   bool
	Version string
}

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{}

func (OSCommandRunner) Run

func (OSCommandRunner) Run(ctx context.Context, name string, args ...string) ([]byte, error)

type PreparedCore

type PreparedCore interface {
	Version() string
	Updated() bool
	Commit() (InstallResult, error)
	Cleanup()
}

type Release

type Release struct {
	TagName string  `json:"tag_name"`
	Assets  []Asset `json:"assets"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL