2020-06-08 22:19:26 +00:00
|
|
|
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2020-06-09 17:09:43 +00:00
|
|
|
// Package tsdns provides a Resolver capable of resolving
|
2020-06-08 22:19:26 +00:00
|
|
|
// domains on a Tailscale network.
|
|
|
|
package tsdns
|
|
|
|
|
|
|
|
import (
|
2020-07-07 19:25:32 +00:00
|
|
|
"bytes"
|
|
|
|
"context"
|
2020-06-08 22:19:26 +00:00
|
|
|
"errors"
|
|
|
|
"sync"
|
2020-06-09 17:09:43 +00:00
|
|
|
"time"
|
2020-06-08 22:19:26 +00:00
|
|
|
|
|
|
|
dns "golang.org/x/net/dns/dnsmessage"
|
|
|
|
"inet.af/netaddr"
|
2020-07-07 19:25:32 +00:00
|
|
|
"tailscale.com/net/netns"
|
2020-06-08 22:19:26 +00:00
|
|
|
"tailscale.com/types/logger"
|
|
|
|
)
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// maxResponseSize is the maximum size of a response from a Resolver.
|
|
|
|
const maxResponseSize = 512
|
|
|
|
|
|
|
|
// queueSize is the maximal number of DNS requests that can be pending at a time.
|
|
|
|
// If EnqueueRequest is called when this many requests are already pending,
|
|
|
|
// the request will be dropped to avoid blocking the caller.
|
|
|
|
const queueSize = 8
|
|
|
|
|
|
|
|
// delegateTimeout is the maximal amount of time Resolver will wait
|
|
|
|
// for upstream nameservers to process a query.
|
|
|
|
const delegateTimeout = 5 * time.Second
|
|
|
|
|
2020-06-09 17:09:43 +00:00
|
|
|
// defaultTTL is the TTL of all responses from Resolver.
|
|
|
|
const defaultTTL = 600 * time.Second
|
2020-06-08 22:19:26 +00:00
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// ErrClosed indicates that the resolver has been closed and readers should exit.
|
|
|
|
var ErrClosed = errors.New("closed")
|
|
|
|
|
2020-06-08 22:19:26 +00:00
|
|
|
var (
|
2020-07-07 19:25:32 +00:00
|
|
|
errAllFailed = errors.New("all upstream nameservers failed")
|
|
|
|
errFullQueue = errors.New("request queue full")
|
2020-06-08 22:19:26 +00:00
|
|
|
errMapNotSet = errors.New("domain map not set")
|
|
|
|
errNotImplemented = errors.New("query type not implemented")
|
|
|
|
errNotQuery = errors.New("not a DNS query")
|
|
|
|
)
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// Map is all the data Resolver needs to resolve DNS queries within the Tailscale network.
|
2020-06-08 22:19:26 +00:00
|
|
|
type Map struct {
|
2020-06-09 17:09:43 +00:00
|
|
|
// domainToIP is a mapping of Tailscale domains to their IP addresses.
|
2020-07-07 19:25:32 +00:00
|
|
|
// For example, monitoring.tailscale.us -> 100.64.0.1.
|
2020-06-09 17:09:43 +00:00
|
|
|
domainToIP map[string]netaddr.IP
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
|
|
|
|
2020-06-09 17:09:43 +00:00
|
|
|
// NewMap returns a new Map with domain to address mapping given by domainToIP.
|
|
|
|
func NewMap(domainToIP map[string]netaddr.IP) *Map {
|
2020-07-07 19:25:32 +00:00
|
|
|
return &Map{domainToIP: domainToIP}
|
2020-06-09 17:09:43 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// Packet represents a DNS payload together with the address of its origin.
|
|
|
|
type Packet struct {
|
|
|
|
// Payload is the application layer DNS payload.
|
|
|
|
// Resolver assumes ownership of the request payload when it is enqueued
|
|
|
|
// and cedes ownership of the response payload when it is returned from NextResponse.
|
|
|
|
Payload []byte
|
|
|
|
// Addr is the source address for a request and the destination address for a response.
|
|
|
|
Addr netaddr.IPPort
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resolver is a DNS resolver for nodes on the Tailscale network,
|
|
|
|
// associating them with domain names of the form <mynode>.<mydomain>.<root>.
|
|
|
|
// If it is asked to resolve a domain that is not of that form,
|
|
|
|
// it delegates to upstream nameservers if any are set.
|
2020-06-08 22:19:26 +00:00
|
|
|
type Resolver struct {
|
|
|
|
logf logger.Logf
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// The asynchronous interface is due to the fact that resolution may potentially
|
|
|
|
// block for a long time (if the upstream nameserver is slow to reach).
|
|
|
|
|
|
|
|
// queue is a buffered channel holding DNS requests queued for resolution.
|
|
|
|
queue chan Packet
|
|
|
|
// responses is an unbuffered channel to which responses are sent.
|
|
|
|
responses chan Packet
|
|
|
|
// errors is an unbuffered channel to which errors are sent.
|
|
|
|
errors chan error
|
|
|
|
// closed notifies the poll goroutines to stop.
|
|
|
|
closed chan struct{}
|
|
|
|
// pollGroup signals when all poll goroutines have stopped.
|
|
|
|
pollGroup sync.WaitGroup
|
|
|
|
|
|
|
|
// rootDomain is <root> in <mynode>.<mydomain>.<root>.
|
|
|
|
rootDomain []byte
|
|
|
|
|
|
|
|
// dialer is the netns.Dialer used for delegation.
|
|
|
|
dialer netns.Dialer
|
2020-06-08 22:19:26 +00:00
|
|
|
|
|
|
|
// mu guards the following fields from being updated while used.
|
2020-07-07 19:25:32 +00:00
|
|
|
mu sync.RWMutex
|
2020-06-08 22:19:26 +00:00
|
|
|
// dnsMap is the map most recently received from the control server.
|
|
|
|
dnsMap *Map
|
2020-07-07 19:25:32 +00:00
|
|
|
// nameservers is the list of nameserver addresses that should be used
|
|
|
|
// if the received query is not for a Tailscale node.
|
|
|
|
// The addresses are strings of the form ip:port, as expected by Dial.
|
|
|
|
nameservers []string
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// NewResolver constructs a resolver associated with the given root domain.
|
|
|
|
func NewResolver(logf logger.Logf, rootDomain string) *Resolver {
|
2020-06-08 22:19:26 +00:00
|
|
|
r := &Resolver{
|
2020-07-07 19:25:32 +00:00
|
|
|
logf: logger.WithPrefix(logf, "tsdns: "),
|
|
|
|
queue: make(chan Packet, queueSize),
|
|
|
|
responses: make(chan Packet),
|
|
|
|
errors: make(chan error),
|
|
|
|
closed: make(chan struct{}),
|
|
|
|
// Conform to the name format dnsmessage uses (trailing period, bytes).
|
|
|
|
rootDomain: []byte(rootDomain + "."),
|
|
|
|
dialer: netns.NewDialer(),
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
func (r *Resolver) Start() {
|
|
|
|
// TODO(dmytro): spawn more than one goroutine? They block on delegation.
|
|
|
|
r.pollGroup.Add(1)
|
|
|
|
go r.poll()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close shuts down the resolver and ensures poll goroutines have exited.
|
|
|
|
// The Resolver cannot be used again after Close is called.
|
|
|
|
func (r *Resolver) Close() {
|
|
|
|
select {
|
|
|
|
case <-r.closed:
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
// continue
|
|
|
|
}
|
|
|
|
close(r.closed)
|
|
|
|
r.pollGroup.Wait()
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// SetMap sets the resolver's DNS map, taking ownership of it.
|
2020-06-08 22:19:26 +00:00
|
|
|
func (r *Resolver) SetMap(m *Map) {
|
|
|
|
r.mu.Lock()
|
|
|
|
r.dnsMap = m
|
|
|
|
r.mu.Unlock()
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// SetUpstreamNameservers sets the addresses of the resolver's
|
|
|
|
// upstream nameservers, taking ownership of the argument.
|
|
|
|
// The addresses should be strings of the form ip:port,
|
|
|
|
// matching what Dial("udp", addr) expects as addr.
|
|
|
|
func (r *Resolver) SetNameservers(nameservers []string) {
|
|
|
|
r.mu.Lock()
|
|
|
|
r.nameservers = nameservers
|
|
|
|
r.mu.Unlock()
|
|
|
|
}
|
|
|
|
|
|
|
|
// EnqueueRequest places the given DNS request in the resolver's queue.
|
|
|
|
// It takes ownership of the payload and does not block.
|
|
|
|
// If the queue is full, the request will be dropped and an error will be returned.
|
|
|
|
func (r *Resolver) EnqueueRequest(request Packet) error {
|
|
|
|
select {
|
|
|
|
case r.queue <- request:
|
|
|
|
return nil
|
|
|
|
default:
|
|
|
|
return errFullQueue
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
2020-07-07 19:25:32 +00:00
|
|
|
}
|
2020-06-08 22:19:26 +00:00
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// NextResponse returns a DNS response to a previously enqueued request.
|
|
|
|
// It blocks until a response is available and gives up ownership of the response payload.
|
|
|
|
func (r *Resolver) NextResponse() (Packet, error) {
|
|
|
|
select {
|
|
|
|
case resp := <-r.responses:
|
|
|
|
return resp, nil
|
|
|
|
case err := <-r.errors:
|
|
|
|
return Packet{}, err
|
|
|
|
case <-r.closed:
|
|
|
|
return Packet{}, ErrClosed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resolve maps a given domain name to the IP address of the host that owns it.
|
|
|
|
// The domain name must not have a trailing period.
|
|
|
|
func (r *Resolver) Resolve(domain string) (netaddr.IP, dns.RCode, error) {
|
|
|
|
r.mu.RLock()
|
2020-06-08 22:19:26 +00:00
|
|
|
if r.dnsMap == nil {
|
2020-07-07 19:25:32 +00:00
|
|
|
r.mu.RUnlock()
|
2020-06-08 22:19:26 +00:00
|
|
|
return netaddr.IP{}, dns.RCodeServerFailure, errMapNotSet
|
|
|
|
}
|
2020-06-09 17:09:43 +00:00
|
|
|
addr, found := r.dnsMap.domainToIP[domain]
|
2020-07-07 19:25:32 +00:00
|
|
|
r.mu.RUnlock()
|
2020-06-08 22:19:26 +00:00
|
|
|
|
|
|
|
if !found {
|
2020-07-07 19:25:32 +00:00
|
|
|
return netaddr.IP{}, dns.RCodeNameError, nil
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
|
|
|
return addr, dns.RCodeSuccess, nil
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
func (r *Resolver) poll() {
|
|
|
|
defer r.pollGroup.Done()
|
|
|
|
|
|
|
|
var (
|
|
|
|
packet Packet
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case packet = <-r.queue:
|
|
|
|
// continue
|
|
|
|
case <-r.closed:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
packet.Payload, err = r.respond(packet.Payload)
|
|
|
|
if err != nil {
|
|
|
|
select {
|
|
|
|
case r.errors <- err:
|
|
|
|
// continue
|
|
|
|
case <-r.closed:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
select {
|
|
|
|
case r.responses <- packet:
|
|
|
|
// continue
|
|
|
|
case <-r.closed:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// queryServer obtains a DNS response by querying the given server.
|
|
|
|
func (r *Resolver) queryServer(ctx context.Context, server string, query []byte) ([]byte, error) {
|
|
|
|
conn, err := r.dialer.DialContext(ctx, "udp", server)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer conn.Close()
|
|
|
|
|
|
|
|
// Interrupt the current operation when the context is cancelled.
|
|
|
|
go func() {
|
|
|
|
<-ctx.Done()
|
|
|
|
conn.SetDeadline(time.Unix(1, 0))
|
|
|
|
}()
|
|
|
|
|
|
|
|
_, err = conn.Write(query)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
out := make([]byte, maxResponseSize)
|
|
|
|
n, err := conn.Read(out)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return out[:n], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// delegate forwards the query to all upstream nameservers and returns the first response.
|
|
|
|
func (r *Resolver) delegate(query []byte) ([]byte, error) {
|
|
|
|
r.mu.RLock()
|
|
|
|
nameservers := r.nameservers
|
|
|
|
r.mu.RUnlock()
|
|
|
|
|
|
|
|
if len(r.nameservers) == 0 {
|
|
|
|
return nil, errAllFailed
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), delegateTimeout)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// Common case, don't spawn goroutines.
|
|
|
|
if len(nameservers) == 1 {
|
|
|
|
return r.queryServer(ctx, nameservers[0], query)
|
|
|
|
}
|
|
|
|
|
|
|
|
datach := make(chan []byte)
|
|
|
|
for _, server := range nameservers {
|
|
|
|
go func(s string) {
|
|
|
|
resp, err := r.queryServer(ctx, s, query)
|
|
|
|
// Only print errors not due to cancelation after first response.
|
|
|
|
if err != nil && ctx.Err() != context.Canceled {
|
|
|
|
r.logf("querying %s: %v", s, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
datach <- resp
|
|
|
|
}(server)
|
|
|
|
}
|
|
|
|
|
|
|
|
var response []byte
|
|
|
|
for range nameservers {
|
|
|
|
cur := <-datach
|
|
|
|
if cur != nil && response == nil {
|
|
|
|
// Received first successful response
|
|
|
|
response = cur
|
|
|
|
cancel()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if response == nil {
|
|
|
|
return nil, errAllFailed
|
|
|
|
}
|
|
|
|
return response, nil
|
|
|
|
}
|
|
|
|
|
2020-06-08 22:19:26 +00:00
|
|
|
type response struct {
|
2020-07-07 19:25:32 +00:00
|
|
|
Header dns.Header
|
|
|
|
Question dns.Question
|
|
|
|
Name string
|
|
|
|
IP netaddr.IP
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// parseQuery parses the query in given packet into a response struct.
|
2020-07-07 19:25:32 +00:00
|
|
|
func (r *Resolver) parseQuery(query []byte, resp *response) error {
|
2020-06-08 22:19:26 +00:00
|
|
|
var parser dns.Parser
|
|
|
|
var err error
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
resp.Header, err = parser.Start(query)
|
2020-06-08 22:19:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if resp.Header.Response {
|
|
|
|
return errNotQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
resp.Question, err = parser.Question()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// marshalARecord serializes an A record into an active builder.
|
2020-06-09 17:09:43 +00:00
|
|
|
// The caller may continue using the builder following the call.
|
2020-07-07 19:25:32 +00:00
|
|
|
func marshalARecord(name dns.Name, ip netaddr.IP, builder *dns.Builder) error {
|
2020-06-08 22:19:26 +00:00
|
|
|
var answer dns.AResource
|
|
|
|
|
|
|
|
answerHeader := dns.ResourceHeader{
|
2020-07-07 19:25:32 +00:00
|
|
|
Name: name,
|
2020-06-08 22:19:26 +00:00
|
|
|
Type: dns.TypeA,
|
|
|
|
Class: dns.ClassINET,
|
2020-06-09 17:09:43 +00:00
|
|
|
TTL: uint32(defaultTTL / time.Second),
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
2020-07-07 19:25:32 +00:00
|
|
|
ipbytes := ip.As4()
|
|
|
|
copy(answer.A[:], ipbytes[:])
|
2020-06-08 22:19:26 +00:00
|
|
|
return builder.AResource(answerHeader, answer)
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// marshalAAAARecord serializes an AAAA record into an active builder.
|
2020-06-09 17:09:43 +00:00
|
|
|
// The caller may continue using the builder following the call.
|
2020-07-07 19:25:32 +00:00
|
|
|
func marshalAAAARecord(name dns.Name, ip netaddr.IP, builder *dns.Builder) error {
|
|
|
|
var answer dns.AAAAResource
|
2020-06-08 22:19:26 +00:00
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
answerHeader := dns.ResourceHeader{
|
|
|
|
Name: name,
|
|
|
|
Type: dns.TypeAAAA,
|
|
|
|
Class: dns.ClassINET,
|
|
|
|
TTL: uint32(defaultTTL / time.Second),
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
2020-07-07 19:25:32 +00:00
|
|
|
ipbytes := ip.As16()
|
|
|
|
copy(answer.AAAA[:], ipbytes[:])
|
|
|
|
return builder.AAAAResource(answerHeader, answer)
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// marshalResponse serializes the DNS response into a new buffer.
|
|
|
|
func marshalResponse(resp *response) ([]byte, error) {
|
2020-06-09 17:09:43 +00:00
|
|
|
resp.Header.Response = true
|
|
|
|
resp.Header.Authoritative = true
|
|
|
|
if resp.Header.RecursionDesired {
|
|
|
|
resp.Header.RecursionAvailable = true
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
builder := dns.NewBuilder(nil, resp.Header)
|
2020-06-08 22:19:26 +00:00
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
err := builder.StartQuestions()
|
2020-06-09 17:09:43 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
err = builder.Question(resp.Question)
|
2020-06-08 22:19:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// Only successful responses contain answers.
|
|
|
|
if resp.Header.RCode != dns.RCodeSuccess {
|
|
|
|
return builder.Finish()
|
|
|
|
}
|
|
|
|
|
|
|
|
err = builder.StartAnswers()
|
2020-06-08 22:19:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
if resp.IP.Is4() {
|
|
|
|
err = marshalARecord(resp.Question.Name, resp.IP, &builder)
|
|
|
|
} else {
|
|
|
|
err = marshalAAAARecord(resp.Question.Name, resp.IP, &builder)
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
2020-07-07 19:25:32 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
return builder.Finish()
|
|
|
|
}
|
|
|
|
|
|
|
|
// respond returns a DNS response to query.
|
|
|
|
func (r *Resolver) respond(query []byte) ([]byte, error) {
|
|
|
|
resp := new(response)
|
|
|
|
|
|
|
|
// ParseQuery is sufficiently fast to run on every DNS packet.
|
|
|
|
// This is considerably simpler than extracting the name by hand
|
|
|
|
// to shave off microseconds in case of delegation.
|
|
|
|
err := r.parseQuery(query, resp)
|
2020-06-08 22:19:26 +00:00
|
|
|
// We will not return this error: it is the sender's fault.
|
|
|
|
if err != nil {
|
2020-07-07 19:25:32 +00:00
|
|
|
r.logf("parsing query: %v", err)
|
2020-06-08 22:19:26 +00:00
|
|
|
resp.Header.RCode = dns.RCodeFormatError
|
2020-07-07 19:25:32 +00:00
|
|
|
return marshalResponse(resp)
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
// Delegate only when not a subdomain of rootDomain.
|
|
|
|
// We do this on bytes because Name.String() allocates.
|
|
|
|
rawName := resp.Question.Name.Data[:resp.Question.Name.Length]
|
|
|
|
if !bytes.HasSuffix(rawName, r.rootDomain) {
|
|
|
|
out, err := r.delegate(query)
|
|
|
|
if err != nil {
|
|
|
|
r.logf("delegating: %v", err)
|
|
|
|
resp.Header.RCode = dns.RCodeServerFailure
|
|
|
|
return marshalResponse(resp)
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
switch resp.Question.Type {
|
|
|
|
case dns.TypeA, dns.TypeAAAA:
|
|
|
|
domain := resp.Question.Name.String()
|
|
|
|
// Strip off the trailing period.
|
|
|
|
// This is safe: Name is guaranteed to have a trailing period by construction.
|
|
|
|
domain = domain[:len(domain)-1]
|
|
|
|
resp.IP, resp.Header.RCode, err = r.Resolve(domain)
|
|
|
|
default:
|
|
|
|
resp.Header.RCode = dns.RCodeNotImplemented
|
|
|
|
err = errNotImplemented
|
|
|
|
}
|
2020-06-08 22:19:26 +00:00
|
|
|
// We will not return this error: it is the sender's fault.
|
|
|
|
if err != nil {
|
2020-07-07 19:25:32 +00:00
|
|
|
r.logf("resolving: %v", err)
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 19:25:32 +00:00
|
|
|
return marshalResponse(resp)
|
2020-06-08 22:19:26 +00:00
|
|
|
}
|