diff options
author | Dimitri Sokolyuk <demon@dim13.org> | 2016-03-24 00:07:31 +0100 |
---|---|---|
committer | Dimitri Sokolyuk <demon@dim13.org> | 2016-03-24 00:07:31 +0100 |
commit | b38e33d6b1c3973b40c306b754f8e29c27d010e0 (patch) | |
tree | 1d341791647ad87d8a1e713b6ed0153a4bea8803 /route.go | |
parent | 04dc81bed2efa2a3c8a580d7e58b3c5be3775764 (diff) |
Make lint happy
Diffstat (limited to 'route.go')
-rw-r--r-- | route.go | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -8,8 +8,10 @@ import ( "net/url" ) +// Route defines a set of routes including correspondent TLS certificates type Route map[string]Entry +// Entry holds routing settings type Entry struct { ServerName string Upstream string @@ -18,6 +20,7 @@ type Entry struct { cert *tls.Certificate } +// GetCertificate returns certificate for SNI negotiation func (r Route) GetCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error) { if e, ok := r[h.ServerName]; ok && e.cert != nil { return e.cert, nil @@ -25,6 +28,7 @@ func (r Route) GetCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error) return nil, errors.New("no cert for " + h.ServerName) } +// Restore and update routes from in-memory state func (r Route) Restore() error { mux := http.NewServeMux() for k, v := range route { @@ -47,9 +51,9 @@ func (r Route) Restore() error { } func (e Entry) String() string { + ret := e.ServerName + " -> " + e.Upstream if e.cert != nil { - return e.ServerName + " -> " + e.Upstream + " with TLS" - } else { - return e.ServerName + " -> " + e.Upstream + ret += " with TLS" } + return ret } |