summaryrefslogtreecommitdiffhomepage
path: root/control/controlclient/direct.go
diff options
context:
space:
mode:
Diffstat (limited to 'control/controlclient/direct.go')
-rw-r--r--control/controlclient/direct.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go
index a541f00bd..e5d69e373 100644
--- a/control/controlclient/direct.go
+++ b/control/controlclient/direct.go
@@ -30,6 +30,7 @@ import (
"github.com/tailscale/wireguard-go/wgcfg"
"golang.org/x/crypto/nacl/box"
"golang.org/x/oauth2"
+ "inet.af/netaddr"
"tailscale.com/log/logheap"
"tailscale.com/net/netns"
"tailscale.com/net/tlsdial"
@@ -638,8 +639,7 @@ func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*NetworkM
UserProfiles: make(map[tailcfg.UserID]tailcfg.UserProfile),
Domain: resp.Domain,
Roles: resp.Roles,
- DNS: resp.DNS,
- DNSDomains: resp.SearchPaths,
+ DNS: resp.DNSConfig,
Hostinfo: resp.Node.Hostinfo,
PacketFilter: c.parsePacketFilter(resp.PacketFilter),
DERPMap: lastDERPMap,
@@ -653,6 +653,15 @@ func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*NetworkM
} else {
nm.MachineStatus = tailcfg.MachineUnauthorized
}
+ if len(resp.DNS) > 0 {
+ nm.DNS.Nameservers = wgIPToNetaddr(resp.DNS)
+ }
+ if len(resp.SearchPaths) > 0 {
+ nm.DNS.Domains = resp.SearchPaths
+ }
+ if Debug.ProxyDNS {
+ nm.DNS.Proxied = true
+ }
// Printing the netmap can be extremely verbose, but is very
// handy for debugging. Let's limit how often we do it.
@@ -792,12 +801,24 @@ func loadServerKey(ctx context.Context, httpc *http.Client, serverURL string) (w
return key, nil
}
+func wgIPToNetaddr(ips []wgcfg.IP) (ret []netaddr.IP) {
+ for _, ip := range ips {
+ nip, ok := netaddr.FromStdIP(ip.IP())
+ if !ok {
+ panic(fmt.Sprintf("conversion of %s from wgcfg to netaddr IP failed", ip))
+ }
+ ret = append(ret, nip.Unmap())
+ }
+ return ret
+}
+
// Debug contains temporary internal-only debug knobs.
// They're unexported to not draw attention to them.
var Debug = initDebug()
type debug struct {
NetMap bool
+ ProxyDNS bool
OnlyDisco bool
Disco bool
ForceDisco bool // ask control server to not filter out our disco key
@@ -806,6 +827,7 @@ type debug struct {
func initDebug() debug {
d := debug{
NetMap: envBool("TS_DEBUG_NETMAP"),
+ ProxyDNS: envBool("TS_DEBUG_PROXY_DNS"),
OnlyDisco: os.Getenv("TS_DEBUG_USE_DISCO") == "only",
ForceDisco: os.Getenv("TS_DEBUG_USE_DISCO") == "only" || envBool("TS_DEBUG_USE_DISCO"),
}