mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 17:53:21 -04:00 
			
		
		
		
	This fix tries to fix 261 where proxy upstream parser is not able to parse upstream correctly. Several test cases have also been added to cover the changes and prevent regression in the future. This fix fixes 261. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
		
			
				
	
	
		
			28 lines
		
	
	
		
			570 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			570 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package proxy
 | |
| 
 | |
| import (
 | |
| 	"github.com/miekg/coredns/core/dnsserver"
 | |
| 	"github.com/miekg/coredns/middleware"
 | |
| 
 | |
| 	"github.com/mholt/caddy"
 | |
| )
 | |
| 
 | |
| func init() {
 | |
| 	caddy.RegisterPlugin("proxy", caddy.Plugin{
 | |
| 		ServerType: "dns",
 | |
| 		Action:     setup,
 | |
| 	})
 | |
| }
 | |
| 
 | |
| func setup(c *caddy.Controller) error {
 | |
| 	upstreams, err := NewStaticUpstreams(&c.Dispenser)
 | |
| 	if err != nil {
 | |
| 		return middleware.Error("proxy", err)
 | |
| 	}
 | |
| 	dnsserver.GetConfig(c).AddMiddleware(func(next dnsserver.Handler) dnsserver.Handler {
 | |
| 		return Proxy{Next: next, Client: Clients(), Upstreams: upstreams}
 | |
| 	})
 | |
| 
 | |
| 	return nil
 | |
| }
 |