From d965e9030625e859f6a322c0006c113201a012e5 Mon Sep 17 00:00:00 2001 From: epipho Date: Fri, 22 May 2015 18:10:27 -0400 Subject: [PATCH] Compress all DNS responses to prevent them from going over the 512 byte limit from RFC 1035 --- command/agent/dns.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/command/agent/dns.go b/command/agent/dns.go index 9e2357dea4..66d595f311 100644 --- a/command/agent/dns.go +++ b/command/agent/dns.go @@ -180,6 +180,7 @@ func (d *DNSServer) handlePtr(resp dns.ResponseWriter, req *dns.Msg) { // Setup the message response m := new(dns.Msg) m.SetReply(req) + m.Compress = true m.Authoritative = true m.RecursionAvailable = (len(d.recursors) > 0) @@ -249,6 +250,7 @@ func (d *DNSServer) handleQuery(resp dns.ResponseWriter, req *dns.Msg) { // Setup the message response m := new(dns.Msg) m.SetReply(req) + m.Compress = true m.Authoritative = true m.RecursionAvailable = (len(d.recursors) > 0) @@ -785,6 +787,7 @@ func (d *DNSServer) handleRecurse(resp dns.ResponseWriter, req *dns.Msg) { var err error for _, recursor := range d.recursors { r, rtt, err = c.Exchange(req, recursor) + r.Compress = true if err == nil { // Forward the response d.logger.Printf("[DEBUG] dns: recurse RTT for %v (%v)", q, rtt) @@ -801,6 +804,7 @@ func (d *DNSServer) handleRecurse(resp dns.ResponseWriter, req *dns.Msg) { q, resp.RemoteAddr().String(), resp.RemoteAddr().Network()) m := &dns.Msg{} m.SetReply(req) + m.Compress = true m.RecursionAvailable = true m.SetRcode(req, dns.RcodeServerFailure) resp.WriteMsg(m)