config

package
v0.9.2-0...-9d65b93 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const UpstreamDefaultCfgName = "default"

Variables

View Source
var ErrInvalidBytesSourceType = fmt.Errorf("not a valid BytesSourceType, try [%s]", strings.Join(_BytesSourceTypeNames, ", "))
View Source
var ErrInvalidIPVersion = fmt.Errorf("not a valid IPVersion, try [%s]", strings.Join(_IPVersionNames, ", "))
View Source
var ErrInvalidInitStrategy = fmt.Errorf("not a valid InitStrategy, try [%s]", strings.Join(_InitStrategyNames, ", "))
View Source
var ErrInvalidNetProtocol = fmt.Errorf("not a valid NetProtocol, try [%s]", strings.Join(_NetProtocolNames, ", "))
View Source
var ErrInvalidQueryLogField = fmt.Errorf("not a valid QueryLogField, try [%s]", strings.Join(_QueryLogFieldNames, ", "))
View Source
var ErrInvalidQueryLogType = fmt.Errorf("not a valid QueryLogType, try [%s]", strings.Join(_QueryLogTypeNames, ", "))
View Source
var ErrInvalidTLSVersion = fmt.Errorf("not a valid TLSVersion, try [%s]", strings.Join(_TLSVersionNames, ", "))
View Source
var ErrInvalidUpstreamStrategy = fmt.Errorf("not a valid UpstreamStrategy, try [%s]", strings.Join(_UpstreamStrategyNames, ", "))

Functions

func BytesSourceTypeNames

func BytesSourceTypeNames() []string

BytesSourceTypeNames returns a list of possible string values of BytesSourceType.

func ConvertPort

func ConvertPort(in string) (uint16, error)

ConvertPort converts string representation into a valid port (0 - 65535)

func IPVersionNames

func IPVersionNames() []string

IPVersionNames returns a list of possible string values of IPVersion.

func InitStrategyNames

func InitStrategyNames() []string

InitStrategyNames returns a list of possible string values of InitStrategy.

func NetProtocolNames

func NetProtocolNames() []string

NetProtocolNames returns a list of possible string values of NetProtocol.

func QueryLogFieldNames

func QueryLogFieldNames() []string

QueryLogFieldNames returns a list of possible string values of QueryLogField.

func QueryLogTypeNames

func QueryLogTypeNames() []string

QueryLogTypeNames returns a list of possible string values of QueryLogType.

func TLSVersionNames

func TLSVersionNames() []string

TLSVersionNames returns a list of possible string values of TLSVersion.

func UpstreamStrategyNames

func UpstreamStrategyNames() []string

UpstreamStrategyNames returns a list of possible string values of UpstreamStrategy.

func WithDefaults

func WithDefaults[T any]() (T, error)

Types

type Blocking

type Blocking struct {
	BlackLists        map[string][]BytesSource `yaml:"blackLists"`
	WhiteLists        map[string][]BytesSource `yaml:"whiteLists"`
	ClientGroupsBlock map[string][]string      `yaml:"clientGroupsBlock"`
	BlockType         string                   `yaml:"blockType" default:"ZEROIP"`
	BlockTTL          Duration                 `yaml:"blockTTL" default:"6h"`
	Loading           SourceLoading            `yaml:"loading"`

	// Deprecated options
	Deprecated struct {
		DownloadTimeout       *Duration     `yaml:"downloadTimeout"`
		DownloadAttempts      *uint         `yaml:"downloadAttempts"`
		DownloadCooldown      *Duration     `yaml:"downloadCooldown"`
		RefreshPeriod         *Duration     `yaml:"refreshPeriod"`
		FailStartOnListError  *bool         `yaml:"failStartOnListError"`
		ProcessingConcurrency *uint         `yaml:"processingConcurrency"`
		StartStrategy         *InitStrategy `yaml:"startStrategy"`
		MaxErrorsPerFile      *int          `yaml:"maxErrorsPerFile"`
	} `yaml:",inline"`
}

Blocking configuration for query blocking

func (*Blocking) IsEnabled

func (c *Blocking) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*Blocking) LogConfig

func (c *Blocking) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type BootstrapDNS

type BootstrapDNS bootstrapDNS

