From 297d1b7cb6bc634304eddf1f52d35ebcf8ec56ec Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 6 Oct 2021 15:01:48 -0700 Subject: [PATCH] net/dns/resolver: don't forward DNS-SD queries Updates #2442 Fixes tailscale/corp#2820 Signed-off-by: Brad Fitzpatrick --- net/dns/resolver/forwarder.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/dns/resolver/forwarder.go b/net/dns/resolver/forwarder.go index 2dbd2ec77..b5c118637 100644 --- a/net/dns/resolver/forwarder.go +++ b/net/dns/resolver/forwarder.go @@ -518,6 +518,21 @@ func (f *forwarder) forward(query packet) error { return err } + // Drop DNS service discovery spam, primarily for battery life + // on mobile. This is scoped to only Apple platforms, as + // that's where we see it. Things like Spotify on iOS + // generate this traffic, when browsing for LAN devices. But + // even when filtering this out, playing on Sonos still works. + // + // TODO(bradfitz): maybe after 1.16 is out, do it more broadly? + switch runtime.GOOS { + case "ios", "darwin": + if hasRDNSBonjourPrefix(domain) { + f.logf("[v1] dropping %q", domain) + return nil + } + } + clampEDNSSize(query.bs, maxResponseBytes) resolvers := f.resolvers(domain)