1
0
mirror of https://github.com/DNSCrypt/dnscrypt-proxy.git synced 2024-12-11 22:35:40 +01:00

dns64: preserve cnames in translated response (#2129)

* dns64: preserve cnames in translated response

* dns64: rename synthAAAAs to synth64
This commit is contained in:
ignoramous 2022-06-16 04:23:50 +05:30 committed by GitHub
parent 72a602577a
commit 7177a0ec74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,10 +121,12 @@ func (plugin *PluginDNS64) Eval(pluginsState *PluginsState, msg *dns.Msg) error
} }
} }
synthAAAAs := make([]dns.RR, 0) synth64 := make([]dns.RR, 0)
for _, answer := range resp.Answer { for _, answer := range resp.Answer {
header := answer.Header() header := answer.Header()
if header.Rrtype == dns.TypeA { if header.Rrtype == dns.TypeCNAME {
synth64 = append(synth64, answer)
} else if header.Rrtype == dns.TypeA {
ttl := initialTTL ttl := initialTTL
if ttl > header.Ttl { if ttl > header.Ttl {
ttl = header.Ttl ttl = header.Ttl
@ -143,7 +145,7 @@ func (plugin *PluginDNS64) Eval(pluginsState *PluginsState, msg *dns.Msg) error
Ttl: ttl, Ttl: ttl,
} }
synthAAAA.AAAA = ipv6 synthAAAA.AAAA = ipv6
synthAAAAs = append(synthAAAAs, synthAAAA) synth64 = append(synth64, synthAAAA)
} }
plugin.pref64Mutex.RUnlock() plugin.pref64Mutex.RUnlock()
} }
@ -151,7 +153,7 @@ func (plugin *PluginDNS64) Eval(pluginsState *PluginsState, msg *dns.Msg) error
} }
synth := EmptyResponseFromMessage(msg) synth := EmptyResponseFromMessage(msg)
synth.Answer = append(synth.Answer, synthAAAAs...) synth.Answer = append(synth.Answer, synth64...)
pluginsState.synthResponse = synth pluginsState.synthResponse = synth
pluginsState.action = PluginsActionSynth pluginsState.action = PluginsActionSynth