mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 17:53:21 -04:00 
			
		
		
		
	plugin/etcd+kubernetes: Persist truncated state to client if CNAME lookup response is truncated (#4715)
Persist the TC bit to client response for truncated CNAME lookups. Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
		| @@ -22,18 +22,19 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M | ||||
| 	state.Zone = zone | ||||
|  | ||||
| 	var ( | ||||
| 		records []dns.RR | ||||
| 		extra   []dns.RR | ||||
| 		err     error | ||||
| 		records   []dns.RR | ||||
| 		extra     []dns.RR | ||||
| 		truncated bool | ||||
| 		err       error | ||||
| 	) | ||||
|  | ||||
| 	switch state.QType() { | ||||
| 	case dns.TypeA: | ||||
| 		records, err = plugin.A(ctx, &k, zone, state, nil, plugin.Options{}) | ||||
| 		records, truncated, err = plugin.A(ctx, &k, zone, state, nil, plugin.Options{}) | ||||
| 	case dns.TypeAAAA: | ||||
| 		records, err = plugin.AAAA(ctx, &k, zone, state, nil, plugin.Options{}) | ||||
| 		records, truncated, err = plugin.AAAA(ctx, &k, zone, state, nil, plugin.Options{}) | ||||
| 	case dns.TypeTXT: | ||||
| 		records, err = plugin.TXT(ctx, &k, zone, state, nil, plugin.Options{}) | ||||
| 		records, truncated, err = plugin.TXT(ctx, &k, zone, state, nil, plugin.Options{}) | ||||
| 	case dns.TypeCNAME: | ||||
| 		records, err = plugin.CNAME(ctx, &k, zone, state, plugin.Options{}) | ||||
| 	case dns.TypePTR: | ||||
| @@ -58,7 +59,7 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M | ||||
| 		// Do a fake A lookup, so we can distinguish between NODATA and NXDOMAIN | ||||
| 		fake := state.NewWithQuestion(state.QName(), dns.TypeA) | ||||
| 		fake.Zone = state.Zone | ||||
| 		_, err = plugin.A(ctx, &k, zone, fake, nil, plugin.Options{}) | ||||
| 		_, _, err = plugin.A(ctx, &k, zone, fake, nil, plugin.Options{}) | ||||
| 	} | ||||
|  | ||||
| 	if k.IsNameError(err) { | ||||
| @@ -81,6 +82,7 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M | ||||
|  | ||||
| 	m := new(dns.Msg) | ||||
| 	m.SetReply(r) | ||||
| 	m.Truncated = truncated | ||||
| 	m.Authoritative = true | ||||
| 	m.Answer = append(m.Answer, records...) | ||||
| 	m.Extra = append(m.Extra, extra...) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user