mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-29 01:04:15 -04:00 
			
		
		
		
	* Rename middleware to plugin first pass; mostly used 'sed', few spots where I manually changed text. This still builds a coredns binary. * fmt error * Rename AddMiddleware to AddPlugin * Readd AddMiddleware to remain backwards compat
		
			
				
	
	
		
			38 lines
		
	
	
		
			751 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			751 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package tls
 | |
| 
 | |
| import (
 | |
| 	"github.com/coredns/coredns/core/dnsserver"
 | |
| 	"github.com/coredns/coredns/plugin"
 | |
| 	"github.com/coredns/coredns/plugin/pkg/tls"
 | |
| 
 | |
| 	"github.com/mholt/caddy"
 | |
| )
 | |
| 
 | |
| func init() {
 | |
| 	caddy.RegisterPlugin("tls", caddy.Plugin{
 | |
| 		ServerType: "dns",
 | |
| 		Action:     setup,
 | |
| 	})
 | |
| }
 | |
| 
 | |
| func setup(c *caddy.Controller) error {
 | |
| 	config := dnsserver.GetConfig(c)
 | |
| 
 | |
| 	if config.TLSConfig != nil {
 | |
| 		return plugin.Error("tls", c.Errf("TLS already configured for this server instance"))
 | |
| 	}
 | |
| 
 | |
| 	for c.Next() {
 | |
| 		args := c.RemainingArgs()
 | |
| 		if len(args) != 3 {
 | |
| 			return plugin.Error("tls", c.ArgErr())
 | |
| 		}
 | |
| 		tls, err := tls.NewTLSConfig(args[0], args[1], args[2])
 | |
| 		if err != nil {
 | |
| 			return plugin.Error("tls", err)
 | |
| 		}
 | |
| 		config.TLSConfig = tls
 | |
| 	}
 | |
| 	return nil
 | |
| }
 |