diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 12f861fea..50dc6b62e 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -717,6 +717,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm } }() + var lastDNSConfig = new(tailcfg.DNSConfig) var lastDERPMap *tailcfg.DERPMap var lastUserProfile = map[tailcfg.UserID]tailcfg.UserProfile{} var lastParsedPacketFilter []filter.Match @@ -820,6 +821,9 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm if pf := resp.PacketFilter; pf != nil { lastParsedPacketFilter = c.parsePacketFilter(pf) } + if c := resp.DNSConfig; c != nil { + lastDNSConfig = c + } if v, ok := resp.CollectServices.Get(); ok { collectServices = v @@ -846,7 +850,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm User: resp.Node.User, UserProfiles: make(map[tailcfg.UserID]tailcfg.UserProfile), Domain: resp.Domain, - DNS: resp.DNSConfig, + DNS: *lastDNSConfig, Hostinfo: resp.Node.Hostinfo, PacketFilter: lastParsedPacketFilter, CollectServices: collectServices, diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index f1b07cb1d..52c3911f9 100644 --- a/tailcfg/tailcfg.go +++ b/tailcfg/tailcfg.go @@ -37,7 +37,8 @@ import ( // 12: 2021-03-04: client understands PingRequest // 13: 2021-03-19: client understands FilterRule.IPProto // 14: 2021-04-07: client understands DNSConfig.Routes and DNSConfig.Resolvers -const CurrentMapRequestVersion = 14 +// 15: 2021-04-12: client treats nil MapResponse.DNSConfig as meaning unchanged +const CurrentMapRequestVersion = 15 type StableID string @@ -875,11 +876,8 @@ type MapResponse struct { SearchPaths []string `json:",omitempty"` // DNSConfig contains the DNS settings for the client to use. - // - // TODO(bradfitz): make this a pointer and conditionally sent - // only if changed, like DERPMap, PacketFilter, etc. It's - // small, though. - DNSConfig DNSConfig `json:",omitempty"` + // A nil value means no change from an earlier non-nil value. + DNSConfig *DNSConfig `json:",omitempty"` // Domain is the name of the network that this node is // in. It's either of the form "example.com" (for user