config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Cfg = &Config{}
	Md  = &MatchDomains{Regex: make(map[*regexp.Regexp][]string)}
)

Functions

func LoadExternalUpstreams

func LoadExternalUpstreams()

LoadExternalUpstreams loads the external upstreams from the URLs provided in the configuration file.

func ReadConfig

func ReadConfig(file string) error

ReadConfig reads the configuration from the given file.

func WatchConfigFile

func WatchConfigFile(file string, done chan bool)

Watch will watch the configuration file for changes.

Types

type Cache

type Cache struct {
	Enabled bool   `yaml:"enabled"`
	Path    string `yaml:"path"`
}

type Config

type Config struct {
	Server    Server     `yaml:"server"`
	Cache     Cache      `yaml:"cache"`
	Upstreams []Upstream `yaml:"upstreams"`
	// ExternalUpstreams is a list of URLs to fetch the upstreams from.
	ExternalUpstreams         []ExternalUpstreamConfig `yaml:"externalUpstreams"`
	ExternalUpstreamsInterval int                      `yaml:"externalUpstreamsInterval"`
	// contains filtered or unexported fields
}

type ExternalUpstream

type ExternalUpstream struct {
	Upstreams []Upstream `yaml:"upstreams"`
}

type ExternalUpstreamConfig

type ExternalUpstreamConfig struct {
	Interval string `yaml:"interval"`
	URL      string `yaml:"url"`
	Token    string `yaml:"token"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type HashDBExternal

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

func (*HashDBExternal) ComputeHash

func (h *HashDBExternal) ComputeHash(upstreamContent []byte) string

ComputeHash computes the hash of the external upstream.

func (*HashDBExternal) HasUpdated

func (h *HashDBExternal) HasUpdated(url string, upstreamContent []byte) bool

HasUpdated checks if the external upstream has been updated.

func (*HashDBExternal) Update

func (h *HashDBExternal) Update(url, hash string)

UpdateHash updates the hash of the external upstream.

type MatchDomains

type MatchDomains struct {
	Regex map[*regexp.Regexp][]string
	// contains filtered or unexported fields
}

func (*MatchDomains) Add

func (m *MatchDomains) Add(regex *regexp.Regexp, servers []string)

func (*MatchDomains) Clear

func (m *MatchDomains) Clear()

Clear clears the MatchDomains map.

func (*MatchDomains) ComputeMatchDomains

func (m *MatchDomains) ComputeMatchDomains()

Compute MatchDomains from the Upstreams.

func (*MatchDomains) Get

func (m *MatchDomains) Get(domain string) []string

type Server

type Server struct {
	Host            string   `yaml:"host"`
	Port            int      `yaml:"port"`
	DefaultUpstream []string `yaml:"defaultUpstream"`
	LogLevel        string   `yaml:"logLevel"`
}

func (*Server) GetListenAddress

func (s *Server) GetListenAddress() string

GetListenAddress returns the address to listen on.

func (*Server) GetLogLevel

func (s *Server) GetLogLevel() zerolog.Level

GetLogLevel returns the log level.

type Upstream

type Upstream struct {
	Name       string           `yaml:"name"`
	DNSServers []string         `yaml:"servers"`
	HostRegex  []string         `yaml:"regex"`
	Regex      []*regexp.Regexp `yaml:"-"`
}

func (*Upstream) CompileDNSServers

func (u *Upstream) CompileDNSServers()

func (*Upstream) CompileRegex

func (u *Upstream) CompileRegex()

Jump to

Keyboard shortcuts

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