clients

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultClientType         = "udp"
	DefaultTimeout            = 2 // in seconds
	DefaultNdots              = 0
	DefaultIPv4               = false
	DefaultIPv6               = false
	DefaultInsecureSkipVerify = true
	DefaultUseTCPFallback     = true
	DefaultUseUDPFallback     = true
)

Default values

Variables

This section is empty.

Functions

func ConcurrentLookup

func ConcurrentLookup(ctx context.Context, dst Destination, questions []dns.Question, flags QueryFlags, queryFunc QueryFunc, logger *slog.Logger) ([]*dns.Msg, error)

ConcurrentLookup performs concurrent DNS lookups

Types

type ClassicClient

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

ClassicClient represents the config options for setting up a Client.

func (*ClassicClient) Lookup

func (c *ClassicClient) Lookup(ctx context.Context, dst Destination, questions []dns.Question, flags QueryFlags) ([]*dns.Msg, error)

Lookup implements the Client interface

type ClassicClientOpts

type ClassicClientOpts struct {
	UseTLS bool
	UseTCP bool
}

ClassicClientOpts holds options for setting up a Classic client.

type Client

type Client interface {
	Lookup(ctx context.Context, dst Destination, questions []dns.Question, flags QueryFlags) ([]*dns.Msg, error)
	// contains filtered or unexported methods
}

Client implements the configuration for a DNS Client. In contrast to doggo, a Client does not specify the endpoint

func LoadClient

func LoadClient(config *ClientConfig) (Client, error)

LoadClient loads the correct Client based on the configuration.

func NewClassicClient

func NewClassicClient(config *ClientConfig, opts ClassicClientOpts) (Client, error)

NewClassicClient accepts a list of nameservers and configures a DNS client.

func NewDNSCryptClient

func NewDNSCryptClient(config *ClientConfig, opts DNSCryptClientOpts) (Client, error)

NewDNSCryptClient accepts a list of nameservers and configures a DNS client.

func NewDOHClient

func NewDOHClient(config *ClientConfig) (Client, error)

NewDOHClient returns a DOHClient

func NewDOQClient

func NewDOQClient(config *ClientConfig) (Client, error)

NewDOQClient accepts a nameserver address and configures a DOQ based client.

type ClientConfig

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

ClientConfig represent a set of common options to configure a Client.

func NewClientConfig

func NewClientConfig(options ...Option) *ClientConfig

Returns a new ClientConfig

func (*ClientConfig) String

func (c *ClientConfig) String() string

String returns a string representation of the ClientConfig

type DNSCryptClient

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

DNSCryptClient represents the config options for setting up a Client.

func (*DNSCryptClient) Lookup

func (c *DNSCryptClient) Lookup(ctx context.Context, dst Destination, questions []dns.Question, flags QueryFlags) ([]*dns.Msg, error)

Lookup implements the Client interface

type DNSCryptClientOpts

type DNSCryptClientOpts struct {
	UseTCP bool
}

DNSCryptClientOpts holds options for setting up a DNSCrypt client.

type DOHClient

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

DOHClient represents the config options for setting up a DOH based client.

func (*DOHClient) Lookup

func (c *DOHClient) Lookup(ctx context.Context, dst Destination, questions []dns.Question, flags QueryFlags) ([]*dns.Msg, error)

Lookup implements the Client interface

type DOQClient

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

DOQClient represents the config options for setting up a DOQ based client.

func (*DOQClient) Lookup

func (c *DOQClient) Lookup(ctx context.Context, dst Destination, questions []dns.Question, flags QueryFlags) ([]*dns.Msg, error)

Lookup implements the Client interface

type Destination

type Destination struct {
	Server      string // IP address
	TLSHostname string
}

Destination specifies the endpoint

type Option

type Option func(*ClientConfig)

ClientConfig options

func WithClientType

func WithClientType(clientType string) Option

func WithDebugLogger

func WithDebugLogger() Option

WithDebugLogger creates a logger in debug mode

func WithInsecureSkipVerify

func WithInsecureSkipVerify(insecureSkipVerify bool) Option

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger specifies a logger

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithUseIPv4

func WithUseIPv4(useIPv4 bool) Option

func WithUseIPv6

func WithUseIPv6(useIPv6 bool) Option

func WithUseTCPFallback

func WithUseTCPFallback(useTCPFallback bool) Option

func WithUseUDPFallback

func WithUseUDPFallback(useUDPFallback bool) Option

type QueryFlags

type QueryFlags struct {
	AA bool // Authoritative Answer
	AD bool // Authenticated Data
	CD bool // Checking Disabled
	RD bool // Recursion Desired
	Z  bool // Reserved for future use
	DO bool // DNSSEC OK

	// EDNS0 options
	NSID    bool   // Request Name Server Identifier
	Cookie  bool   // Request DNS Cookie
	Padding bool   // Request EDNS padding for privacy
	EDE     bool   // Request Extended DNS Errors
	ECS     string // EDNS Client Subnet (e.g., "192.0.2.0/24" or "2001:db8::/32")
}

QueryFlags represents the various DNS query flags

type QueryFunc

type QueryFunc func(ctx context.Context, dst Destination, question dns.Question, flags QueryFlags) (*dns.Msg, error)

QueryFunc represents the signature of a query function

Jump to

Keyboard shortcuts

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