aboutsummaryrefslogtreecommitdiff
path: root/route.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-24 00:07:31 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-03-24 00:07:31 +0100
commitb38e33d6b1c3973b40c306b754f8e29c27d010e0 (patch)
tree1d341791647ad87d8a1e713b6ed0153a4bea8803 /route.go
parent04dc81bed2efa2a3c8a580d7e58b3c5be3775764 (diff)
Make lint happy
Diffstat (limited to 'route.go')
-rw-r--r--route.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/route.go b/route.go
index c9d05e0..f66d076 100644
--- a/route.go
+++ b/route.go
@@ -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
}