guputil

package
v0.0.0-...-760a7c8 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checksum

func Checksum(r io.Reader) (string, error)

func ExpandTag

func ExpandTag(tag string) string

ExpandTag expands a tag for usage in an index.json file.

func ParsePublicKey

func ParsePublicKey(key []byte) (pubKey *ecdsa.PublicKey, err error)

ParsePublicKey parses a PEM encoded public key.

func Tag

func Tag(tag, goos, goarch string) string

Tag creates a tag given the user tag, GOOS, and GOARCH.

func UpdateFilename

func UpdateFilename(tag string, versionIndex int) string

UpdateFilename returns the update filename for the specified tag and version.

Types

type BundleInfo

type BundleInfo struct {
	// Checksum of the new binary in the gup patch bundle.
	Checksum string

	// DecodedChecksum of the binary in the gup patch bundle.
	DecodedChecksum []byte

	// Signature is the ECDSA signature of the new binary in the gup patch
	// bundle.
	Signature ECDSASignature
}

BundleInfo represents information about a gup patch bundle.

func Diff

func Diff(key *ecdsa.PrivateKey, old, new io.Reader, patch io.Writer) (*BundleInfo, error)

Diff computes a diff between old and new and writes out a gup patch bundle to patch. The ECDSA binary signature for new is written into the gup patch bundle using the provided private key.

func Patch

func Patch(pub *ecdsa.PublicKey, old io.Reader, new io.Writer, patch io.Reader) (*BundleInfo, error)

Patch applies the gup patch bundle, patch, to old, and writes the result to new. The provided public key is used to verify the ECDSA binary signature previously encoded into the gup patch bundle.

func (*BundleInfo) String

func (b *BundleInfo) String() string

type ECDSASignature

type ECDSASignature struct {
	R, S *big.Int
}

type Index

type Index struct {
	// Tags is a map of all tags (or "release channels") to their respective
	// versions.
	Tags map[string]*IndexVersions
}

Index represents a index.json file.

type IndexVersion

type IndexVersion struct {
	// From and To represent the SHA256 hash of the old (from) file and the new
	// (to) file. For example, if a user's binary is currently SHA256="foo"
	// then any version where From="foo" would be the next update for that
	// user.
	From, To string

	// Replacement indicates that the version is a full binary replacement,
	// i.e. not an incremental patch.
	Replacement bool
}

IndexVersion represents a single version found in a index.json file.

The first version in a chain will always have an empty From value equal to the To value and will be a Replacement binary.

type IndexVersions

type IndexVersions struct {
	// List is a list of all versions available, in order of most recent (index
	// zero) to oldest (last index).
	List []IndexVersion
}

IndexVersions represents versions found in a index.json file for a specific tag.

func (IndexVersions) FindCurrentVersion

func (v IndexVersions) FindCurrentVersion(x string) (*IndexVersion, int)

FindCurrentVersion finds the current version for x; i.e. the version whose To specifies x.

func (IndexVersions) FindNextVersion

func (v IndexVersions) FindNextVersion(from string) (*IndexVersion, int)

FindNextVersion returns the next logical version to upgrade to when coming from the given SHA256. If nil is returned, there is no next version.

Jump to

Keyboard shortcuts

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