config

package
v0.0.0-...-5abfbfe Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidResolverUpstream = errors.New("invalid resolver upstream")
	ErrInvalidCollectorBackend = errors.New("invalid collector backend")
	ErrInvalidServerAddress    = errors.New("invalid server address")
	ErrInvalidServerNetwork    = errors.New("invalid network")
	ErrInvalidResolverMode     = errors.New("invalid resolver mode")
	ErrInvalidLogMode          = errors.New("invalid log mode")
)

Functions

func Write

func Write(path string, c *Config) error

Write writes a TOML config to path and returns any error encountered while writing

Types

type CollectorOptions

type CollectorOptions struct {
	MaxEntries int    `toml:"max_entries"`
	Anonymize  bool   `toml:"anonymize"`
	Interval   uint   `toml:"interval"`
	Enabled    bool   `toml:"enabled"`
	Backend    string `toml:"backend"`
}

CollectorOptions specifies available collector config options

type Config

type Config struct {
	Collector CollectorOptions `toml:"collector"`
	Resolver  ResolverOptions  `toml:"resolver"`
	Filter    FilterOptions    `toml:"filter"`
	Server    ServerOptions    `toml:"server"`
	Store     StoreOptions     `toml:"store"`
	Log       LogOptions       `toml:"log"`
}

Config specifies the global configuration options

func Default

func Default() *Config

Default returns a config with default values

func Read

func Read(path string) (*Config, error)

Read reads a TOML config file and returns a Config or any error encountered while reading

func (*Config) Defaults

func (c *Config) Defaults()

Defaults sets sane defaults in the config

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the config and returns an error if the config is not valid

type FilterOptions

type FilterOptions struct {
	TTL  int    `toml:"ttl"`
	Mode string `toml:"mode"`
}

FilterOptions specifies available filter config options

type LogOptions

type LogOptions struct {
	Enabled bool     `toml:"enabled"`
	Mode    string   `toml:"mode"`
	Level   string   `toml:"level"`
	Outputs []string `toml:"outputs"`
}

LogOptions specifies available log config options

type ResolverOptions

type ResolverOptions struct {
	CacheEnabled bool       `toml:"cache_enabled"`
	RawUpstream  string     `toml:"upstream"`
	MaxExpire    int        `toml:"max_expire"`
	Upstream     netip.Addr `toml:"-"`
	HintPath     string     `toml:"hint_path"`
	Mode         string     `toml:"mode"`
}

ResolverOptions specifies available resolver config options

type ServerOptions

type ServerOptions struct {
	CacheEnabled bool           `toml:"cache_enabled"`
	Address      string         `toml:"address"`
	AddrPort     netip.AddrPort `toml:"-"`
	Network      string         `toml:"network"`
}

ServerOptions specifies available server config options

type StoreOptions

type StoreOptions struct {
	Username string `toml:"username"`
	Password string `toml:"password"`
	Database string `toml:"database"`
	Backend  string `toml:"backend"`
	Host     string `toml:"host"`
	Port     int    `toml:"port"`
}

Jump to

Keyboard shortcuts

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