return ssl alert unrecognized_name when https domain not registered (#3620)

This commit is contained in:
Zeyu Dong
2023-09-18 02:28:05 -04:00
committed by GitHub
parent bae0b4d7c0
commit 5c8ea51eb5
5 changed files with 28 additions and 9 deletions

View File

@@ -46,6 +46,7 @@ type (
authFunc func(conn net.Conn, username, password string, reqInfoMap map[string]string) (bool, error)
hostRewriteFunc func(net.Conn, string) (net.Conn, error)
successHookFunc func(net.Conn, map[string]string) error
failHookFunc func(net.Conn)
)
// Muxer is a functional component used for https and tcpmux proxies.
@@ -58,6 +59,7 @@ type Muxer struct {
vhostFunc muxFunc
checkAuth authFunc
successHook successHookFunc
failHook failHookFunc
rewriteHost hostRewriteFunc
registryRouter *Routers
}
@@ -87,6 +89,11 @@ func (v *Muxer) SetSuccessHookFunc(f successHookFunc) *Muxer {
return v
}
func (v *Muxer) SetFailHookFunc(f failHookFunc) *Muxer {
v.failHook = f
return v
}
func (v *Muxer) SetRewriteHostFunc(f hostRewriteFunc) *Muxer {
v.rewriteHost = f
return v
@@ -206,13 +213,8 @@ func (v *Muxer) handle(c net.Conn) {
httpUser := reqInfoMap["HTTPUser"]
l, ok := v.getListener(name, path, httpUser)
if !ok {
res := notFoundResponse()
if res.Body != nil {
defer res.Body.Close()
}
_ = res.Write(c)
log.Debug("http request for host [%s] path [%s] httpUser [%s] not found", name, path, httpUser)
_ = c.Close()
v.failHook(sConn)
return
}