dnscheck

package
v0.0.0-...-b6e3791 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: AGPL-3.0 Imports: 25 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 Consul

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

Consul is the Consul KV based DNS checker.

TODO(a.garipov): Add tests.

func NewConsul

func NewConsul(c *ConsulConfig) (cc *Consul, err error)

NewConsul creates a new Consul KV based DNS checker. c must be non-nil.

func (*Consul) Check

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

Check implements the Interface interface for *Consul. The context must contain the lowercased hostname as well as the server information.

func (*Consul) ServeHTTP

func (cc *Consul) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface for *Consul.

type ConsulConfig

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

	// ConsulKVURL is the URL to the Consul KV database.
	ConsulKVURL *url.URL

	// ConsulSessionURL is the URL to the Consul session API.
	ConsulSessionURL *url.URL

	// 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

	// TTL defines, for how long to keep the information about a single client.
	TTL time.Duration
}

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

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.

Jump to

Keyboard shortcuts

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