Documentation
¶
Overview ¶
Package fanout - parallel proxying DNS messages to upstream resolvers.
Supported transport protocols:
- DNS/UDP (plain, default)
- DNS/TCP (plain)
- DoT - DNS-over-TLS (RFC 7858) — tls:// prefix or "tls" directive
- DoH - DNS-over-HTTPS (RFC 8484) — https:// prefix (HTTP/2 transport)
- DoH3 - DNS-over-HTTPS (RFC 8484) — h3:// prefix (HTTP/3 / QUIC transport, RFC 9114)
- DoQ - DNS-over-QUIC (RFC 9250) — quic:// prefix
Index ¶
Constants ¶
const ( // TCPTLS net type for a DNS-over-TLS Client (DoT, RFC 7858). TCPTLS = "tcp-tls" // TCP net type for a Client (plain DNS over TCP). TCP = "tcp" // UDP net type for a Client (plain DNS over UDP). UDP = "udp" // DOH net type for a DNS-over-HTTPS Client (DoH, RFC 8484 over HTTP/2). DOH = "dns-over-https" // DOH3 net type for a DNS-over-HTTPS Client using HTTP/3 over QUIC (DoH3, RFC 8484 + RFC 9114). DOH3 = "dns-over-https3" // DOQ net type for a DNS-over-QUIC Client (DoQ, RFC 9250). DOQ = "dns-over-quic" )
Variables ¶
var ( RequestCount = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "fanout", Name: "request_count_total", Help: "Number of request attempts started per upstream.", }, []string{"to"}) ErrorCount = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "fanout", Name: "request_error_count_total", Help: "Number of failed request attempts per upstream, grouped by bounded error class.", }, []string{"error", "to"}) RcodeCount = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "fanout", Name: "response_rcode_count_total", Help: "Number of responses per response code per upstream.", }, []string{"rcode", "to"}) RequestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Namespace: plugin.Namespace, Subsystem: "fanout", Name: "request_duration_seconds", Buckets: plugin.TimeBuckets, Help: "Histogram of the time request attempts with a valid DNS response took.", }, []string{"to"}) )
Variables declared for monitoring.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Request(context.Context, *request.Request) (*dns.Msg, error)
Endpoint() string
Net() string
SetTLSConfig(*tls.Config)
}
Client represents the proxy for remote DNS server
func NewDoH3Client ¶ added in v1.12.0
NewDoH3Client creates a new DNS-over-HTTPS client using HTTP/3 (QUIC) transport. The endpoint must be a full HTTPS URL (e.g. "https://dns.google/dns-query").
func NewDoHClient ¶ added in v1.12.0
NewDoHClient creates a new DNS-over-HTTPS client for the given endpoint URL. The endpoint must be a full URL (e.g. "https://dns.google/dns-query"). The client uses HTTP/2 with a connection-pooling transport for performance.
func NewDoQClient ¶ added in v1.12.0
NewDoQClient creates a new DNS-over-QUIC client for the given address. The address should be in host:port format (e.g. "dns.example.com:853").
type Domain ¶
type Domain interface {
Get(string) Domain
AddString(string)
Add(string, Domain)
Contains(string) bool
IsFinal() bool
Finish()
}
Domain represents DNS domain name
type Fanout ¶
type Fanout struct {
ExcludeDomains Domain
Timeout time.Duration
Race bool
RaceContinueOnErrorResponse bool
From string
// Attempts is the number of times to retry a failed upstream request.
// A value of 0 means infinite retries (bounded only by Timeout).
Attempts int
WorkerCount int
ServerSelectionPolicy policy
TapPlugin *dnstap.Dnstap
Next plugin.Handler
// contains filtered or unexported fields
}
Fanout represents a plugin instance that can do async requests to list of DNS servers.
func New ¶
func New() *Fanout
New returns reference to new Fanout plugin instance with default configs.
func (*Fanout) AddClient ¶
AddClient is used to add a new DNS server to the fanout. It also increments WorkerCount and serverCount. For bulk initialization during setup, use addClient instead.
func (*Fanout) OnShutdown ¶
OnShutdown stops all configured clients and releases their resources.
type SequentialPolicy ¶
type SequentialPolicy struct {
}
SequentialPolicy is used to select clients based on its sequential order
type Transport ¶
type Transport interface {
Dial(ctx context.Context, net string) (*dns.Conn, error)
// Yield returns a healthy connection to the pool for reuse.
// Only call this for connections that completed a successful request-response cycle.
// For failed connections, call conn.Close() instead.
Yield(conn *dns.Conn)
SetTLSConfig(*tls.Config)
// Close drains the connection pool and releases resources.
Close()
}
Transport represent a solution to connect to remote DNS endpoint with specific network
func NewTransport ¶
NewTransport creates new transport with address
type WeightedPolicy ¶
type WeightedPolicy struct {
// contains filtered or unexported fields
}
WeightedPolicy is used to select clients randomly based on its loadFactor (weights)