diff options
author | Dimitri Sokolyuk <demon@dim13.org> | 2016-03-31 11:28:15 +0200 |
---|---|---|
committer | Dimitri Sokolyuk <demon@dim13.org> | 2016-03-31 11:28:15 +0200 |
commit | 94899ddaf95e79324de8bcdd70ca18ff834ec0be (patch) | |
tree | 6c3ade19899a77b4e28aee2d4f752164b6d3ae53 /route.go | |
parent | 647ff6e872fe9e1de936521acdb23373a610e68d (diff) |
Separated routes branch
Diffstat (limited to 'route.go')
-rw-r--r-- | route.go | 29 |
1 files changed, 1 insertions, 28 deletions
@@ -1,9 +1,7 @@ package goxy import ( - "crypto/tls" "encoding/json" - "errors" "fmt" "net/http" "os" @@ -12,14 +10,6 @@ import ( // Route defines a set of routes including correspondent TLS certificates type Route map[string]Entry -// 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 - } - return nil, errors.New("no cert for " + h.ServerName) -} - // Save routes to persistent file func (r Route) Save(fname string) error { fd, err := os.Create(fname) @@ -42,23 +32,6 @@ func (r *Route) Load(fname string) error { func (r Route) ServeHTTP(w http.ResponseWriter, _ *http.Request) { for k, v := range r { - fmt.Fprintln(w, k, v) - } -} - -// Entry holds routing settings -type Entry struct { - Host string // HostName - Upstream string // URL - Cert []byte // PEM - Key []byte // PEM - cert *tls.Certificate // Parsed -} - -func (e Entry) String() string { - ret := e.Host + " → " + e.Upstream - if e.cert != nil { - ret += " with TLS" + fmt.Fprintln(w, k, "→", v) } - return ret } |