normalized request qtype

for some reason, all untyped requests are `a`
records, even when the request family is ipv6
This commit is contained in:
W Anders
2024-05-07 20:10:15 -06:00
parent a311c333a9
commit 7a62ec248a
+19 -2
View File
@@ -57,7 +57,8 @@ func (netboxdns *NetboxDNS) ServeDNS(
) (int, error) {
state := request.Request{W: respWriter, Req: reqMsg}
qname := state.QName()
qtype := state.QType()
family := state.Family()
qtype := fixQType(state.QType(), family)
// check if plugin is configured to respond to the requested zone
respondingZone := plugin.Zones(netboxdns.zones).Matches(qname)
@@ -65,7 +66,7 @@ func (netboxdns *NetboxDNS) ServeDNS(
return netboxdns.nextOrFailure(reqContext, respWriter, reqMsg)
}
response, err := netboxdns.lookup(qname, qtype, state.Family())
response, err := netboxdns.lookup(qname, qtype, family)
if err != nil {
return dns.RcodeServerFailure, err
}
@@ -107,3 +108,19 @@ func (netboxdns *NetboxDNS) nextOrFailure(
request,
)
}
func fixQType(stateQtype uint16, family int) uint16 {
var qtype uint16
switch stateQtype {
case dns.TypeA, dns.TypeAAAA:
switch family {
case 1:
qtype = dns.TypeA
case 2:
qtype = dns.TypeAAAA
}
return qtype
default:
return stateQtype
}
}