aboutsummaryrefslogtreecommitdiff
path: root/route.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-31 14:43:29 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-03-31 14:43:29 +0200
commit7cb7f7d4d90714d50331c68e97fc5169c4f67991 (patch)
tree37f04d81512323ee4aa20262396b7dfe5d6f4c58 /route.go
parent56b132f7dbd9668426d934a6feaa70f3252ed040 (diff)
Rewrite Test, pass HTTP
Diffstat (limited to 'route.go')
-rw-r--r--route.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/route.go b/route.go
index 92d318d..5e1b806 100644
--- a/route.go
+++ b/route.go
@@ -1,14 +1,31 @@
package goxy
import (
+ "crypto/tls"
"encoding/json"
+ "errors"
"fmt"
"net/http"
+ "net/url"
"os"
)
// Route defines a set of routes including correspondent TLS certificates
-type Route map[string]Entry
+type Route map[string]route
+
+type route struct {
+ ServerName *url.URL
+ Upstream *url.URL
+ Certificate *tls.Certificate
+}
+
+// GetCertificate returns certificate for SNI negotiation
+func (r Route) GetCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error) {
+ if route, ok := r[h.ServerName]; ok && route.Certificate != nil {
+ return route.Certificate, nil
+ }
+ return nil, errors.New("no cert for " + h.ServerName)
+}
// Save routes to persistent file
func (r Route) Save(fname string) error {