* 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.
This commit is contained in:
Miek Gieben
2016-09-23 09:14:12 +01:00
committed by GitHub
parent cacbb0e0b1
commit 090d1872e9
61 changed files with 381 additions and 577 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/miekg/dns"
)
// DNSKEY holds a DNSSEC public and private key used for on-the-fly signing.
type DNSKEY struct {
K *dns.DNSKEY
s crypto.Signer

View File

@@ -12,6 +12,7 @@ import (
gcache "github.com/patrickmn/go-cache"
)
// Dnssec signs the reply on-the-fly.
type Dnssec struct {
Next middleware.Handler
@@ -21,6 +22,7 @@ type Dnssec struct {
cache *gcache.Cache
}
// New returns a new Dnssec.
func New(zones []string, keys []*DNSKEY, next middleware.Handler) Dnssec {
return Dnssec{Next: next,
zones: zones,
@@ -95,7 +97,7 @@ func (d Dnssec) sign(rrs []dns.RR, signerName string, ttl, incep, expir uint32)
sigs := make([]dns.RR, len(d.keys))
var e error
for i, k := range d.keys {
sig := k.NewRRSIG(signerName, ttl, incep, expir)
sig := k.newRRSIG(signerName, ttl, incep, expir)
e = sig.Sign(k.s, rrs)
sigs[i] = sig
}

View File

@@ -35,7 +35,7 @@ func (d Dnssec) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
}
}
drr := NewDnssecResponseWriter(w, d)
drr := &ResponseWriter{w, d}
return d.Next.ServeDNS(ctx, drr, r)
}

View File

@@ -10,15 +10,13 @@ import (
"github.com/miekg/dns"
)
// ResponseWriter sign the response on the fly.
type ResponseWriter struct {
dns.ResponseWriter
d Dnssec
}
func NewDnssecResponseWriter(w dns.ResponseWriter, d Dnssec) *ResponseWriter {
return &ResponseWriter{w, d}
}
// WriteMsg implements the dns.ResponseWriter interface.
func (d *ResponseWriter) WriteMsg(res *dns.Msg) error {
// By definition we should sign anything that comes back, we should still figure out for
// which zone it should be.
@@ -38,13 +36,12 @@ func (d *ResponseWriter) WriteMsg(res *dns.Msg) error {
return d.ResponseWriter.WriteMsg(res)
}
// Write implements the dns.ResponseWriter interface.
func (d *ResponseWriter) Write(buf []byte) (int, error) {
log.Printf("[WARNING] Dnssec called with Write: not signing reply")
n, err := d.ResponseWriter.Write(buf)
return n, err
}
func (d *ResponseWriter) Hijack() {
d.ResponseWriter.Hijack()
return
}
// Hijack implements the dns.ResponseWriter interface.
func (d *ResponseWriter) Hijack() { d.ResponseWriter.Hijack() }

View File

@@ -3,7 +3,7 @@ package dnssec
import "github.com/miekg/dns"
// newRRSIG return a new RRSIG, with all fields filled out, except the signed data.
func (k *DNSKEY) NewRRSIG(signerName string, ttl, incep, expir uint32) *dns.RRSIG {
func (k *DNSKEY) newRRSIG(signerName string, ttl, incep, expir uint32) *dns.RRSIG {
sig := new(dns.RRSIG)
sig.Hdr.Rrtype = dns.TypeRRSIG
@@ -11,7 +11,7 @@ func (k *DNSKEY) NewRRSIG(signerName string, ttl, incep, expir uint32) *dns.RRSI
sig.KeyTag = k.keytag
sig.SignerName = signerName
sig.Hdr.Ttl = ttl
sig.OrigTtl = origTtl
sig.OrigTtl = origTTL
sig.Inception = incep
sig.Expiration = expir
@@ -50,4 +50,4 @@ func rrSets(rrs []dns.RR) map[rrset][]dns.RR {
return nil
}
const origTtl = 3600
const origTTL = 3600

View File

@@ -52,7 +52,7 @@ func dnssecParse(c *caddy.Controller) ([]string, []*DNSKEY, error) {
}
}
}
for i, _ := range zones {
for i := range zones {
zones[i] = middleware.Host(zones[i]).Normalize()
}
return zones, keys, nil