split in two types to avoid infinite recursion. See `BootstrapDNS.UnmarshalYAML`.

func (*BootstrapDNS) IsEnabled

func (b *BootstrapDNS) IsEnabled() bool

func (*BootstrapDNS) LogConfig

func (b *BootstrapDNS) LogConfig(*logrus.Entry)

func (*BootstrapDNS) UnmarshalYAML

func (b *BootstrapDNS) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML creates BootstrapDNS from YAML

type BootstrappedUpstream

type BootstrappedUpstream bootstrappedUpstream

split in two types to avoid infinite recursion. See `BootstrappedUpstream.UnmarshalYAML`.

func (*BootstrappedUpstream) UnmarshalYAML

func (b *BootstrappedUpstream) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML creates BootstrappedUpstream from YAML

type BytesSource

type BytesSource struct {
	Type BytesSourceType
	From string
}

func NewBytesSources

func NewBytesSources(sources ...string) []BytesSource

func TextBytesSource

func TextBytesSource(lines ...string) BytesSource

func (BytesSource) String

func (s BytesSource) String() string

func (*BytesSource) UnmarshalText

func (s *BytesSource) UnmarshalText(data []byte) error

UnmarshalText implements `encoding.TextUnmarshaler`.

type BytesSourceType

type BytesSourceType uint16

