From 4a4b1bdb83f206474ebd7e952705c4731aea9fc0 Mon Sep 17 00:00:00 2001 From: yaling888 <73897884+yaling888@users.noreply.github.com> Date: Fri, 25 Mar 2022 04:09:11 +0800 Subject: [PATCH] Chore: adjust tun RelayDnsPacket --- listener/tun/ipstack/commons/dns.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/listener/tun/ipstack/commons/dns.go b/listener/tun/ipstack/commons/dns.go index 412dc5b7..667c2642 100644 --- a/listener/tun/ipstack/commons/dns.go +++ b/listener/tun/ipstack/commons/dns.go @@ -28,15 +28,9 @@ func RelayDnsPacket(payload []byte) ([]byte, error) { r, err := resolver.ServeMsg(msg) if err != nil { - return nil, err - } - - for _, ans := range r.Answer { - header := ans.Header() - - if header.Class == D.ClassINET && (header.Rrtype == D.TypeA || header.Rrtype == D.TypeAAAA) { - header.Ttl = 1 - } + m := new(D.Msg) + m.SetRcode(msg, D.RcodeServerFailure) + return m.Pack() } r.SetRcode(msg, r.Rcode)