mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 18:53:13 -05:00 
			
		
		
		
	* Fix linter errors * More linting fixes * More docs and making members private that dont need to be public * Fix linter errors * More linting fixes * More docs and making members private that dont need to be public * More lint fixes This leaves: ~~~ middleware/kubernetes/nametemplate/nametemplate.go:64:6: exported type NameTemplate should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:71:1: exported method NameTemplate.SetTemplate should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:108:1: exported method NameTemplate.GetZoneFromSegmentArray should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:116:1: exported method NameTemplate.GetNamespaceFromSegmentArray should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:120:1: exported method NameTemplate.GetServiceFromSegmentArray should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:124:1: exported method NameTemplate.GetTypeFromSegmentArray should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:135:1: exported method NameTemplate.GetSymbolFromSegmentArray should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:167:1: exported method NameTemplate.IsValid should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:182:6: exported type NameValues should have comment or be unexported middleware/kubernetes/util/util.go:1:1: package comment should be of the form "Package util ..." middleware/kubernetes/util/util.go:27:2: exported const WildcardStar should have comment (or a comment on this block) or be unexported middleware/proxy/lookup.go:66:1: exported method Proxy.Forward should have comment or be unexported middleware/proxy/proxy.go:24:6: exported type Client should have comment or be unexported middleware/proxy/proxy.go:107:1: exported function Clients should have comment or be unexported middleware/proxy/reverseproxy.go:10:6: exported type ReverseProxy should have comment or be unexported middleware/proxy/reverseproxy.go:16:1: exported method ReverseProxy.ServeDNS should have comment or be unexported middleware/proxy/upstream.go:42:6: exported type Options should have comment or be unexported ~~~ I plan on reworking the proxy anyway, so I'll leave that be.
		
			
				
	
	
		
			92 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package dnssec
 | 
						|
 | 
						|
import (
 | 
						|
	"strings"
 | 
						|
 | 
						|
	"github.com/miekg/coredns/core/dnsserver"
 | 
						|
	"github.com/miekg/coredns/middleware"
 | 
						|
 | 
						|
	"github.com/mholt/caddy"
 | 
						|
)
 | 
						|
 | 
						|
func init() {
 | 
						|
	caddy.RegisterPlugin("dnssec", caddy.Plugin{
 | 
						|
		ServerType: "dns",
 | 
						|
		Action:     setup,
 | 
						|
	})
 | 
						|
}
 | 
						|
 | 
						|
func setup(c *caddy.Controller) error {
 | 
						|
	zones, keys, err := dnssecParse(c)
 | 
						|
	if err != nil {
 | 
						|
		return middleware.Error("dnssec", err)
 | 
						|
	}
 | 
						|
 | 
						|
	dnsserver.GetConfig(c).AddMiddleware(func(next middleware.Handler) middleware.Handler {
 | 
						|
		return New(zones, keys, next)
 | 
						|
	})
 | 
						|
 | 
						|
	return nil
 | 
						|
}
 | 
						|
 | 
						|
func dnssecParse(c *caddy.Controller) ([]string, []*DNSKEY, error) {
 | 
						|
	zones := []string{}
 | 
						|
 | 
						|
	keys := []*DNSKEY{}
 | 
						|
	for c.Next() {
 | 
						|
		if c.Val() == "dnssec" {
 | 
						|
			// dnssec [zones...]
 | 
						|
			zones = make([]string, len(c.ServerBlockKeys))
 | 
						|
			copy(zones, c.ServerBlockKeys)
 | 
						|
			args := c.RemainingArgs()
 | 
						|
			if len(args) > 0 {
 | 
						|
				zones = args
 | 
						|
			}
 | 
						|
 | 
						|
			for c.NextBlock() {
 | 
						|
				k, e := keyParse(c)
 | 
						|
				if e != nil {
 | 
						|
					return nil, nil, e
 | 
						|
				}
 | 
						|
				keys = append(keys, k...)
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
	for i := range zones {
 | 
						|
		zones[i] = middleware.Host(zones[i]).Normalize()
 | 
						|
	}
 | 
						|
	return zones, keys, nil
 | 
						|
}
 | 
						|
 | 
						|
func keyParse(c *caddy.Controller) ([]*DNSKEY, error) {
 | 
						|
	keys := []*DNSKEY{}
 | 
						|
 | 
						|
	what := c.Val()
 | 
						|
	if !c.NextArg() {
 | 
						|
		return nil, c.ArgErr()
 | 
						|
	}
 | 
						|
	value := c.Val()
 | 
						|
	switch what {
 | 
						|
	case "key":
 | 
						|
		if value == "file" {
 | 
						|
			ks := c.RemainingArgs()
 | 
						|
			for _, k := range ks {
 | 
						|
				base := k
 | 
						|
				// Kmiek.nl.+013+26205.key, handle .private or without extension: Kmiek.nl.+013+26205
 | 
						|
				if strings.HasSuffix(k, ".key") {
 | 
						|
					base = k[:len(k)-4]
 | 
						|
				}
 | 
						|
				if strings.HasSuffix(k, ".private") {
 | 
						|
					base = k[:len(k)-8]
 | 
						|
				}
 | 
						|
				k, err := ParseKeyFile(base+".key", base+".private")
 | 
						|
				if err != nil {
 | 
						|
					return nil, err
 | 
						|
				}
 | 
						|
				keys = append(keys, k)
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return keys, nil
 | 
						|
}
 |