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 ¶
ReadConfig reads the configuration from the given file.
func WatchConfigFile ¶
Watch will watch the configuration file for changes.
Types ¶
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 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) 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 ¶
GetListenAddress returns the address to listen on.
func (*Server) GetLogLevel ¶
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()
Click to show internal directories.
Click to hide internal directories.