patchclient

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package patchclient implements all you need to easily do updates for your application.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGetUpdate     = errors.New("patchclient: failed to get update")
	ErrApplyUpdate   = errors.New("patchclient: failed to apply update")
	ErrUnmarshalJSON = errors.New("patchclient: failed to unmarshal json")
	ErrReadJSON      = errors.New("patchclient: failed to read json")
)

Functions

func GetLocalBinaryName

func GetLocalBinaryName() string

func GetUpdate

func GetUpdate(baseUpdateURL, version string) (io.ReadCloser, error)

GetUpdate returns an open io.ReadCloser, if error is not nil. Caller has to close the io.ReadCloser.

Types

type PatchClient

type PatchClient struct {
	URL       string
	Version   string
	PublicKey []byte
}

func NewInsecurePatchClient

func NewInsecurePatchClient(url, version string) *PatchClient

NewInsecurePatchClient is not able to verify the signature of your update.

func NewPatchClient

func NewPatchClient(url, version string, pubKey []byte) *PatchClient

NewPatchClient is able to verify updates.

func (*PatchClient) ApplyUpdate

func (pc *PatchClient) ApplyUpdate(rc io.ReadCloser) error

ApplyUpdate is the simplest version of applying an update. It patches a full binary without checking a signature.

func (*PatchClient) ApplyUpdateWithPatch

func (pc *PatchClient) ApplyUpdateWithPatch(patch io.Reader) error

ApplyUpdateWithPatch applies a not signed binary patch.

func (*PatchClient) ApplyVerifiedPatchUpdate

func (pc *PatchClient) ApplyVerifiedPatchUpdate(binary io.ReadCloser, hexChecksum, hexSignature string) error

ApplyVerifiedPatchUpdate applies a signed binary patch and checks the checksum.

func (*PatchClient) ApplyVerifiedUpdate

func (pc *PatchClient) ApplyVerifiedUpdate(binary io.ReadCloser, hexChecksum, hexSignature string) error

ApplyVerifiedUpdate applies a signed binary update and checks the checksum.

func (*PatchClient) SignedVerifiedPatchUpdate

func (pc *PatchClient) SignedVerifiedPatchUpdate() error

func (*PatchClient) SignedVerifiedUpdate

func (pc *PatchClient) SignedVerifiedUpdate() error

func (*PatchClient) UnsignedNotVerifiedPatchUpdate

func (pc *PatchClient) UnsignedNotVerifiedPatchUpdate() error

func (*PatchClient) UnsignedNotVerifiedUpdate

func (pc *PatchClient) UnsignedNotVerifiedUpdate() error

type SignedUpdate

type SignedUpdate struct {
	// Patch contains the binary diff of current to next version
	Patch []byte `json:"patch"`
	// Signature contains the signature of the next version binary
	// to verify, if the resulting binary patch is correct.
	Signature []byte `json:"signature"`
	// Digest is the SHA256 of the Patch
	Digest []byte `json:"sha256"`
}

SignedUpdate contains data required to validate and verify patch the applied patch. If the Digest is not correct, the Patch should not be applied, if the Signature can not be verified, the patch will return an error and you can rollback the patch.

Jump to

Keyboard shortcuts

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