BytesSourceType supported BytesSource types. ENUM( text=1 // Inline YAML block. http // HTTP(S). file // Local file. )

const (
	// BytesSourceTypeText is a BytesSourceType of type Text.
	// Inline YAML block.
	BytesSourceTypeText BytesSourceType = iota + 1
	// BytesSourceTypeHttp is a BytesSourceType of type Http.
	// HTTP(S).
	BytesSourceTypeHttp
	// BytesSourceTypeFile is a BytesSourceType of type File.
	// Local file.
	BytesSourceTypeFile
)

func BytesSourceTypeValues

func BytesSourceTypeValues() []BytesSourceType

BytesSourceTypeValues returns a list of the values for BytesSourceType

func ParseBytesSourceType

func ParseBytesSourceType(name string) (BytesSourceType, error)

ParseBytesSourceType attempts to convert a string to a BytesSourceType.

func (BytesSourceType) IsValid

func (x BytesSourceType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (BytesSourceType) MarshalText

func (x BytesSourceType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (BytesSourceType) String

func (x BytesSourceType) String() string

String implements the Stringer interface.

func (*BytesSourceType) UnmarshalText

func (x *BytesSourceType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Caching

type Caching struct {
	MinCachingTime        Duration `yaml:"minTime"`
	MaxCachingTime        Duration `yaml:"maxTime"`
	CacheTimeNegative     Duration `yaml:"cacheTimeNegative" default:"30m"`
	MaxItemsCount         int      `yaml:"maxItemsCount"`
	Prefetching           bool     `yaml:"prefetching"`
	PrefetchExpires       Duration `yaml:"prefetchExpires" default:"2h"`
	PrefetchThreshold     int      `yaml:"prefetchThreshold" default:"5"`
	PrefetchMaxItemsCount int      `yaml:"prefetchMaxItemsCount"`
}

Caching configuration for domain caching

func (*Caching) EnablePrefetch

func (c *Caching) EnablePrefetch()

func (*Caching) IsEnabled

func (c *Caching) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*Caching) LogConfig

func (c *Caching) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type ClientLookup

type ClientLookup struct {
	ClientnameIPMapping map[string][]net.IP `yaml:"clients"`
	Upstream            Upstream            `yaml:"upstream"`
	SingleNameOrder     []uint              `yaml:"singleNameOrder"`
}

ClientLookup configuration for the client lookup

func (*ClientLookup) IsEnabled

func (c *ClientLookup) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*ClientLookup) LogConfig

func (c *ClientLookup) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type ConditionalUpstream

type ConditionalUpstream struct {
	RewriterConfig `yaml:",inline"`
	Mapping        ConditionalUpstreamMapping `yaml:"mapping"`
}

ConditionalUpstream conditional upstream configuration

func (*ConditionalUpstream) IsEnabled

func (c *ConditionalUpstream) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*ConditionalUpstream) LogConfig

func (c *ConditionalUpstream) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type ConditionalUpstreamMapping

type ConditionalUpstreamMapping struct {
	Upstreams map[string][]Upstream
}

ConditionalUpstreamMapping mapping for conditional configuration

func (*ConditionalUpstreamMapping) UnmarshalYAML

func (c *ConditionalUpstreamMapping) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements `yaml.Unmarshaler`.

type Config

type Config struct {
	Upstreams        Upstreams           `yaml:"upstreams"`
	ConnectIPVersion IPVersion           `yaml:"connectIPVersion"`
	CustomDNS        CustomDNS           `yaml:"customDNS"`
	Conditional      ConditionalUpstream `yaml:"conditional"`
	Blocking         Blocking            `yaml:"blocking"`
	ClientLookup     ClientLookup        `yaml:"clientLookup"`
	Caching          Caching             `yaml:"caching"`
	QueryLog         QueryLog            `yaml:"queryLog"`
	Prometheus       Metrics             `yaml:"prometheus"`
	Redis            Redis               `yaml:"redis"`
	Log              log.Config          `yaml:"log"`
	Ports            Ports               `yaml:"ports"`
	MinTLSServeVer   TLSVersion          `yaml:"minTlsServeVersion" default:"1.2"`
	CertFile         string              `yaml:"certFile"`
	KeyFile          string              `yaml:"keyFile"`
	BootstrapDNS     BootstrapDNS        `yaml:"bootstrapDns"`
	HostsFile        HostsFile           `yaml:"hostsFile"`
	FQDNOnly         FQDNOnly            `yaml:"fqdnOnly"`
	Filtering        Filtering           `yaml:"filtering"`
	EDE              EDE                 `yaml:"ede"`
	ECS              ECS                 `yaml:"ecs"`
	SUDN             SUDN                `yaml:"specialUseDomains"`

	// Deprecated options
	Deprecated struct {
		Upstream            *UpstreamGroups `yaml:"upstream"`
		UpstreamTimeout     *Duration       `yaml:"upstreamTimeout"`
		DisableIPv6         *bool           `yaml:"disableIPv6"`
		LogLevel            *logrus.Level   `yaml:"logLevel"`
		LogFormat           *log.FormatType `yaml:"logFormat"`
		LogPrivacy          *bool           `yaml:"logPrivacy"`
		LogTimestamp        *bool           `yaml:"logTimestamp"`
		DNSPorts            *ListenConfig   `yaml:"port"`
		HTTPPorts           *ListenConfig   `yaml:"httpPort"`
		HTTPSPorts          *ListenConfig   `yaml:"httpsPort"`
		TLSPorts            *ListenConfig   `yaml:"tlsPort"`
		StartVerifyUpstream *bool           `yaml:"startVerifyUpstream"`
		DoHUserAgent        *string         `yaml:"dohUserAgent"`
	} `yaml:",inline"`
}

Config main configuration

func LoadConfig

func LoadConfig(path string, mandatory bool) (rCfg *Config, rerr error)

LoadConfig creates new config from YAML file or a directory containing YAML files

type Configurable

type Configurable interface {
	// IsEnabled returns true when the receiver is configured.
	IsEnabled() bool

	// LogConfig logs the receiver's configuration.
	//
	// The behavior of this method is undefined when `IsEnabled` returns false.
	LogConfig(*logrus.Entry)
}

type CustomDNS

type CustomDNS struct {
	RewriterConfig      `yaml:",inline"`
	CustomTTL           Duration         `yaml:"customTTL" default:"1h"`
	Mapping             CustomDNSMapping `yaml:"mapping"`
	Zone                ZoneFileDNS      `yaml:"zone" default:""`
	FilterUnmappedTypes bool             `yaml:"filterUnmappedTypes" default:"true"`
}

CustomDNS custom DNS configuration

func (*CustomDNS) IsEnabled

func (c *CustomDNS) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*CustomDNS) LogConfig

func (c *CustomDNS) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type CustomDNSEntries

type CustomDNSEntries []dns.RR

func (*CustomDNSEntries) UnmarshalYAML

func (c *CustomDNSEntries) UnmarshalYAML(unmarshal func(interface{}) error) error

type CustomDNSMapping

type CustomDNSMapping map[string]CustomDNSEntries

type Downloader

