From 7d0490410961010edc9fb056c719f579e06b0cfd Mon Sep 17 00:00:00 2001 From: Skyxim Date: Fri, 10 Jun 2022 14:29:19 +0800 Subject: [PATCH] fix: leak dns when domain in hosts list --- dns/middleware.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dns/middleware.go b/dns/middleware.go index 415bcd1b..0bfc4977 100644 --- a/dns/middleware.go +++ b/dns/middleware.go @@ -46,11 +46,11 @@ func withHosts(hosts *trie.DomainTrie[netip.Addr], mapping *cache.LruCache[netip rr.A = ip.AsSlice() msg.Answer = []D.RR{rr} - } else if ip.Is6() && q.Qtype == D.TypeAAAA { + } else if q.Qtype == D.TypeAAAA { rr := &D.AAAA{} rr.Hdr = D.RR_Header{Name: q.Name, Rrtype: D.TypeAAAA, Class: D.ClassINET, Ttl: 10} - rr.AAAA = ip.AsSlice() - + ip := ip.As16() + rr.AAAA = ip[:] msg.Answer = []D.RR{rr} } else { return next(ctx, r)