prevent ipv4-mapped IPv6 address responses

This commit is contained in:
Donavan Fritz 2024-02-10 23:02:52 -08:00
parent 46eba0f367
commit 6c6d9580d9

View File

@ -96,7 +96,7 @@ func (s synthetic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
} }
// handle AAAA requests with IPv6 address // handle AAAA requests with IPv6 address
if ip.To16() != nil && state.QType() == dns.TypeAAAA { if ip.To4() == nil && state.QType() == dns.TypeAAAA {
log.Debug("Responding to AAAA request for ", state.QName()) log.Debug("Responding to AAAA request for ", state.QName())
m := new(dns.Msg) m := new(dns.Msg)
m.SetReply(r) m.SetReply(r)
@ -118,7 +118,7 @@ func (s synthetic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
} }
// handle A requests with IPv6 address (respond with empty answer and NOERROR) // handle A requests with IPv6 address (respond with empty answer and NOERROR)
if ip.To16() != nil && state.QType() == dns.TypeA { if ip.To4() == nil && state.QType() == dns.TypeA {
log.Debug("Responding to A request for ", state.QName(), " with empty answer") log.Debug("Responding to A request for ", state.QName(), " with empty answer")
m := new(dns.Msg) m := new(dns.Msg)
m.SetReply(r) m.SetReply(r)