autoupdate

package module
v0.0.0-...-3013172 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: Apache-2.0 Imports: 12 Imported by: 9

README

Lantern Autoupdate

The autoupdate package provides Lantern with the ability to request, download and apply software updates over the network with minimal interaction. At this time, autoupdate relies on the go-update and the autoupdate-server packages.

## General flow

lanternautoupdates - general client

At some point on the Lantern application's lifetime, an independent process will be created, this process will periodically send local information (using a proxy, if available) to an update server that will compare client's data against a list of releases. When applicable, the server will generate a binary patch and send a reply to the client containing the URL of the appropriate patch. The client will download and apply the patch to its executable file so the new version is ready the next time Lantern starts.

Update server

lanternautoupdates - server process

The update server holds a list of releases and waits for queries from clients. Clients will send their own checksum and the server will compare that checksum against the checksum of the latest release, if they don't match a binary diff will be generated. This binary diff can be used by the client to patch itself.

Download server

The update server may or may not be used as a download server. Clients will pull binary diffs from this location, the actual patch's URL will be provided by the update server.

Client

lanternautoupdates - auto update process

A client will compute the checksum of its executable file and will send it to an update server periodically. When the update server replies with a special message meaning that a new version is available, the client will download the binary patch, apply it to a temporary file and check the signature, if the signature is what the client expects, the original executable will be replaced with the patched one.

Documentation

Overview

Package autoupdate provides Lantern with special tools to autoupdate itself with minimal effort.

Index

Constants

View Source
const PackagePublicKey = `` /* 450-byte string literal not displayed */

This is the public key of the BNS cert. Incoming updates will be signed to prevent MITM attacks.

Variables

This section is empty.

Functions

func ApplyNext

func ApplyNext(cfg *Config) (newVersion string, err error)

ApplyNext applies the next available update whenever it is available, blocking until the next update has been applied. If ApplyNext returns without an error, that means that the current program's executable has been udpated in place and you may want to restart. If ApplyNext returns an error, that means that an unrecoverable error has occurred and we can't continue checking for updates.

func CheckMobileUpdate

func CheckMobileUpdate(cfg *Config) (string, error)

CheckMobileUpdate checks if a new update is available for mobile.

func UpdateMobile

func UpdateMobile(url, apkPath string, updater Updater, httpClient *http.Client) error

UpdateMobile downloads the latest APK from the given url to file apkPath.

Types

type Config

type Config struct {
	// CurrentVersion: the current version of the program, must be in the form
	// X.Y.Z
	CurrentVersion string

	// URL: the url at which to check for updates
	URL string

	// PublicKey: the public key against which to check the signature of any
	// received updates.
	PublicKey []byte

	// CheckInterval: the interval at which to check for updates, defaults to
	// 4 hours.
	CheckInterval time.Duration

	// HTTPClient: (optional), an http.Client to use when checking for updates
	HTTPClient *http.Client

	// Operating system (optional, will be inferred)
	OS string
	// Arch (optional, will be inferred)
	Arch string
	// Channel (optional, defaults to stable)
	Channel string
	// contains filtered or unexported fields
}

type Updater

type Updater interface {
	// PublishProgress: publish percentage of update already downloaded
	Progress(int)
}

Jump to

Keyboard shortcuts

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