server

package
v0.0.0-...-48822a8 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 34 Imported by: 8 modules, 6 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchAsset       = errors.New(`No such asset with the given checksum`)
	ErrNoUpdateAvailable = errors.New(`No update available`)
)

Public errors

View Source
var Arch = struct {
	X64 string
	X86 string
	ARM string
}{
	"amd64",
	"386",
	"arm",
}

Arch holds architecture names.

View Source
var OS = struct {
	Windows string
	Linux   string
	Darwin  string
	Android string
}{
	"windows",
	"linux",
	"darwin",
	"android",
}

OS holds operating system names.

Functions

func SetPrivateKey

func SetPrivateKey(s string)

func Sign

func Sign(hashedMessage []byte) ([]byte, error)

Sign creates a signatures for a byte array.

Types

type Asset

type Asset struct {
	Name      string // Name of the release.
	URL       string // URL of the patch.
	LocalFile string
	Checksum  string // SHA256 hash of the file.
	Signature string // RSASSA-PKCS1-V1_5-SIGN signature, this is the SHA256 hash against the private key.
	AssetInfo
	// contains filtered or unexported fields
}

Asset struct represents a file included as part of a Release.

type AssetInfo

type AssetInfo struct {
	OS   string
	Arch string
}

AssetInfo struct holds OS and Arch information of an asset.

type Initiative

type Initiative string

Initiative type.

const (
	INITIATIVE_NEVER  Initiative = "never"
	INITIATIVE_AUTO   Initiative = "auto"
	INITIATIVE_MANUAL Initiative = "manual"
)

type Params

type Params struct {
	// protocol version
	Version int `json:"version"`
	// version of the application updating itself
	AppVersion string `json:"app_version"`
	// operating system of target platform
	OS string `json:"-"`
	// hardware architecture of target platform
	Arch string `json:"-"`
	// Semantic version of the OS
	OSVersion string `json:"os_version"`
	// checksum of the binary to replace (used for returning diff patches)
	Checksum string `json:"checksum"`
	// tags for custom update channels
	Tags map[string]string `json:"tags"`
}

Params represent parameters sent by the go-update client.

type Patch

type Patch struct {
	File string
	// contains filtered or unexported fields
}

Patch struct is a representation of a patch generated by bsdiff.

type PatchType

type PatchType string

PatchType represents the type of a binary patch, if any. Only bsdiff is supported

const (
	PATCHTYPE_BSDIFF PatchType = "bsdiff"
	PATCHTYPE_NONE   PatchType = ""
)

type Release

type Release struct {
	URL     string
	Version semver.Version // Release version.
	Assets  []Asset        // The list of assets on this release.
	// contains filtered or unexported fields
}

Release struct represents a single github release.

type ReleaseManager

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

ReleaseManager struct defines a repository to pull releases from.

func NewReleaseManager

func NewReleaseManager(owner string, repo string) *ReleaseManager

NewReleaseManager creates a wrapper of github.Client.

func (*ReleaseManager) CheckForUpdate

func (g *ReleaseManager) CheckForUpdate(p *Params, isLantern bool) (res *Result, err error)

CheckForUpdate receives a *Params message and emits a *Result. If both res and err are nil it means no update is available.

func (*ReleaseManager) UpdateAssetsMap

func (g *ReleaseManager) UpdateAssetsMap() (err error)

UpdateAssetsMap will pull published releases, scan for compatible update-only binaries and will add them to the updateAssetsMap.

type Result

type Result struct {
	// should the update be applied automatically/manually
	Initiative Initiative `json:"initiative"`
	// url where to download the updated application
	URL string `json:"url"`
	// a URL to a patch to apply
	PatchURL string `json:"patch_url"`
	// the patch format (only bsdiff supported at the moment)
	PatchType PatchType `json:"patch_type"`
	// version of the new application
	Version string `json:"version"`
	// expected checksum of the new application
	Checksum string `json:"checksum"`
	// signature for verifying update authenticity
	Signature string `json:"signature"`
}

Result represents the answer to be sent to the client.

type UpdateServer

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

func NewUpdateServer

func NewUpdateServer(publicAddr, localAddr, localpatchesDirectory string, rateLimit int) *UpdateServer

func (*UpdateServer) Close

func (u *UpdateServer) Close()

func (*UpdateServer) HandleRepo

func (u *UpdateServer) HandleRepo(app, owner, repo string, otelHandler func(next http.Handler) http.Handler)

func (*UpdateServer) ListenAndServe

func (u *UpdateServer) ListenAndServe() error

Jump to

Keyboard shortcuts

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