mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 18:23:13 -04:00 
			
		
		
		
	Cache the size and the do bit whenever someone asked for it. We can probably add more: PASS BenchmarkStateDo-4 100000000 11.9 ns/op BenchmarkStateSize-4 5000000 265 ns/op ok github.com/miekg/coredns/middleware 2.828s PASS BenchmarkStateDo-4 1000000000 2.86 ns/op BenchmarkStateSize-4 500000000 3.10 ns/op ok github.com/miekg/coredns/middleware 5.032s This PR also includes some testing cleanups as well.
		
			
				
	
	
		
			29 lines
		
	
	
		
			816 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			816 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package testing
 | |
| 
 | |
| import (
 | |
| 	"net"
 | |
| 
 | |
| 	"github.com/miekg/dns"
 | |
| )
 | |
| 
 | |
| type ResponseWriter struct{}
 | |
| 
 | |
| func (t *ResponseWriter) LocalAddr() net.Addr {
 | |
| 	ip := net.ParseIP("127.0.0.1")
 | |
| 	port := 53
 | |
| 	return &net.UDPAddr{IP: ip, Port: port, Zone: ""}
 | |
| }
 | |
| 
 | |
| func (t *ResponseWriter) RemoteAddr() net.Addr {
 | |
| 	ip := net.ParseIP("10.240.0.1")
 | |
| 	port := 40212
 | |
| 	return &net.UDPAddr{IP: ip, Port: port, Zone: ""}
 | |
| }
 | |
| 
 | |
| func (t *ResponseWriter) WriteMsg(m *dns.Msg) error     { return nil }
 | |
| func (t *ResponseWriter) Write(buf []byte) (int, error) { return len(buf), nil }
 | |
| func (t *ResponseWriter) Close() error                  { return nil }
 | |
| func (t *ResponseWriter) TsigStatus() error             { return nil }
 | |
| func (t *ResponseWriter) TsigTimersOnly(bool)           { return }
 | |
| func (t *ResponseWriter) Hijack()                       { return }
 |