fbserver

package
v0.0.0-...-b5afeba Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DBTimestampDBReadError occurs we cannot read DB.
	DBTimestampDBReadError = "db.timestamp.db_read_error"
	// DBTimestampInvalidTXT happens when a/the TXT record is not parseable to int64.
	DBTimestampInvalidTXT = "db.timestamp.invalid_txt"
	// DBTimestampKeySearchError means that searching the key itself failed. This is a DB lookup issue, not anything related to the key.
	DBTimestampKeySearchError = "db.timestamp.key_search_error"
	// DBTimestampKeyNotFound happens when we did not find the key, or we did not find any valid TXT record.
	DBTimestampKeyNotFound = "db.timestamp.key_not_found"
	// DBTimestampNumRun increments on every timestamp lookup.
	DBTimestampNumRun = "db.timestamp.num_run"
	// DBTimestamp is the actual key storing the db timestamp value.
	DBTimestamp = "db.timestamp"
	// DBFreshness is difference in seconds between db timestamp value and current time
	DBFreshness = "db.freshness"
)
View Source
const BackendStatsInterval = 10

BackendStatsInterval is the interval at which we report backend stats, in seconds.

View Source
const DBTimestampInterval = 10

DBTimestampInterval is the interval at which we update the DB timestamp, in seconds.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionMonitor

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

ConnectionMonitor is a wrapper around `net.Conn` which serves to log per connection metrics.

func NewConnectionMonitor

func NewConnectionMonitor(c net.Conn, transportName MonitorType, s *metrics.Stats) *ConnectionMonitor

NewConnectionMonitor makes a new ConnectionMonitor from `net.Conn`. It also initializes and increments the appropriate counters for the connection.

func (*ConnectionMonitor) Close

func (cm *ConnectionMonitor) Close() error

Close calls `net.Conn.Close` and then increments counters

func (*ConnectionMonitor) LocalAddr

func (cm *ConnectionMonitor) LocalAddr() net.Addr

LocalAddr is a passthrough for `net.Conn.LocalAddr`

func (*ConnectionMonitor) Read

func (cm *ConnectionMonitor) Read(b []byte) (int, error)

Read is a passthrough for `net.Conn.Read`

func (*ConnectionMonitor) RemoteAddr

func (cm *ConnectionMonitor) RemoteAddr() net.Addr

RemoteAddr is a passthrough for `net.Conn.RemoteAddr`

func (*ConnectionMonitor) SetDeadline

func (cm *ConnectionMonitor) SetDeadline(t time.Time) error

SetDeadline is a passthrough for `net.Conn.SetDeadline`

func (*ConnectionMonitor) SetReadDeadline

func (cm *ConnectionMonitor) SetReadDeadline(t time.Time) error

SetReadDeadline is a passthrough for `net.Conn.SetReadDeadline`

func (*ConnectionMonitor) SetWriteDeadline

func (cm *ConnectionMonitor) SetWriteDeadline(t time.Time) error

SetWriteDeadline is a passthrough for `net.Conn.SetWriteDeadline`

func (*ConnectionMonitor) Write

func (cm *ConnectionMonitor) Write(b []byte) (int, error)

Write is a passthrough for `net.Conn.Write`

type DNSSECConfig

type DNSSECConfig struct {
	Zones string
	Keys  string
}

DNSSECConfig contains the zones and keys configs received from command line e.g comma-separated lists.

type Monitor

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

Monitor is a net.Listener that logs and captures socket metrics.

func NewMonitor

func NewMonitor(l net.Listener, t MonitorType, s *metrics.Stats) *Monitor

NewMonitor creates a Monitor from a net.Listener.

func (*Monitor) Accept

func (m *Monitor) Accept() (net.Conn, error)

Accept monitors net.Listener.Accept.

func (*Monitor) Addr

func (m *Monitor) Addr() net.Addr

Addr increments a counter and then calls net.Listener.Addr.

func (*Monitor) Close

func (m *Monitor) Close() error

Close monitors net.listener.Close.

type MonitorType

type MonitorType string

MonitorType is a transport protocol string (e.g., "tcp").

type PacketConnectionMonitor

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

PacketConnectionMonitor is a wrapper around `net.PacketConn` which servers to log per request metrics

func NewPacketConnectionMonitor

func NewPacketConnectionMonitor(c net.PacketConn, transportName MonitorType, s *metrics.Stats) *PacketConnectionMonitor

NewPacketConnectionMonitor makes a new PacketConnectionMonitor from `net.PacketConn`. It also initializes and increments the appropriate counters for the connection.

func (*PacketConnectionMonitor) Close

func (pcm *PacketConnectionMonitor) Close() error

Close calls `net.PacketConn.Close` and then increments counters

func (*PacketConnectionMonitor) LocalAddr

func (pcm *PacketConnectionMonitor) LocalAddr() net.Addr

LocalAddr is a passthrough for `net.PacketConn.LocalAddr`

func (*PacketConnectionMonitor) ReadFrom

func (pcm *PacketConnectionMonitor) ReadFrom(p []byte) (int, net.Addr, error)

ReadFrom calls `net.PacketConn.ReadFrom` and increments the counter

func (*PacketConnectionMonitor) SetDeadline

func (pcm *PacketConnectionMonitor) SetDeadline(t time.Time) error

SetDeadline is a passthrough for `net.PacketConn.SetDeadline`

func (*PacketConnectionMonitor) SetReadDeadline

func (pcm *PacketConnectionMonitor) SetReadDeadline(t time.Time) error

SetReadDeadline is a passthrough for `net.PacketConn.SetReadDeadline`

func (*PacketConnectionMonitor) SetWriteDeadline

