From f69e4e0d71cf7d9711b3dc9e85ce2135f7c1af03 Mon Sep 17 00:00:00 2001 From: David Fifield Date: Thu, 16 Apr 2020 21:04:19 -0600 Subject: [PATCH] Truncation and TC bit in responses. --- dnstt-server/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dnstt-server/main.go b/dnstt-server/main.go index d10f4bb..451e6c4 100644 --- a/dnstt-server/main.go +++ b/dnstt-server/main.go @@ -472,6 +472,12 @@ func sendLoop(dnsConn net.PacketConn, ttConn *turbotunnel.QueuePacketConn, ch <- log.Printf("resp WireFormat: %v", err) continue } + // Truncate if necessary. + // https://tools.ietf.org/html/rfc1035#section-4.1.1 + if len(buf) > maxUDPPayload { + buf = buf[:maxUDPPayload] + buf[2] |= 0x02 // TC = 1 + } _, err = dnsConn.WriteTo(buf, rec.Addr) if err != nil { if err, ok := err.(net.Error); ok && err.Temporary() {