Documentation ¶
Index ¶
- Constants
- func GetMaxAnswer(ctx context.Context) (int, bool)
- func MakeOPTWithECS(s string) (*dns.OPT, error)
- func WithMaxAnswer(ctx context.Context, masAns int) context.Context
- type CacheConfig
- type DBConfig
- type DummyLogger
- type FBDNSDB
- func (h *FBDNSDB) AcquireReader() (db.Reader, error)
- func (h *FBDNSDB) Close()
- func (h *FBDNSDB) Load() (err error)
- func (h *FBDNSDB) Name() string
- func (h *FBDNSDB) PeriodicDBReload(reloadInt int)
- func (h *FBDNSDB) QuerySingle(rtype, record, remoteIP, subnet string, maxAns int) (*dnstest.Recorder, error)
- func (h *FBDNSDB) Reload(s ReloadSignal) (err error)
- func (h *FBDNSDB) ReportBackendStats()
- func (h *FBDNSDB) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)
- func (h *FBDNSDB) ServeDNSWithRCODE(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)
- func (h *FBDNSDB) ValidateDbKey(dbKey []byte) error
- func (h *FBDNSDB) WatchControlDirAndReload() error
- func (h *FBDNSDB) WatchDBAndReload() error
- type HandlerConfig
- type Logger
- type ReloadSignal
- type ReloadType
- type TextLogger
Constants ¶
const ( ControlFileFullReload = "switchdb" ControlFilePartialReload = "reload" )
group of control files we watch for to reload DB
const ( // TypeToStatsPrefix is the prefix used for creating stats keys TypeToStatsPrefix = "DNS_query" // DefaultMaxAnswer is the default number of answer returned for A\AAAA query DefaultMaxAnswer = 1 )
Variables ¶
This section is empty.
Functions ¶
func GetMaxAnswer ¶
GetMaxAnswer is used to get max answer number from context
func MakeOPTWithECS ¶
MakeOPTWithECS returns dns.OPT with a specified subnet EDNS0 option FIXME: Instead of returning a dns.OPT specifically for EDNS0 Make this function more standardized to support all types of options (e.g: ecs, dns cookie..) see: https://tools.ietf.org/html/rfc6891#section-6
Types ¶
type CacheConfig ¶
CacheConfig has knobs to modify caching behaviour.
type DBConfig ¶
type DBConfig struct { Path string ControlPath string Driver string ReloadInterval int ReloadTimeout time.Duration WatchDB bool ValidationKey []byte }
DBConfig contains our DNS Database configuration.
type DummyLogger ¶
type DummyLogger struct{}
DummyLogger logs nothing
func (*DummyLogger) Log ¶
func (l *DummyLogger) Log(_ request.Request, _ *dns.Msg, _ *dns.EDNS0_SUBNET, _ *db.Location)
Log is used to log to an ioWriter.
func (*DummyLogger) LogFailed ¶
func (l *DummyLogger) LogFailed(_ request.Request, _ *dns.EDNS0_SUBNET, _ *db.Location)
LogFailed is used to log failures
type FBDNSDB ¶
type FBDNSDB struct { ReloadChan chan ReloadSignal Next plugin.Handler // contains filtered or unexported fields }
FBDNSDB is the DNS DB handler.
func NewFBDNSDB ¶
func NewFBDNSDB(handlerConfig HandlerConfig, dbConfig DBConfig, cacheConfig CacheConfig, l Logger, s stats.Stats) (t *FBDNSDB, err error)
NewFBDNSDB initialize a new FBDNSDB and set up DB reloading
func NewFBDNSDBBasic ¶
func NewFBDNSDBBasic(handlerConfig HandlerConfig, dbConfig DBConfig, cacheConfig CacheConfig, l Logger, s stats.Stats) (t *FBDNSDB, err error)
NewFBDNSDBBasic initialize a new FBDNSDB. Reloading strategy is left to be set.
func (*FBDNSDB) AcquireReader ¶
AcquireReader return a DB reader which increment the refcount to the DB. This makes sure that we can handle DB reloading from other goroutine while providing a consistent view on the DB during a query. The Reader must be `Close`d when not needed anymore.
func (*FBDNSDB) Close ¶
func (h *FBDNSDB) Close()
Close closes the database. It also takes care of closing the channel used for periodic reloading.
func (*FBDNSDB) PeriodicDBReload ¶
PeriodicDBReload is to enforce db reload in case db watch fails or stuck
func (*FBDNSDB) QuerySingle ¶
func (h *FBDNSDB) QuerySingle(rtype, record, remoteIP, subnet string, maxAns int) (*dnstest.Recorder, error)
QuerySingle queries dns server for a query, returning single answer if possible
func (*FBDNSDB) ReportBackendStats ¶
func (h *FBDNSDB) ReportBackendStats()
ReportBackendStats refreshes backend statistics in server stats
func (*FBDNSDB) ServeDNSWithRCODE ¶
func (h *FBDNSDB) ServeDNSWithRCODE(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)
ServeDNSWithRCODE handles a dns query and with return the RCODE and eventual error that happen during processing.
func (*FBDNSDB) ValidateDbKey ¶
ValidateDbKey checks whether record of certain key is in db
func (*FBDNSDB) WatchControlDirAndReload ¶
WatchControlDirAndReload refreshes the data view on control file change. We monitor for two type of reload signals: full reload, when we switch to new file/directory, and partial reload when we try to catch up on WAL if possible. CDB does full reload in both cases as it's immutable.
func (*FBDNSDB) WatchDBAndReload ¶
WatchDBAndReload refreshes the data view on DB file change
type HandlerConfig ¶
type HandlerConfig struct { // Controls whether responses are always compressed not depending on response buffer size AlwaysCompress bool // Controls whether CNAME chasing is enabled/disabled CNAMEChasing bool // Controls the number of max hops we do for CNAME chasing MaxCNAMEHops int }
HandlerConfig contains config used when handling a DNS request.
type Logger ¶
type Logger interface { // LogFailed logs a message when we could not construct an answer LogFailed(state request.Request, ecs *dns.EDNS0_SUBNET, loc *db.Location) // Log logs a DNS response Log(state request.Request, r *dns.Msg, ecs *dns.EDNS0_SUBNET, loc *db.Location) }
Logger is an interface for logging messages
type ReloadSignal ¶
type ReloadSignal struct { Kind ReloadType Payload string }
ReloadSignal is a signal we use to tell server that something/someone requested DB reload
func NewFullReloadSignal ¶
func NewFullReloadSignal(newDBPath string) *ReloadSignal
NewFullReloadSignal is a helper to create new ReloadSignal of kind FullReload
func NewPartialReloadSignal ¶
func NewPartialReloadSignal() *ReloadSignal
NewPartialReloadSignal is a helper to create new ReloadSignal of kind PartialReload
type ReloadType ¶
type ReloadType int
ReloadType - how to reload the DB
const ( // FullReload - close and open DB FullReload ReloadType = iota // PartialReload - Catch up on WAL PartialReload )
type TextLogger ¶
TextLogger logs to an io.Writer
func (*TextLogger) Log ¶
func (l *TextLogger) Log(state request.Request, _ *dns.Msg, _ *dns.EDNS0_SUBNET, _ *db.Location)
Log is used to log to an ioWriter.
func (*TextLogger) LogFailed ¶
func (l *TextLogger) LogFailed(state request.Request, ecs *dns.EDNS0_SUBNET, loc *db.Location)
LogFailed is used to log failures