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
1 changed files with 6 additions and 4 deletions

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 {
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
if ttl > header.Ttl {
ttl = header.Ttl
@ -143,7 +145,7 @@ func (plugin *PluginDNS64) Eval(pluginsState *PluginsState, msg *dns.Msg) error
Ttl: ttl,
}
synthAAAA.AAAA = ipv6
synthAAAAs = append(synthAAAAs, synthAAAA)
synth64 = append(synth64, synthAAAA)
}
plugin.pref64Mutex.RUnlock()
}
@ -151,7 +153,7 @@ func (plugin *PluginDNS64) Eval(pluginsState *PluginsState, msg *dns.Msg) error
}
synth := EmptyResponseFromMessage(msg)
synth.Answer = append(synth.Answer, synthAAAAs...)
synth.Answer = append(synth.Answer, synth64...)
pluginsState.synthResponse = synth
pluginsState.action = PluginsActionSynth