aboutsummaryrefslogtreecommitdiff
path: root/route.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-31 11:28:15 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-03-31 11:28:15 +0200
commit94899ddaf95e79324de8bcdd70ca18ff834ec0be (patch)
tree6c3ade19899a77b4e28aee2d4f752164b6d3ae53 /route.go
parent647ff6e872fe9e1de936521acdb23373a610e68d (diff)
Separated routes branch
Diffstat (limited to 'route.go')
-rw-r--r--route.go29
1 files changed, 1 insertions, 28 deletions
diff --git a/route.go b/route.go
index 544fd2f..92d318d 100644
--- a/route.go
+++ b/route.go
@@ -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
}