dnscheck

package
v0.0.0-...-c1ed7b1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package dnscheck contains types and utilities for checking if a particular client uses the DNS server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyMetrics

type EmptyMetrics struct{}

EmptyMetrics is the implementation of the Metrics interface that does nothing.

func (EmptyMetrics) HandleError

func (EmptyMetrics) HandleError(_ context.Context, _, _ string)

HandleError implements the Metrics interface for EmptyMetrics.

func (EmptyMetrics) HandleRequest

func (EmptyMetrics) HandleRequest(_ context.Context, _ string, _ bool)

HandleRequest implements the Metrics interface for EmptyMetrics.

type Interface

type Interface interface {
	// Check saves the information about a client's request and returns the
	// appropriate response.  If req is not the right type of request or not
	// a request for the appropriate check domain, both resp and err are nil.
	//
	// All arguments must be non-nil.  req must contain one question, which
	// should be either an A or an AAAA one.
	Check(ctx context.Context, req *dns.Msg, ri *agd.RequestInfo) (resp *dns.Msg, err error)
}

Interface is the DNS checker interface. All methods must be safe for concurrent use.

type Metrics

type Metrics interface {
	// HandleError handles the total number of errors by type.  reqType must be
	// [reqMtrcTypeDNS] or [reqMtrcTypeHTTP].  errType must be either
	// [errMtrcTypeTimeout], [errMtrcTypeRatelimit], [errMtrcTypeOther] or an
	// empty string.
	HandleError(ctx context.Context, reqType, errType string)

	// HandleRequest handles the total number of requests by type.  reqType must
	// be [reqMtrcTypeDNS] or [reqMtrcTypeHTTP].
	HandleRequest(ctx context.Context, reqType string, isValid bool)
}

Metrics is an interface that is used for the collection of the DNSCheck service statistics.

type RemoteKV

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

RemoteKV is the RemoteKV KV based DNS checker.

func NewRemoteKV

func NewRemoteKV(c *RemoteKVConfig) (dc *RemoteKV)

NewRemoteKV creates a new remote KV based DNS checker. c must be non-nil.

func (*RemoteKV) Check

func (dc *RemoteKV) Check(
	ctx context.Context,
	req *dns.Msg,
	ri *agd.RequestInfo,
) (resp *dns.Msg, err error)

Check implements the Interface interface for *RemoteKV.

func (*RemoteKV) ServeHTTP

func (dc *RemoteKV) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface for *RemoteKV.

TODO(a.garipov): Find ways of merging the attributes of [RemoteKV.logger] and the logger that websvc adds.

type RemoteKVConfig

type RemoteKVConfig struct {
	// Logger is used to log the operation of the DNS checker.
	Logger *slog.Logger

	// Messages is the message constructor used to create DNS responses with
	// IPv4 and IPv6 IPs.
	Messages *dnsmsg.Constructor

	// Metrics is used for the collection of the DNSCheck service statistics.
	Metrics Metrics

	// RemoteKV for DNS server checking.
	RemoteKV remotekv.Interface

	// ErrColl is the error collector that is used to collect non-critical
	// errors.
	ErrColl errcoll.Interface

	// Domains are the lower-cased domain names used to detect DNS check requests.
	Domains []string

	// NodeLocation is the location of this server node.
	NodeLocation string

	// NodeName is the name of this server node.
	NodeName string

	// IPv4 are the IPv4 addresses to respond with to A requests.
	IPv4 []netip.Addr

	// IPv6 are the IPv6 addresses to respond with to AAAA requests.
	IPv6 []netip.Addr
}

RemoteKVConfig is the configuration structure for remote KV based DNS checker. All fields must be non-empty.

Jump to

Keyboard shortcuts

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