updater

package
v0.107.67 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package updater provides an updater for AdGuardHome.

Index

Constants

View Source
const MaxPackageFileSize = 32 * 1024 * 1024

MaxPackageFileSize is a maximum package file length in bytes. The largest package whose size is limited by this constant currently has the size of approximately 9 MiB.

Variables

This section is empty.

Functions

func DefaultVersionURL added in v0.107.55

func DefaultVersionURL() *url.URL

DefaultVersionURL returns the default URL for the version announcement.

Types

type Config

type Config struct {
	// Client is used to perform HTTP requests.  It must not be nil.
	Client *http.Client

	// Logger is used for logging the update process.  It must not be nil.
	Logger *slog.Logger

	// VersionCheckURL is URL to the latest version announcement.  It must not
	// be nil, see [DefaultVersionURL].
	VersionCheckURL *url.URL

	// CommandConstructor is used to run external commands.  It must not be nil.
	CommandConstructor executil.CommandConstructor

	// Version is the current AdGuard Home version.  It must not be empty.
	Version string

	// Channel is the current AdGuard Home update channel.  It must be a valid
	// channel, see [version.ChannelBeta] and the related constants.
	Channel string

	// GOARCH is the current CPU architecture.  It must not be empty and must be
	// one of the supported architectures.
	GOARCH string

	// GOOS is the current operating system.  It must not be empty and must be
	// one of the supported OSs.
	GOOS string

	// GOARM is the current ARM variant, if any.  It must either be empty or be
	// a valid and supported GOARM value.
	GOARM string

	// GOMIPS is the current MIPS variant, if any.  It must either be empty or
	// be a valid and supported GOMIPS value.
	GOMIPS string

	// ConfName is the name of the current configuration file.  It must not be
	// empty.
	ConfName string

	// WorkDir is the working directory that is used for temporary files.  It
	// must not be empty.
	WorkDir string

	// ExecPath is path to the executable file.  It must not be empty.
	ExecPath string
}

Config is the AdGuard Home updater configuration.

type Updater

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

Updater is the AdGuard Home updater.

func NewUpdater

func NewUpdater(conf *Config) *Updater

NewUpdater creates a new Updater. conf must not be nil.

func (*Updater) NewVersion

func (u *Updater) NewVersion() (nv string)

NewVersion returns the available new version.

func (*Updater) Update

func (u *Updater) Update(ctx context.Context, firstRun bool) (err error)

Update performs the auto-update. It returns an error if the update fails. If firstRun is true, it assumes the configuration file doesn't exist.

func (*Updater) VersionInfo

func (u *Updater) VersionInfo(ctx context.Context, forceRecheck bool) (vi VersionInfo, err error)

VersionInfo downloads the latest version information. If forceRecheck is false and there are cached results, those results are returned.

type VersionInfo

type VersionInfo struct {
	NewVersion      string `json:"new_version,omitempty"`
	Announcement    string `json:"announcement,omitempty"`
	AnnouncementURL string `json:"announcement_url,omitempty"`
	// TODO(a.garipov): See if the frontend actually still cares about
	// nullability.
	CanAutoUpdate aghalg.NullBool `json:"can_autoupdate,omitempty"`
}

VersionInfo contains information about a new version.

Jump to

Keyboard shortcuts

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