update

package
v0.9.3-dev.4 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: GPL-3.0 Imports: 20 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

Overview

Package update downloads and replaces the Mihari binary (self-update).

Index

Constants

View Source
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

func LoadChannel(path string) (string, error)

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

func SaveChannel(path, channel string) error

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.

func SelectSelfAsset

func SelectSelfAsset(release Release, goos, goarch string) (Asset, error)

SelectSelfAsset picks the unique mihari binary asset for goos/goarch. Expected names are mihari-windows-<arch>.exe or mihari-<goos>-<arch>.

type CheckResult added in v0.4.0

type CheckResult struct {
	Current   string
	Latest    string
	Available bool
	Ahead     bool
	Channel   string
}

CheckResult describes the latest Mihari release relative to the running version.

type OfficialReleaseSource added in v0.9.3

type OfficialReleaseSource struct{ Client *http.Client }

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

func (s OfficialReleaseSource) Checksum(ctx context.Context, tag, asset string) (string, error)

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 Result

type Result struct {
	Version string
	Updated bool
	Ahead   bool
	Channel string
}

Result describes a self-update attempt.

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.

func (SelfUpdater) Update

func (u SelfUpdater) Update(ctx context.Context, binaryPath, currentVersion, channel string) (Result, error)

Update downloads the latest release when newer than currentVersion and replaces binaryPath.

Jump to

Keyboard shortcuts

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