type Downloader struct {
	Timeout  Duration `yaml:"timeout" default:"5s"`
	Attempts uint     `yaml:"attempts" default:"3"`
	Cooldown Duration `yaml:"cooldown" default:"500ms"`
}

func (*Downloader) LogConfig

func (c *Downloader) LogConfig(logger *logrus.Entry)

type Duration

type Duration time.Duration

Duration is a wrapper for time.Duration to support yaml unmarshalling

func (Duration) IsAboveZero

func (c Duration) IsAboveZero() bool

IsAboveZero returns true if duration is strictly greater than zero.

func (Duration) IsAtLeastZero

func (c Duration) IsAtLeastZero() bool

IsAtLeastZero returns true if duration is greater or equal to zero.

func (Duration) Seconds

func (c Duration) Seconds() float64

Seconds returns duration in seconds

func (Duration) SecondsU32

func (c Duration) SecondsU32() uint32

SecondsU32 returns duration in seconds as uint32

func (Duration) String

func (c Duration) String() string

String implements `fmt.Stringer`

func (Duration) ToDuration

func (c Duration) ToDuration() time.Duration

ToDuration converts Duration to time.Duration

func (*Duration) UnmarshalText

func (c *Duration) UnmarshalText(data []byte) error

UnmarshalText implements `encoding.TextUnmarshaler`.

type ECS

type ECS struct {
	UseAsClient bool      `yaml:"useAsClient" default:"false"`
	Forward     bool      `yaml:"forward" default:"false"`
	IPv4Mask    ECSv4Mask `yaml:"ipv4Mask" default:"0"`
	IPv6Mask    ECSv6Mask `yaml:"ipv6Mask" default:"0"`
}

ECS is the configuration of the ECS resolver

func (*ECS) IsEnabled

func (c *ECS) IsEnabled() bool

IsEnabled returns true if the ECS resolver is enabled

func (*ECS) LogConfig

func (c *ECS) LogConfig(logger *logrus.Entry)

LogConfig logs the configuration

type ECSv4Mask

type ECSv4Mask uint8

ECSv4Mask is the subnet mask to be added as EDNS0 option for IPv4

func (*ECSv4Mask) UnmarshalText

func (x *ECSv4Mask) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface

type ECSv6Mask

type ECSv6Mask uint8

ECSv6Mask is the subnet mask to be added as EDNS0 option for IPv6

func (*ECSv6Mask) UnmarshalText

func (x *ECSv6Mask) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface

type EDE

type EDE = toEnable

type FQDNOnly

type FQDNOnly = toEnable

type Filtering

type Filtering struct {
	QueryTypes QTypeSet `yaml:"queryTypes"`
}

func (*Filtering) IsEnabled

func (c *Filtering) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*Filtering) LogConfig

func (c *Filtering) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type HostsFile

type HostsFile struct {
	Sources        []BytesSource `yaml:"sources"`
	HostsTTL       Duration      `yaml:"hostsTTL" default:"1h"`
	FilterLoopback bool          `yaml:"filterLoopback"`
	Loading        SourceLoading `yaml:"loading"`

	// Deprecated options
	Deprecated struct {
		RefreshPeriod *Duration    `yaml:"refreshPeriod"`
		Filepath      *BytesSource `yaml:"filePath"`
	} `yaml:",inline"`
}

func (*HostsFile) IsEnabled

func (c *HostsFile) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*HostsFile) LogConfig

func (c *HostsFile) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type IPVersion

type IPVersion uint8

