Documentation
¶
Overview ¶
Package updater is SSHYard's update client. Releases are published as MyGo publishes them on GitHub Releases: a signed archive per platform with a manifest, update-<os>-<arch>.json, in the latest release of Licoy/sshyard. Installing goes through mygo.Updater, which checks the Ed25519 signature against the public key built into the app.
Index ¶
- Constants
- func CleanLeftovers()
- func Compare(a, b string) int
- func ManifestName(goos, goarch string) string
- func ManifestURL(repo, goos, goarch string) string
- func Plugin(interval time.Duration, automatic bool) mygo.Plugin
- type Backend
- type Delta
- type Manifest
- type MygoBackend
- type Route
- type Version
Constants ¶
const MaxManifestSize = 1 << 20
MaxManifestSize bounds a manifest read from the network.
const Repo = "Licoy/sshyard"
Repo is the GitHub repository SSHYard's releases are published in.
Variables ¶
This section is empty.
Functions ¶
func CleanLeftovers ¶ added in v1.0.1
func CleanLeftovers()
CleanLeftovers removes the work directories that MyGo's updater makes next to the app directory, ".<app dir>.update-<digits>", and leaves behind when it cannot remove them: Windows keeps a file just written open while it scans it, and an install cut short by the app exiting keeps its directory too. MyGo only cleans what it leaves inside the app directory. macOS is left out: there a helper removes the directory once the app has exited, and its staged update waits in it until then.
func ManifestName ¶
ManifestName is the manifest's file name for a platform.
func ManifestURL ¶
ManifestURL is where the latest release's manifest of a platform is.
func Plugin ¶
Plugin is MyGo's updater plugin drawn in native UI, which reads the manifest `mygo build` publishes to the latest release of the repository in mygo.json (updates.github = Licoy/sshyard) and verifies signatures. It checks again as the user installs, and as Check is called while it offers a version, so a release published since the offer is the one installed. It checks soon after each launch and every interval after while automatic is on. The interval is read once: a change applies at the next launch.
Types ¶
type Backend ¶
type Backend interface {
// Enabled reports whether this build can update itself: development
// builds and those installed by a package manager cannot.
Enabled() bool
// Check checks as the user asked: the update window shows at once and
// says what it found.
Check()
// SetAutomatic turns the checks in the background on or off.
SetAutomatic(on bool)
// SetRoute sends the requests that follow through r.
SetRoute(r Route)
// Available is the newer version the last check found, or "".
Available() string
// OnChange calls fn on the main thread after Available may have
// changed, and returns a function that removes it.
OnChange(fn func()) (off func())
}
Backend is the update window of the app: MyGo's updater plugin, which checks soon after launch and every interval after, shows the release notes of a newer version in its own window and installs it; a fake in tests.
type Delta ¶
type Delta struct {
From string `json:"from"`
URL string `json:"url"`
Size int64 `json:"size"`
Signature string `json:"signature"`
}
Delta is a delta update from an earlier version.
type Manifest ¶
type Manifest struct {
Version string `json:"version"`
Notes string `json:"notes,omitempty"`
Date string `json:"date,omitempty"`
URL string `json:"url"`
Size int64 `json:"size"`
Signature string `json:"signature"`
Deltas []Delta `json:"deltas,omitempty"`
}
Manifest is MyGo's update manifest, update-<os>-<arch>.json.
func ParseManifest ¶
ParseManifest reads and checks a manifest.
type MygoBackend ¶
type MygoBackend struct{}
MygoBackend is the Backend of the app, over the plugin Plugin returns, which must be used.
func (MygoBackend) Available ¶
func (MygoBackend) Available() string
func (MygoBackend) Check ¶
func (MygoBackend) Check()
func (MygoBackend) Enabled ¶
func (MygoBackend) Enabled() bool
func (MygoBackend) OnChange ¶
func (MygoBackend) OnChange(fn func()) (off func())
func (MygoBackend) SetAutomatic ¶
func (MygoBackend) SetAutomatic(on bool)
func (MygoBackend) SetRoute ¶ added in v0.0.28
func (MygoBackend) SetRoute(r Route)
type Route ¶ added in v0.0.28
type Route struct {
Proxy func(*http.Request) (*url.URL, error)
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
}
Route is how the update window's requests go out: Proxy as an http.Transport's, then Dial for each connection.
type Version ¶
Version is a semantic version: major.minor.patch with an optional prerelease; build metadata is ignored.
func ParseVersion ¶
ParseVersion parses "1.2.3", "v1.2.3-beta.1" or "1.2.3+build".
func (Version) Prerelease ¶
Prerelease reports whether the version is a prerelease.