dnsdb

package
v0.0.0-...-2fd833d Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

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

func (db *Default) Record(ctx context.Context, m *dns.Msg, ri *agd.RequestInfo)

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 Empty

type Empty struct{}

Empty is a DNS query database that does nothing.

func (Empty) Record

func (Empty) Record(_ context.Context, _ *dns.Msg, _ *agd.RequestInfo)

Record implements the Interface interface for Empty.

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.

Jump to

Keyboard shortcuts

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