Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoSuchAsset = errors.New(`No such asset with the given checksum`) ErrNoUpdateAvailable = errors.New(`No update available`) )
Public errors
var Arch = struct { X64 string X86 string ARM string }{ "amd64", "386", "arm", }
Arch holds architecture names.
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)
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 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
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 (*UpdateServer) ListenAndServe ¶
func (u *UpdateServer) ListenAndServe() error