utils/vhost: supprot http authentication

This commit is contained in:
Maodanping
2016-08-29 10:53:02 +08:00
Unverified
parent 77f207d69a
commit dc5e130d33
10 changed files with 111 additions and 19 deletions
+6 -4
View File
@@ -48,7 +48,7 @@ type HttpsMuxer struct {
}
func NewHttpsMuxer(listener *conn.Listener, timeout time.Duration) (*HttpsMuxer, error) {
mux, err := NewVhostMuxer(listener, GetHttpsHostname, nil, timeout)
mux, err := NewVhostMuxer(listener, GetHttpsHostname, nil, nil, timeout)
return &HttpsMuxer{mux}, err
}
@@ -178,11 +178,13 @@ func readHandshake(rd io.Reader) (host string, err error) {
return
}
func GetHttpsHostname(c *conn.Conn) (sc net.Conn, routerName string, err error) {
func GetHttpsHostname(c *conn.Conn) (sc net.Conn, _ map[string]string, err error) {
reqInfoMap := make(map[string]string, 0)
sc, rd := newShareConn(c.TcpConn)
host, err := readHandshake(rd)
if err != nil {
return sc, "", err
return sc, reqInfoMap, err
}
return sc, host, nil
reqInfoMap["Host"] = host
return sc, reqInfoMap, nil
}