mirror of
https://github.com/folbricht/routedns.git
synced 2025-12-20 09:00:01 -06:00
38 lines
684 B
Go
38 lines
684 B
Go
package rdns
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"fmt"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
// DoTClient is a DNS-over-TLS resolver.
|
|
type DoTClient struct {
|
|
endpoint string
|
|
pipeline *Pipeline
|
|
}
|
|
|
|
var _ Resolver = &DoTClient{}
|
|
|
|
// NewDoTClient instantiates a new DNS-over-TLS resolver.
|
|
func NewDoTClient(endpoint string) *DoTClient {
|
|
client := &dns.Client{
|
|
Net: "tcp-tls",
|
|
TLSConfig: &tls.Config{},
|
|
}
|
|
return &DoTClient{
|
|
endpoint: endpoint,
|
|
pipeline: NewPipeline(endpoint, client),
|
|
}
|
|
}
|
|
|
|
// Resolve a DNS query.
|
|
func (d *DoTClient) Resolve(q *dns.Msg) (*dns.Msg, error) {
|
|
return d.pipeline.Resolve(q)
|
|
}
|
|
|
|
func (d *DoTClient) String() string {
|
|
return fmt.Sprintf("DoT(%s)", d.endpoint)
|
|
}
|