func (pcm *PacketConnectionMonitor) SetWriteDeadline(t time.Time) error

SetWriteDeadline is a passthrough for `net.PacketConn.SetWriteDeadline`

func (*PacketConnectionMonitor) WriteTo

func (pcm *PacketConnectionMonitor) WriteTo(p []byte, addr net.Addr) (int, error)

WriteTo is a passthrough for `net.PacketConn.WriteTo`

type Server

type Server struct {

	// If NotifyStartedFunc is set it is called once the server has started listening.
	NotifyStartedFunc func()

	// Wait group which can be used to wait for servers to initialize and start serving.
	// Client can wait for servers to start by invoking Done() method in NotifyStartedFunc
	// and wait for WaitGroup
	ServersStartedWG sync.WaitGroup
	// contains filtered or unexported fields
}

Server collects all of the running servers and the server configurations.

func NewServer

func NewServer(conf ServerConfig, logger dnsserver.Logger, stats stats.Stats, metricsExporter anyMetricsExporter) *Server

NewServer start the server given a server config, a logger and a stat collector

func (*Server) DumpBackendStats

func (srv *Server) DumpBackendStats()

DumpBackendStats reports stats reported by DB backend as server counters

func (*Server) LogMapAge

func (srv *Server) LogMapAge()

LogMapAge will log DB timestamp every `DBTimestampInterval`.

func (*Server) PeriodicDBReload

func (srv *Server) PeriodicDBReload(reloadInt int)

PeriodicDBReload reloads db map periodically

func (*Server) ReloadDB

func (srv *Server) ReloadDB()

ReloadDB refreshes the data view

func (*Server) Shutdown

func (srv *Server) Shutdown()

Shutdown shuts down all the underlying servers and close the DB.

func (*Server) Start

func (srv *Server) Start() (err error)

Start iterates through a list of configured IPs, and starts a separate goroutine to handle DNS requests on the protocols enabled in the configuration. Start does not block, and the servers may fail with fatal errors.

func (*Server) ValidateDbKey

func (srv *Server) ValidateDbKey(dbKey []byte) error

ValidateDbKey checks whether record of certain key is in db

func (*Server) WatchControlDirAndReload

func (srv *Server) WatchControlDirAndReload()

WatchControlDirAndReload refreshes the data view on control file signals change

func (*Server) WatchDBAndReload

func (srv *Server) WatchDBAndReload()

WatchDBAndReload refreshes the data view on DB file change

type ServerConfig

type ServerConfig struct {
	IPAns          ipAns
	Port           int
	MaxUDPSize     int
	TCP            bool
	TLS            bool
	ReusePort      int
	MaxTCPQueries  int
	TCPIdleTimeout time.Duration
	NumCPU         int
	MaxConcurrency int
	ReadTimeout    time.Duration
	TLSConfig      tlsconfig.TLSConfig
	HandlerConfig  dnsserver.HandlerConfig
	CacheConfig    dnsserver.CacheConfig
	DBConfig       dnsserver.DBConfig
	WhoamiDomain   string
	RefuseANY      bool
	DNSSECConfig   DNSSECConfig
	NSID           bool
	PrivateInfo    bool
}

ServerConfig represent the configuration for a given DNS server

func NewServerConfig

func NewServerConfig() (s ServerConfig)

NewServerConfig returns a fully initialized server configuration.

type TLSConnectionMonitor

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

TLSConnectionMonitor is a wrapper around `tls.Conn` which serves to log per connection metrics.

func NewTLSConnectionMonitor

func NewTLSConnectionMonitor(c net.Conn, transportName MonitorType, s *metrics.Stats) *TLSConnectionMonitor

NewTLSConnectionMonitor makes a new ConnectionMonitor from `net.Conn`. It also initializes and increments the appropriate counters for the connection.

func (*TLSConnectionMonitor) Close

func (cm *TLSConnectionMonitor) Close() error

Close calls `net.Conn.Close` and then increments counters

func (*TLSConnectionMonitor) ConnectionState

func (cm *TLSConnectionMonitor) ConnectionState() tls.ConnectionState

ConnectionState is a passthrough for `tls.Conn.ConnectionState`

func (*TLSConnectionMonitor) LocalAddr

func (cm *TLSConnectionMonitor) LocalAddr() net.Addr

LocalAddr is a passthrough for `net.Conn.LocalAddr`

func (*TLSConnectionMonitor) Read

func (cm *TLSConnectionMonitor) Read(b []byte) (int, error)

Read is a passthrough for `net.Conn.Read`

func (*TLSConnectionMonitor) RemoteAddr

func (cm *TLSConnectionMonitor) RemoteAddr() net.Addr

RemoteAddr is a passthrough for `net.Conn.RemoteAddr`

func (*TLSConnectionMonitor) SetDeadline

func (cm *TLSConnectionMonitor) SetDeadline(t time.Time) error

SetDeadline is a passthrough for `net.Conn.SetDeadline`

func (*TLSConnectionMonitor) SetReadDeadline

func (cm *TLSConnectionMonitor) SetReadDeadline(t time.Time) error

SetReadDeadline is a passthrough for `net.Conn.SetReadDeadline`

func (*TLSConnectionMonitor) SetWriteDeadline

func (cm *TLSConnectionMonitor) SetWriteDeadline(t time.Time) error

SetWriteDeadline is a passthrough for `net.Conn.SetWriteDeadline`

func (*TLSConnectionMonitor) Write

func (cm *TLSConnectionMonitor) Write(b []byte) (int, error)

Write is a passthrough for `net.Conn.Write`

Jump to

Keyboard shortcuts

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