Documentation
¶
Overview ¶
Package dnsdb contains types and utilities for collecting anonymous statistics about the Internet.
TODO(a.garipov): This needs way more tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Default ¶
type Default struct {
// contains filtered or unexported fields
}
Default is the default DNSDB implementation.
func New ¶
func New(c *DefaultConfig) (db *Default)
New creates a new default DNS database. c must not be nil.
func (*Default) Record ¶
Record implements the Interface interface for *Default. It saves a DNS response to its in-memory buffer.
func (*Default) ServeHTTP ¶
func (db *Default) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface for *Default.
type DefaultConfig ¶
type DefaultConfig struct {
// Clock is used to get the current time. It must not be nil.
Clock timeutil.Clock
// Logger is used to log the operation of the DNS database. It must not be
// nil.
Logger *slog.Logger
// ErrColl is used to collect HTTP errors. It must not be nil.
ErrColl errcoll.Interface
// Metrics is used for the collection of the DNS database statistics. It
// must not be nil.
Metrics Metrics
// MaxSize is the maximum amount of records in the memory buffer. It must
// be positive.
MaxSize int
}
DefaultConfig is the default DNS database configuration structure.
type EmptyMetrics ¶
type EmptyMetrics struct{}
EmptyMetrics is the implementation of the Metrics interface that does nothing.
func (EmptyMetrics) ObserveRotation ¶
func (EmptyMetrics) ObserveRotation(_ context.Context, dur time.Duration)
ObserveRotation implements the Metrics interface for EmptyMetrics.
func (EmptyMetrics) SetRecordCount ¶
func (EmptyMetrics) SetRecordCount(_ context.Context, _ int)
SetRecordCount implements the Metrics interface for EmptyMetrics.
type Interface ¶
type Interface interface {
// Record saves anonymous data from the DNS query.
Record(ctx context.Context, resp *dns.Msg, ri *agd.RequestInfo)
}
Interface is the DNS query database interface.
type Metrics ¶
type Metrics interface {
// SetRecordCount sets the number of records that have not yet been
// uploaded.
SetRecordCount(ctx context.Context, count int)
// ObserveRotation updates the time of the database rotation and stores the
// duration of the rotation.
ObserveRotation(ctx context.Context, dur time.Duration)
}
Metrics is an interface that is used for the collection of the DNS database statistics.