plugin/kubernetes: error NXDOMAIN for TXT lookups (#5737)
plugin/kubernetes: fix NXDOMAIN/NOERROR responses for TXT queries Signed-off-by: Laurence Robinson <laurence_robinson@live.co.uk> Co-authored-by: Laurence Robinson <laurence.robinson@deshaw.com>
This commit is contained in:
parent
7813b6e090
commit
c3228615e0
2 changed files with 30 additions and 6 deletions
|
@ -100,15 +100,23 @@ func (k *Kubernetes) Services(ctx context.Context, state request.Request, exact
|
|||
// 1 label + zone, label must be "dns-version".
|
||||
t, _ := dnsutil.TrimZone(state.Name(), state.Zone)
|
||||
|
||||
// Hard code the only valid TXT - "dns-version.<zone>"
|
||||
segs := dns.SplitDomainName(t)
|
||||
if len(segs) != 1 {
|
||||
if len(segs) == 1 && segs[0] == "dns-version" {
|
||||
svc := msg.Service{Text: DNSSchemaVersion, TTL: 28800, Key: msg.Path(state.QName(), coredns)}
|
||||
return []msg.Service{svc}, nil
|
||||
}
|
||||
|
||||
// Check if we have an existing record for this query of another type
|
||||
services, _ := k.Records(ctx, state, false)
|
||||
|
||||
if len(services) > 0 {
|
||||
// If so we return an empty NOERROR
|
||||
return nil, nil
|
||||
}
|
||||
if segs[0] != "dns-version" {
|
||||
return nil, nil
|
||||
}
|
||||
svc := msg.Service{Text: DNSSchemaVersion, TTL: 28800, Key: msg.Path(state.QName(), coredns)}
|
||||
return []msg.Service{svc}, nil
|
||||
|
||||
// Return NXDOMAIN for no match
|
||||
return nil, errNoItems
|
||||
|
||||
case dns.TypeNS:
|
||||
// We can only get here if the qname equals the zone, see ServeDNS in handler.go.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue