mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
Move wgengine/tsdns to net/dns.
Straight move+fixup, no other changes. In prep for merging with wgengine/router/dns. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
81143b6d9a
commit
8432999835
@ -22,6 +22,7 @@
|
||||
"tailscale.com/ipn"
|
||||
"tailscale.com/ipn/ipnstate"
|
||||
"tailscale.com/ipn/policy"
|
||||
"tailscale.com/net/dns"
|
||||
"tailscale.com/net/interfaces"
|
||||
"tailscale.com/net/tsaddr"
|
||||
"tailscale.com/portlist"
|
||||
@ -37,8 +38,7 @@
|
||||
"tailscale.com/wgengine"
|
||||
"tailscale.com/wgengine/filter"
|
||||
"tailscale.com/wgengine/router"
|
||||
"tailscale.com/wgengine/router/dns"
|
||||
"tailscale.com/wgengine/tsdns"
|
||||
rdns "tailscale.com/wgengine/router/dns"
|
||||
"tailscale.com/wgengine/wgcfg"
|
||||
"tailscale.com/wgengine/wgcfg/nmcfg"
|
||||
)
|
||||
@ -847,8 +847,8 @@ func (b *LocalBackend) updateDNSMap(netMap *netmap.NetworkMap) {
|
||||
}
|
||||
set(netMap.Name, netMap.Addresses)
|
||||
|
||||
dnsMap := tsdns.NewMap(nameToIP, magicDNSRootDomains(netMap))
|
||||
// map diff will be logged in tsdns.Resolver.SetMap.
|
||||
dnsMap := dns.NewMap(nameToIP, magicDNSRootDomains(netMap))
|
||||
// map diff will be logged in dns.Resolver.SetMap.
|
||||
b.e.SetDNSMap(dnsMap)
|
||||
}
|
||||
|
||||
@ -1420,7 +1420,7 @@ func (b *LocalBackend) authReconfig() {
|
||||
b.logf("[unexpected] dns proxied but no nameservers")
|
||||
proxied = false
|
||||
}
|
||||
rcfg.DNS = dns.Config{
|
||||
rcfg.DNS = rdns.Config{
|
||||
Nameservers: nm.DNS.Nameservers,
|
||||
Domains: nm.DNS.Domains,
|
||||
PerDomain: nm.DNS.PerDomain,
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tsdns
|
||||
package dns
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -316,7 +316,7 @@ func (c *fwdConn) send(packet []byte, dst net.Addr) {
|
||||
var b *backoff.Backoff // lazily initialized, since it is not needed in the common case
|
||||
backOff := func(err error) {
|
||||
if b == nil {
|
||||
b = backoff.NewBackoff("tsdns-fwdConn-send", c.logf, 30*time.Second)
|
||||
b = backoff.NewBackoff("dns-fwdConn-send", c.logf, 30*time.Second)
|
||||
}
|
||||
b.BackOff(context.Background(), err)
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tsdns
|
||||
package dns
|
||||
|
||||
import (
|
||||
"sort"
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tsdns
|
||||
package dns
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tsdns
|
||||
package dns
|
||||
|
||||
import (
|
||||
"errors"
|
@ -4,7 +4,7 @@
|
||||
|
||||
// +build !darwin,!windows
|
||||
|
||||
package tsdns
|
||||
package dns
|
||||
|
||||
func networkIsDown(err error) bool { return false }
|
||||
func networkIsUnreachable(err error) bool { return false }
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tsdns
|
||||
package dns
|
||||
|
||||
import (
|
||||
"net"
|
@ -2,9 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package tsdns provides a Resolver capable of resolving
|
||||
// Package dns provides a Resolver capable of resolving
|
||||
// domains on a Tailscale network.
|
||||
package tsdns
|
||||
package dns
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
@ -100,7 +100,7 @@ type ResolverConfig struct {
|
||||
// The root domain must be in canonical form (with a trailing period).
|
||||
func NewResolver(config ResolverConfig) *Resolver {
|
||||
r := &Resolver{
|
||||
logf: logger.WithPrefix(config.Logf, "tsdns: "),
|
||||
logf: logger.WithPrefix(config.Logf, "dns: "),
|
||||
linkMon: config.LinkMonitor,
|
||||
queue: make(chan Packet, queueSize),
|
||||
responses: make(chan Packet),
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tsdns
|
||||
package dns
|
||||
|
||||
import (
|
||||
"log"
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package tsdns
|
||||
package dns
|
||||
|
||||
import (
|
||||
"bytes"
|
@ -730,7 +730,7 @@ type DNSConfig struct {
|
||||
// Some OSes and OS configurations don't support per-domain DNS configuration,
|
||||
// in which case Nameservers applies to all DNS requests regardless of PerDomain's value.
|
||||
PerDomain bool
|
||||
// Proxied indicates whether DNS requests are proxied through a tsdns.Resolver.
|
||||
// Proxied indicates whether DNS requests are proxied through a dns.Resolver.
|
||||
// This enables MagicDNS. It is togglable independently of PerDomain.
|
||||
Proxied bool
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ type Config struct {
|
||||
// Note that Nameservers may still be applied to all queries
|
||||
// if the manager does not support per-domain settings.
|
||||
PerDomain bool
|
||||
// Proxied indicates whether DNS requests are proxied through a tsdns.Resolver.
|
||||
// Proxied indicates whether DNS requests are proxied through a dns.Resolver.
|
||||
// This enables MagicDNS.
|
||||
Proxied bool
|
||||
}
|
||||
|
@ -47,7 +47,7 @@
|
||||
"tailscale.com/wgengine/magicsock"
|
||||
"tailscale.com/wgengine/monitor"
|
||||
"tailscale.com/wgengine/router"
|
||||
"tailscale.com/wgengine/tsdns"
|
||||
"tailscale.com/net/dns"
|
||||
"tailscale.com/wgengine/tstun"
|
||||
"tailscale.com/wgengine/wgcfg"
|
||||
"tailscale.com/wgengine/wglog"
|
||||
@ -95,7 +95,7 @@ type userspaceEngine struct {
|
||||
tundev *tstun.TUN
|
||||
wgdev *device.Device
|
||||
router router.Router
|
||||
resolver *tsdns.Resolver
|
||||
resolver *dns.Resolver
|
||||
magicConn *magicsock.Conn
|
||||
linkMon *monitor.Mon
|
||||
linkMonOwned bool // whether we created linkMon (and thus need to close it)
|
||||
@ -246,7 +246,7 @@ func newUserspaceEngine(logf logger.Logf, rawTUNDev tun.Device, conf Config) (_
|
||||
e.linkMonOwned = true
|
||||
}
|
||||
|
||||
e.resolver = tsdns.NewResolver(tsdns.ResolverConfig{
|
||||
e.resolver = dns.NewResolver(dns.ResolverConfig{
|
||||
Logf: logf,
|
||||
Forward: true,
|
||||
LinkMonitor: e.linkMon,
|
||||
@ -476,13 +476,13 @@ func (e *userspaceEngine) isLocalAddr(ip netaddr.IP) bool {
|
||||
// handleDNS is an outbound pre-filter resolving Tailscale domains.
|
||||
func (e *userspaceEngine) handleDNS(p *packet.Parsed, t *tstun.TUN) filter.Response {
|
||||
if p.Dst.IP == magicDNSIP && p.Dst.Port == magicDNSPort && p.IPProto == ipproto.UDP {
|
||||
request := tsdns.Packet{
|
||||
request := dns.Packet{
|
||||
Payload: append([]byte(nil), p.Payload()...),
|
||||
Addr: netaddr.IPPort{IP: p.Src.IP, Port: p.Src.Port},
|
||||
}
|
||||
err := e.resolver.EnqueueRequest(request)
|
||||
if err != nil {
|
||||
e.logf("tsdns: enqueue: %v", err)
|
||||
e.logf("dns: enqueue: %v", err)
|
||||
}
|
||||
return filter.Drop
|
||||
}
|
||||
@ -493,11 +493,11 @@ func (e *userspaceEngine) handleDNS(p *packet.Parsed, t *tstun.TUN) filter.Respo
|
||||
func (e *userspaceEngine) pollResolver() {
|
||||
for {
|
||||
resp, err := e.resolver.NextResponse()
|
||||
if err == tsdns.ErrClosed {
|
||||
if err == dns.ErrClosed {
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
e.logf("tsdns: error: %v", err)
|
||||
e.logf("dns: error: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -511,7 +511,7 @@ func (e *userspaceEngine) pollResolver() {
|
||||
}
|
||||
hlen := h.Len()
|
||||
|
||||
// TODO(dmytro): avoid this allocation without importing tstun quirks into tsdns.
|
||||
// TODO(dmytro): avoid this allocation without importing tstun quirks into dns.
|
||||
const offset = tstun.PacketStartOffset
|
||||
buf := make([]byte, offset+hlen+len(resp.Payload))
|
||||
copy(buf[offset+hlen:], resp.Payload)
|
||||
@ -1047,7 +1047,7 @@ func (e *userspaceEngine) SetFilter(filt *filter.Filter) {
|
||||
e.tundev.SetFilter(filt)
|
||||
}
|
||||
|
||||
func (e *userspaceEngine) SetDNSMap(dm *tsdns.Map) {
|
||||
func (e *userspaceEngine) SetDNSMap(dm *dns.Map) {
|
||||
e.resolver.SetMap(dm)
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
"tailscale.com/wgengine/filter"
|
||||
"tailscale.com/wgengine/monitor"
|
||||
"tailscale.com/wgengine/router"
|
||||
"tailscale.com/wgengine/tsdns"
|
||||
"tailscale.com/net/dns"
|
||||
"tailscale.com/wgengine/wgcfg"
|
||||
)
|
||||
|
||||
@ -84,7 +84,7 @@ func (e *watchdogEngine) GetFilter() *filter.Filter {
|
||||
func (e *watchdogEngine) SetFilter(filt *filter.Filter) {
|
||||
e.watchdog("SetFilter", func() { e.wrap.SetFilter(filt) })
|
||||
}
|
||||
func (e *watchdogEngine) SetDNSMap(dm *tsdns.Map) {
|
||||
func (e *watchdogEngine) SetDNSMap(dm *dns.Map) {
|
||||
e.watchdog("SetDNSMap", func() { e.wrap.SetDNSMap(dm) })
|
||||
}
|
||||
func (e *watchdogEngine) SetStatusCallback(cb StatusCallback) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
"tailscale.com/wgengine/filter"
|
||||
"tailscale.com/wgengine/monitor"
|
||||
"tailscale.com/wgengine/router"
|
||||
"tailscale.com/wgengine/tsdns"
|
||||
"tailscale.com/net/dns"
|
||||
"tailscale.com/wgengine/wgcfg"
|
||||
)
|
||||
|
||||
@ -66,7 +66,7 @@ type Engine interface {
|
||||
SetFilter(*filter.Filter)
|
||||
|
||||
// SetDNSMap updates the DNS map.
|
||||
SetDNSMap(*tsdns.Map)
|
||||
SetDNSMap(*dns.Map)
|
||||
|
||||
// SetStatusCallback sets the function to call when the
|
||||
// WireGuard status changes.
|
||||
|
Loading…
Reference in New Issue
Block a user