mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	rewrite: fix multi request concurrency issue in cname rewrite (#6407)
* fix concurrent issue with cname rewrite plugin Signed-off-by: amila <amila.15@cse.mrt.ac.lk> * add nil check before deref, add AAAA type test case Signed-off-by: amila <amila.15@cse.mrt.ac.lk> --------- Signed-off-by: amila <amila.15@cse.mrt.ac.lk>
This commit is contained in:
		| @@ -21,8 +21,15 @@ func (u *MockedUpstream) Lookup(ctx context.Context, state request.Request, name | ||||
| 	m.Authoritative = true | ||||
| 	switch state.Req.Question[0].Name { | ||||
| 	case "xyz.example.com.": | ||||
| 		m.Answer = []dns.RR{ | ||||
| 			test.A("xyz.example.com. 3600 IN A 3.4.5.6"), | ||||
| 		switch state.Req.Question[0].Qtype { | ||||
| 		case dns.TypeA: | ||||
| 			m.Answer = []dns.RR{ | ||||
| 				test.A("xyz.example.com.  3600  IN  A 3.4.5.6"), | ||||
| 			} | ||||
| 		case dns.TypeAAAA: | ||||
| 			m.Answer = []dns.RR{ | ||||
| 				test.AAAA("xyz.example.com.  3600  IN  AAAA 3a01:7e00::f03c:91ff:fe79:234c"), | ||||
| 			} | ||||
| 		} | ||||
| 		return m, nil | ||||
| 	case "bard.google.com.cdn.cloudflare.net.": | ||||
| @@ -94,6 +101,16 @@ func doTestCNameTargetTests(rules []Rule, t *testing.T) { | ||||
| 				test.A("xyz.example.com.  3600  IN  A  3.4.5.6"), | ||||
| 			}, | ||||
| 		}, | ||||
| 		{"abc.example.com", dns.TypeAAAA, | ||||
| 			[]dns.RR{ | ||||
| 				test.CNAME("abc.example.com.  5   IN  CNAME  def.example.com."), | ||||
| 				test.AAAA("def.example.com.   5  IN  AAAA   2a01:7e00::f03c:91ff:fe79:234c"), | ||||
| 			}, | ||||
| 			[]dns.RR{ | ||||
| 				test.CNAME("abc.example.com.  5   IN  CNAME  xyz.example.com."), | ||||
| 				test.AAAA("xyz.example.com.  3600  IN  AAAA  3a01:7e00::f03c:91ff:fe79:234c"), | ||||
| 			}, | ||||
| 		}, | ||||
| 		{"chat.openai.com", dns.TypeA, | ||||
| 			[]dns.RR{ | ||||
| 				test.CNAME("chat.openai.com.  20   IN  CNAME  chat.openai.com.cdn.cloudflare.net."), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user