IPVersion represents IP protocol version(s). ENUM( dual // IPv4 and IPv6 v4 // IPv4 only v6 // IPv6 only )

const (
	// IPVersionDual is a IPVersion of type Dual.
	// IPv4 and IPv6
	IPVersionDual IPVersion = iota
	// IPVersionV4 is a IPVersion of type V4.
	// IPv4 only
	IPVersionV4
	// IPVersionV6 is a IPVersion of type V6.
	// IPv6 only
	IPVersionV6
)

func IPVersionValues

func IPVersionValues() []IPVersion

IPVersionValues returns a list of the values for IPVersion

func ParseIPVersion

func ParseIPVersion(name string) (IPVersion, error)

ParseIPVersion attempts to convert a string to a IPVersion.

func (IPVersion) IsValid

func (x IPVersion) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (IPVersion) MarshalText

func (x IPVersion) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (IPVersion) Net

func (ipv IPVersion) Net() string

func (IPVersion) QTypes

func (ipv IPVersion) QTypes() []dns.Type

func (IPVersion) String

func (x IPVersion) String() string

String implements the Stringer interface.

func (*IPVersion) UnmarshalText

func (x *IPVersion) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Init

type Init struct {
	Strategy InitStrategy `yaml:"strategy" default:"blocking"`
}

func (*Init) LogConfig

func (c *Init) LogConfig(logger *logrus.Entry)

type InitStrategy

type InitStrategy uint16

InitStrategy startup strategy ENUM( blocking // synchronously download blocking lists on startup failOnError // synchronously download blocking lists on startup and shutdown on error fast // asyncronously download blocking lists on startup )

const (
	// InitStrategyBlocking is a InitStrategy of type Blocking.
	// synchronously download blocking lists on startup
	InitStrategyBlocking InitStrategy = iota
	// InitStrategyFailOnError is a InitStrategy of type FailOnError.
	// synchronously download blocking lists on startup and shutdown on error
	InitStrategyFailOnError
	// InitStrategyFast is a InitStrategy of type Fast.
	// asyncronously download blocking lists on startup
	InitStrategyFast
)

func InitStrategyValues

func InitStrategyValues() []InitStrategy

InitStrategyValues returns a list of the values for InitStrategy

func ParseInitStrategy

func ParseInitStrategy(name string) (InitStrategy, error)

ParseInitStrategy attempts to convert a string to a InitStrategy.

func (InitStrategy) Do

func (s InitStrategy) Do(ctx context.Context, init func(context.Context) error, logErr func(error)) error

func (InitStrategy) IsValid

func (x InitStrategy) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (InitStrategy) MarshalText

func (x InitStrategy) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (InitStrategy) String

func (x InitStrategy) String() string

String implements the Stringer interface.

func (*InitStrategy) UnmarshalText

func (x *InitStrategy) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type ListenConfig

type ListenConfig []string

ListenConfig is a list of address(es) to listen on

func (*ListenConfig) UnmarshalText

func (l *ListenConfig) UnmarshalText(data []byte) error

UnmarshalText implements `encoding.TextUnmarshaler`.

type Metrics

type Metrics struct {
	Enable bool   `yaml:"enable" default:"false"`
	Path   string `yaml:"path" default:"/metrics"`
}

Metrics contains the config values for prometheus

func (*Metrics) IsEnabled

func (c *Metrics) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*Metrics) LogConfig

func (c *Metrics) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type NetProtocol

type NetProtocol uint16

NetProtocol resolver protocol ENUM( tcp+udp // TCP and UDP protocols tcp-tls // TCP-TLS protocol https // HTTPS protocol )

const (
	// NetProtocolTcpUdp is a NetProtocol of type Tcp+Udp.
	// TCP and UDP protocols
	NetProtocolTcpUdp NetProtocol = iota
	// NetProtocolTcpTls is a NetProtocol of type Tcp-Tls.
	// TCP-TLS protocol
	NetProtocolTcpTls
	// NetProtocolHttps is a NetProtocol of type Https.
	// HTTPS protocol
	NetProtocolHttps
)

func NetProtocolValues

func NetProtocolValues() []NetProtocol

NetProtocolValues returns a list of the values for NetProtocol

func ParseNetProtocol

func ParseNetProtocol(name string) (NetProtocol, error)

ParseNetProtocol attempts to convert a string to a NetProtocol.

func (NetProtocol) IsValid

func (x NetProtocol) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (NetProtocol) MarshalText

func (x NetProtocol) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (NetProtocol) String

func (x NetProtocol) String() string

String implements the Stringer interface.

func (*NetProtocol) UnmarshalText

func (x *NetProtocol) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Ports

type Ports struct {
	DNS   ListenConfig `yaml:"dns" default:"53"`
	HTTP  ListenConfig `yaml:"http"`
	HTTPS ListenConfig `yaml:"https"`
	TLS   ListenConfig `yaml:"tls"`
}

func (*Ports) LogConfig

func (c *Ports) LogConfig(logger *logrus.Entry)

type QType

type QType dns.Type

func (QType) String

func (c QType) String() string

func (*QType) UnmarshalText

func (c *QType) UnmarshalText(data []byte) error

UnmarshalText implements `encoding.TextUnmarshaler`.

type QTypeSet

type QTypeSet map[QType]struct{}

func NewQTypeSet

func NewQTypeSet(qTypes ...dns.Type) QTypeSet

func (QTypeSet) Contains

func (s QTypeSet) Contains(qType dns.Type) bool

func (*QTypeSet) Insert

func (s *QTypeSet) Insert(qType dns.Type)

func (*QTypeSet) UnmarshalYAML

func (s *QTypeSet) UnmarshalYAML(unmarshal func(interface{}) error) error

type QueryLog

type QueryLog struct {
	Target           string          `yaml:"target"`
	Type             QueryLogType    `yaml:"type"`
	LogRetentionDays uint64          `yaml:"logRetentionDays"`
	CreationAttempts int             `yaml:"creationAttempts" default:"3"`
	CreationCooldown Duration        `yaml:"creationCooldown" default:"2s"`
	Fields           []QueryLogField `yaml:"fields"`
	FlushInterval    Duration        `yaml:"flushInterval" default:"30s"`
	Ignore           QueryLogIgnore  `yaml:"ignore"`
}

QueryLog configuration for the query logging

func (*QueryLog) IsEnabled

func (c *QueryLog) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*QueryLog) LogConfig

func (c *QueryLog) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

func (*QueryLog) SetDefaults

func (c *QueryLog) SetDefaults()

SetDefaults implements `defaults.Setter`.

type QueryLogField

type QueryLogField string

QueryLogField data field to be logged ENUM(clientIP,clientName,responseReason,responseAnswer,question,duration)

const (
	// QueryLogFieldClientIP is a QueryLogField of type clientIP.
	QueryLogFieldClientIP QueryLogField = "clientIP"
	// QueryLogFieldClientName is a QueryLogField of type clientName.
	QueryLogFieldClientName QueryLogField = "clientName"
	// QueryLogFieldResponseReason is a QueryLogField of type responseReason.
	QueryLogFieldResponseReason QueryLogField = "responseReason"
	// QueryLogFieldResponseAnswer is a QueryLogField of type responseAnswer.
	QueryLogFieldResponseAnswer QueryLogField = "responseAnswer"
	// QueryLogFieldQuestion is a QueryLogField of type question.
	QueryLogFieldQuestion QueryLogField = "question"
	// QueryLogFieldDuration is a QueryLogField of type duration.
	QueryLogFieldDuration QueryLogField = "duration"
)

func ParseQueryLogField

func ParseQueryLogField(name string) (QueryLogField, error)

ParseQueryLogField attempts to convert a string to a QueryLogField.

func QueryLogFieldValues

func QueryLogFieldValues() []QueryLogField

QueryLogFieldValues returns a list of the values for QueryLogField

func (QueryLogField) IsValid

func (x QueryLogField) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (QueryLogField) MarshalText

func (x QueryLogField) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (QueryLogField) String

func (x QueryLogField) String() string

String implements the Stringer interface.

func (*QueryLogField) UnmarshalText

func (x *QueryLogField) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type QueryLogIgnore

type QueryLogIgnore struct {
	SUDN bool `yaml:"sudn" default:"false"`
}

type QueryLogType

type QueryLogType int16

QueryLogType type of the query log ENUM( console // use logger as fallback none // no logging mysql // MySQL or MariaDB database postgresql // PostgreSQL database csv // CSV file per day csv-client // CSV file per day and client )

const (
	// QueryLogTypeConsole is a QueryLogType of type Console.
	// use logger as fallback
	QueryLogTypeConsole QueryLogType = iota
	// QueryLogTypeNone is a QueryLogType of type None.
	// no logging
	QueryLogTypeNone
	// QueryLogTypeMysql is a QueryLogType of type Mysql.
	// MySQL or MariaDB database
	QueryLogTypeMysql
	// QueryLogTypePostgresql is a QueryLogType of type Postgresql.
	// PostgreSQL database
	QueryLogTypePostgresql
	// QueryLogTypeCsv is a QueryLogType of type Csv.
	// CSV file per day
	QueryLogTypeCsv
	// QueryLogTypeCsvClient is a QueryLogType of type Csv-Client.
	// CSV file per day and client
	QueryLogTypeCsvClient
)

func ParseQueryLogType

func ParseQueryLogType(name string) (QueryLogType, error)

ParseQueryLogType attempts to convert a string to a QueryLogType.

func QueryLogTypeValues

func QueryLogTypeValues() []QueryLogType

QueryLogTypeValues returns a list of the values for QueryLogType

func (QueryLogType) IsValid

func (x QueryLogType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (QueryLogType) MarshalText

func (x QueryLogType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (QueryLogType) String

func (x QueryLogType) String() string

String implements the Stringer interface.

func (*QueryLogType) UnmarshalText

func (x *QueryLogType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Redis

type Redis struct {
	Address            string   `yaml:"address"`
	Username           string   `yaml:"username" default:""`
	Password           string   `yaml:"password" default:""`
	Database           int      `yaml:"database" default:"0"`
	Required           bool     `yaml:"required" default:"false"`
	ConnectionAttempts int      `yaml:"connectionAttempts" default:"3"`
	ConnectionCooldown Duration `yaml:"connectionCooldown" default:"1s"`
	SentinelUsername   string   `yaml:"sentinelUsername" default:""`
	SentinelPassword   string   `yaml:"sentinelPassword" default:""`
	SentinelAddresses  []string `yaml:"sentinelAddresses"`
}

Redis configuration for the redis connection

func (*Redis) IsEnabled

func (c *Redis) IsEnabled() bool

IsEnabled implements `config.Configurable`

func (*Redis) LogConfig

func (c *Redis) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`

type RewriterConfig

type RewriterConfig struct {
	Rewrite          map[string]string `yaml:"rewrite"`
	FallbackUpstream bool              `yaml:"fallbackUpstream" default:"false"`
}

RewriterConfig custom DNS configuration

func (*RewriterConfig) IsEnabled

func (c *RewriterConfig) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*RewriterConfig) LogConfig

func (c *RewriterConfig) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type SUDN

type SUDN struct {
	// These are "recommended for private use" but not mandatory.
	// If a user wishes to use one, it will most likely be via conditional
	// upstream or custom DNS, which come before SUDN in the resolver chain.
	// Thus defaulting to `true` and returning NXDOMAIN here should not conflict.
	RFC6762AppendixG bool `yaml:"rfc6762-appendixG" default:"true"`
}

SUDN configuration for Special Use Domain Names

func (*SUDN) IsEnabled

func (c *SUDN) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*SUDN) LogConfig

func (c *SUDN) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type SourceLoading

type SourceLoading struct {
	Init `yaml:",inline"`

	Concurrency        uint       `yaml:"concurrency" default:"4"`
	MaxErrorsPerSource int        `yaml:"maxErrorsPerSource" default:"5"`
	RefreshPeriod      Duration   `yaml:"refreshPeriod" default:"4h"`
	Downloads          Downloader `yaml:"downloads"`
}

func (*SourceLoading) LogConfig

func (c *SourceLoading) LogConfig(logger *logrus.Entry)

func (*SourceLoading) StartPeriodicRefresh

func (c *SourceLoading) StartPeriodicRefresh(
	ctx context.Context, refresh func(context.Context) error, logErr func(error),
) error

type TLSVersion

type TLSVersion int // values MUST match `tls.VersionTLS*`

TLSVersion represents a TLS protocol version. ENUM( 1.0 = 769 1.1 1.2 1.3 )

const (
	// TLSVersion10 is a TLSVersion of type 1.0.
	TLSVersion10 TLSVersion = iota + 769
	// TLSVersion11 is a TLSVersion of type 1.1.
	TLSVersion11
	// TLSVersion12 is a TLSVersion of type 1.2.
	TLSVersion12
	// TLSVersion13 is a TLSVersion of type 1.3.
	TLSVersion13
)

func ParseTLSVersion

func ParseTLSVersion(name string) (TLSVersion, error)

ParseTLSVersion attempts to convert a string to a TLSVersion.

func TLSVersionValues

func TLSVersionValues() []TLSVersion

TLSVersionValues returns a list of the values for TLSVersion

func (TLSVersion) IsValid

func (x TLSVersion) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (TLSVersion) MarshalText

func (x TLSVersion) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (TLSVersion) String

func (x TLSVersion) String() string

String implements the Stringer interface.

func (*TLSVersion) UnmarshalText

func (x *TLSVersion) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Upstream

type Upstream struct {
	Net        NetProtocol
	Host       string
	Port       uint16
	Path       string
	CommonName string // Common Name to use for certificate verification; optional. "" uses .Host
}

Upstream is the definition of external DNS server

func ParseUpstream

func ParseUpstream(upstream string) (Upstream, error)

ParseUpstream creates new Upstream from passed string in format net:host[:port][/path][#commonname]

func (*Upstream) IsDefault

func (u *Upstream) IsDefault() bool

IsDefault returns true if u is the default value

func (Upstream) String

func (u Upstream) String() string

String returns the string representation of u

func (*Upstream) UnmarshalText

func (u *Upstream) UnmarshalText(data []byte) error

UnmarshalText implements `encoding.TextUnmarshaler`.

type UpstreamGroup

type UpstreamGroup struct {
	Upstreams

	Name string // group name
}

UpstreamGroup represents the config for one group (upstream branch)

func NewUpstreamGroup

func NewUpstreamGroup(name string, cfg Upstreams, upstreams []Upstream) UpstreamGroup

NewUpstreamGroup creates an UpstreamGroup with the given name and upstreams.

The upstreams from `cfg.Groups` are ignored.

func (*UpstreamGroup) GroupUpstreams

func (c *UpstreamGroup) GroupUpstreams() []Upstream

func (*UpstreamGroup) IsEnabled

func (c *UpstreamGroup) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*UpstreamGroup) LogConfig

func (c *UpstreamGroup) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type UpstreamGroups

type UpstreamGroups map[string][]Upstream

type UpstreamStrategy

type UpstreamStrategy uint8

UpstreamStrategy data field to be logged ENUM(parallel_best,strict,random)

const (
	// UpstreamStrategyParallelBest is a UpstreamStrategy of type Parallel_best.
	UpstreamStrategyParallelBest UpstreamStrategy = iota
	// UpstreamStrategyStrict is a UpstreamStrategy of type Strict.
	UpstreamStrategyStrict
	// UpstreamStrategyRandom is a UpstreamStrategy of type Random.
	UpstreamStrategyRandom
)

func ParseUpstreamStrategy

func ParseUpstreamStrategy(name string) (UpstreamStrategy, error)

ParseUpstreamStrategy attempts to convert a string to a UpstreamStrategy.

func UpstreamStrategyValues

func UpstreamStrategyValues() []UpstreamStrategy

UpstreamStrategyValues returns a list of the values for UpstreamStrategy

func (UpstreamStrategy) IsValid

func (x UpstreamStrategy) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (UpstreamStrategy) MarshalText

func (x UpstreamStrategy) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (UpstreamStrategy) String

func (x UpstreamStrategy) String() string

String implements the Stringer interface.

func (*UpstreamStrategy) UnmarshalText

func (x *UpstreamStrategy) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Upstreams

type Upstreams struct {
	Init      Init             `yaml:"init"`
	Timeout   Duration         `yaml:"timeout" default:"2s"` // always > 0
	Groups    UpstreamGroups   `yaml:"groups"`
	Strategy  UpstreamStrategy `yaml:"strategy" default:"parallel_best"`
	UserAgent string           `yaml:"userAgent"`
}

Upstreams upstream servers configuration

func (*Upstreams) IsEnabled

func (c *Upstreams) IsEnabled() bool

IsEnabled implements `config.Configurable`.

func (*Upstreams) LogConfig

func (c *Upstreams) LogConfig(logger *logrus.Entry)

LogConfig implements `config.Configurable`.

type ZoneFileDNS

type ZoneFileDNS struct {
	RRs CustomDNSMapping
	// contains filtered or unexported fields
}

func (*ZoneFileDNS) UnmarshalYAML

func (z *ZoneFileDNS) UnmarshalYAML(unmarshal func(interface{}) error) error

Directories

Path Synopsis
Package migration helps with migrating deprecated config options.
Package migration helps with migrating deprecated config options.

Jump to

Keyboard shortcuts

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