From 9cd06d86cf22f608bc39b460c302be54802874ff Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Sun, 28 Feb 2021 22:46:29 +0100 Subject: [PATCH] strip additional records before truncating the message --- proxy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/proxy.py b/proxy.py index 60e23b8..5c16ab4 100644 --- a/proxy.py +++ b/proxy.py @@ -141,8 +141,10 @@ class DynamicResolver(object): class TruncatingDNSDatagramProtocol(dns.DNSDatagramProtocol): def writeMessage(self, message, address): if type(message) is dns.Message and len(message.toStr()) > 512: - message.trunc = 1 - message.answers = message.additional = [] + message.additional = [] + if len(message.toStr()) > 512: + message.trunc = 1 + message.answers = [] dns.DNSDatagramProtocol.writeMessage(self, message, address) def main():