autoupdate

package
v0.0.0-...-b60358c Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SaltSize = crypto.KeySize256

	ReleaseManifestFilename = "release.json"

	DefaultUserAgent = "Mozilla/5.0 (compatible; +autoupdate)"
)

Variables

This section is empty.

Functions

func GenerateSigningKeypair

func GenerateSigningKeypair(password []byte) (encryptedAndEncodedPrivateKey string, encodedPublicKey string, err error)

func Verify

func Verify(base64PublicKey string, input VerifyInput) (err error)

func VerifyMany

func VerifyMany(base64PublicKey string, input []VerifyInput) (err error)

Types

type ChannelManifest

type ChannelManifest struct {
	Name    string `json:"name"`
	Channel string `json:"channel"`
	Version string `json:"version"`
}

func (ChannelManifest) ToJson

func (manifest ChannelManifest) ToJson() (manifestJSON []byte, err error)

type Config

type Config struct {
	PublicKey string
	// BaseURL is the URL of the folder containing the manifest
	// e.g. https://downloads.example.com/myapp
	BaseURL        string
	CurrentVersion string
	ReleaseChannel string
	// Interval to check for updates. default: 1800 seconds
	Interval int64
	// Verbose logs actions with the INFO level
	Verbose    bool
	UserAgent  *string
	HttpClient *http.Client
}

type CreateReleaseInput

type CreateReleaseInput struct {
	// Name of the project. e.g. myapp
	Name string
	// Version of the release of the project. e.g. 1.1.52
	Version string
	Channel string
	Files   []string
	// PrivateKeyPrivateKey is the base64 encoded privateKey, encrypted with password
	PrivateKey         string
	PrivateKeyPassword string
}

type Release

type Release struct {
	Name            string
	ChannelManifest ChannelManifest
	ReleaseManifest ReleaseManifest
}

func CreateRelease

func CreateRelease(ctx context.Context, info CreateReleaseInput) (release Release, err error)

type ReleaseFile

type ReleaseFile struct {
	Filename  string         `json:"file"`
	Sha256    byteshex.Bytes `json:"sha256"`
	Signature []byte         `json:"signature"`
}

func Sign

func Sign(encryptedBase64PrivateKey string, password string, input SignInput) (output ReleaseFile, err error)

func SignMany

func SignMany(encryptedBase64PrivateKey string, password string, input []SignInput) (output []ReleaseFile, err error)

type ReleaseManifest

type ReleaseManifest struct {
	Name    string        `json:"name"`
	Version string        `json:"version"`
	Files   []ReleaseFile `json:"files"`
}

func (ReleaseManifest) ToJson

func (manifest ReleaseManifest) ToJson() (manifestJSON []byte, err error)

type SignInput

type SignInput struct {
	Filename string
	Reader   io.Reader
}

type Updater

type Updater struct {
	Updated chan struct{}
	// contains filtered or unexported fields
}

func NewUpdater

func NewUpdater(config Config) (updater *Updater, err error)

func (*Updater) CheckUpdate

func (updater *Updater) CheckUpdate(ctx context.Context) (manifest ChannelManifest, err error)

func (*Updater) RestartRequired

func (updater *Updater) RestartRequired() bool

func (*Updater) RunInBackground

func (updater *Updater) RunInBackground(ctx context.Context)

func (*Updater) Update

func (updater *Updater) Update(ctx context.Context, channelManifest ChannelManifest) (err error)

func (*Updater) UpdateAvailable

func (updater *Updater) UpdateAvailable(manifest ChannelManifest) bool

UpdateAvailable returns true if the latest avaiable version is > to the latest install version

type VerifyInput

type VerifyInput struct {
	Reader    io.Reader
	Sha256    []byte
	Signature []byte
}

Jump to

Keyboard shortcuts

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