updater

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package updater is a desktop auto-update client. A publisher signs a release manifest with an ed25519 private key; the app embeds the matching public key and verifies the manifest before trusting any release info or downloading an artifact. This signature scheme is independent of OS code-signing — it authenticates the *update metadata* so a tampered or spoofed manifest is rejected. Pure Go; the security-critical parts (verify, version compare) are unit-tested. Self-replacement/relaunch is desktop-only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAndRelaunch

func ApplyAndRelaunch(newBinary string) error

ApplyAndRelaunch replaces the running executable with the downloaded artifact and relaunches it. Desktop-only. On Windows a running .exe cannot be overwritten in place, so the current binary is moved aside first.

NOTE: self-replacement is OS-specific and must be validated by running a real packaged app; the verify/download path above is the security-critical, unit-tested part.

func PlatformKey

func PlatformKey() string

PlatformKey is the manifest key for the current build.

func SignManifest

func SignManifest(m *Manifest, priv ed25519.PrivateKey) ([]byte, error)

SignManifest produces a signed-manifest document: the manifest JSON plus a base64 ed25519 signature over exactly those bytes. It is the counterpart to VerifyManifest and is used by the publisher (goleo build --publish).

Types

type Client

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

Client checks for and downloads updates.

func NewClient

func NewClient(cfg Config) (*Client, error)

func (*Client) Check

func (c *Client) Check() (*Release, error)

Check fetches and verifies the manifest and returns the newer release for the current platform, or nil if the app is up to date.

func (*Client) Download

func (c *Client) Download(rel *Release, progress func(done, total int64)) (string, error)

Download fetches the release artifact to a temp file and verifies its SHA256. progress, if non-nil, is called with (bytesDownloaded, totalBytes).

type Config

type Config struct {
	ManifestURL    string // URL of the signed manifest JSON
	PublicKey      string // base64-encoded ed25519 public key
	CurrentVersion string // the running app's version
}

Config configures the update client.

type Manifest

type Manifest struct {
	Releases map[string]Release `json:"releases"`
}

Manifest maps a platform key ("<GOOS>/<GOARCH>") to its latest Release.

func VerifyManifest

func VerifyManifest(data []byte, pubKey ed25519.PublicKey) (*Manifest, error)

VerifyManifest parses a signed-manifest document and verifies its ed25519 signature against pubKey, returning the inner Manifest only if valid.

type Release

type Release struct {
	Version string `json:"version"`
	URL     string `json:"url"`
	SHA256  string `json:"sha256"` // hex digest of the artifact
	Notes   string `json:"notes,omitempty"`
}

Release describes a downloadable build for one platform.

func CheckForUpdate

func CheckForUpdate(current string, m *Manifest, platform string) (*Release, bool)

CheckForUpdate returns the release for platform if it is newer than current.

Jump to

Keyboard shortcuts

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