From 7cb896ac59808e4e0b3830653ac832128d8dc207 Mon Sep 17 00:00:00 2001 From: bloved Date: Fri, 29 Jan 2021 19:47:01 +0100 Subject: [PATCH] - BUG FIX: preserving DNS RCode in Zabov responses (SetReply(query) resets it to RcodeSuccess) Some DNS client (such as MS Windows) misbehave in case of always positive responses --- dns_client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dns_client.go b/dns_client.go index 241a678..861f503 100644 --- a/dns_client.go +++ b/dns_client.go @@ -30,7 +30,9 @@ func ForwardQuery(query *dns.Msg, config string, nocache bool) *dns.Msg { if !nocache { if cached := GetDomainFromCache(lfqdn); cached != nil { go incrementStats("CacheHit", 1) + Rcode := cached.MsgHdr.Rcode cached.SetReply(query) + cached.MsgHdr.Rcode = Rcode cached.Authoritative = true if ZabovDebug { log.Println("ForwardQuery: CacheHit") @@ -65,7 +67,9 @@ func ForwardQuery(query *dns.Msg, config string, nocache bool) *dns.Msg { continue } else { go incrementStats(d, 1) + Rcode := in.MsgHdr.Rcode in.SetReply(query) + in.MsgHdr.Rcode = Rcode in.Authoritative = true in.Compress = true go DomainCache(lfqdn, in)