Documentation
¶
Overview ¶
Package update downloads and replaces the Mihari binary (self-update).
Index ¶
- Constants
- func LoadChannel(path string) (string, error)
- func SaveChannel(path, channel string) error
- type Asset
- type CheckResult
- type OfficialReleaseSource
- type PreparedUpdate
- type Release
- type Result
- type SelfUpdater
- func (u SelfUpdater) Check(ctx context.Context, currentVersion, channel string) (CheckResult, error)
- func (u SelfUpdater) Prepare(ctx context.Context, binaryPath, currentVersion, channel string) (PreparedUpdate, error)
- func (u SelfUpdater) Update(ctx context.Context, binaryPath, currentVersion, channel string) (Result, error)
Constants ¶
const ( // ChannelMain tracks official GitHub latest releases. ChannelMain = "main" // ChannelDev tracks canonical prerelease tags vX.Y.Z-dev.N. ChannelDev = "dev" )
Variables ¶
This section is empty.
Functions ¶
func LoadChannel ¶ added in v0.9.0
LoadChannel reads the Mihari release channel from path. A missing file defaults to ChannelMain. An invalid first line is an error.
func SaveChannel ¶ added in v0.9.0
SaveChannel atomically writes channel to path. Only main and dev are accepted.
Types ¶
type Asset ¶
type Asset struct {
Name string `json:"name"`
URL string `json:"browser_download_url"`
Size int64 `json:"size"`
}
Asset is a GitHub release asset.
type CheckResult ¶ added in v0.4.0
CheckResult describes the latest Mihari release relative to the running version.
type OfficialReleaseSource ¶ added in v0.9.3
OfficialReleaseSource obtains independent fixed-tag evidence from the project release origin. Client permits an injected transport; URLs are never inputs.
func (OfficialReleaseSource) Checksum ¶ added in v0.9.3
Checksum returns the unique digest in the official fixed-tag manifest.
func (OfficialReleaseSource) Download ¶ added in v0.9.3
func (s OfficialReleaseSource) Download(ctx context.Context, tag, asset string, limit int64) ([]byte, error)
Download retrieves a bounded asset from the immutable release URL. Callers must verify its independent checksum before trusting executable/resource bytes.
type PreparedUpdate ¶ added in v0.9.3
type PreparedUpdate struct {
Version, CandidatePath, SHA256, Channel string
Available, Ahead bool
// contains filtered or unexported fields
}
PreparedUpdate owns a verified download until Apply or Close consumes it. Fields describe a candidate, not authority for privileged installation.
func (*PreparedUpdate) Close ¶ added in v0.9.3
func (p *PreparedUpdate) Close() error
Close releases the prepared candidate. It is safe to call repeatedly.
type Release ¶
type Release struct {
TagName string `json:"tag_name"`
Draft bool `json:"draft"`
Assets []Asset `json:"assets"`
}
Release is a GitHub release document.
type SelfUpdater ¶
type SelfUpdater struct {
HTTPClient *http.Client
APIBase string
Repository string
GOOS string
GOARCH string
// AfterReplace is optional; used to restart the OS service after a successful replace.
AfterReplace func(ctx context.Context, version string) error
// contains filtered or unexported fields
}
SelfUpdater installs a newer Mihari binary from GitHub Releases.
func (SelfUpdater) Check ¶ added in v0.4.0
func (u SelfUpdater) Check(ctx context.Context, currentVersion, channel string) (CheckResult, error)
Check reports whether GitHub Releases contains a newer Mihari version for channel.
func (SelfUpdater) Prepare ¶ added in v0.9.3
func (u SelfUpdater) Prepare(ctx context.Context, binaryPath, currentVersion, channel string) (PreparedUpdate, error)
Prepare downloads and verifies a fixed release without replacing binaryPath.