configmgr

package
v0.0.0-...-75a31e8 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package configmgr defines the AdGuard Home on-disk configuration entities and configuration manager.

TODO(a.garipov): Add tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(fileName string) (err error)

Validate returns an error if the configuration file with the given name does not exist or is invalid.

Types

type Config

type Config struct {
	// BaseLogger is used to create loggers for other entities.  It must not be
	// nil.
	BaseLogger *slog.Logger

	// Logger is used for logging the operation of the configuration manager.
	// It must not be nil.
	Logger *slog.Logger

	// Frontend is the filesystem with the frontend files.
	Frontend fs.FS

	// WebAddr is the initial or override address for the Web UI.  It is not
	// written to the configuration file.
	WebAddr netip.AddrPort

	// Start is the time of start of AdGuard Home.
	Start time.Time

	// FileName is the path to the configuration file.
	FileName string
}

Config contains the configuration parameters for the configuration manager.

type Manager

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

Manager handles full and partial changes in the configuration, persisting them to disk if necessary.

TODO(a.garipov): Support missing configs and default values.

func New

func New(ctx context.Context, c *Config) (m *Manager, err error)

New creates a new *Manager that persists changes to the file pointed to by c.FileName. It reads the configuration file and populates the service fields. c must not be nil.

func (*Manager) DNS

func (m *Manager) DNS() (dns agh.ServiceWithConfig[*dnssvc.Config])

DNS returns the current DNS service. It is safe for concurrent use.

func (*Manager) UpdateDNS

func (m *Manager) UpdateDNS(ctx context.Context, c *dnssvc.Config) (err error)

UpdateDNS implements the websvc.ConfigManager interface for *Manager. The fields of c must not be modified after calling UpdateDNS.

func (*Manager) UpdateWeb

func (m *Manager) UpdateWeb(ctx context.Context, c *websvc.Config) (err error)

UpdateWeb implements the websvc.ConfigManager interface for *Manager. The fields of c must not be modified after calling UpdateWeb.

func (*Manager) Web

func (m *Manager) Web() (web agh.ServiceWithConfig[*websvc.Config])

Web returns the current web service. It is safe for concurrent use.

Jump to

Keyboard shortcuts

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