From d93dd82ed907f5277ace8a4fc4fa324498b26f6f Mon Sep 17 00:00:00 2001 From: XueBing Date: Sun, 18 Dec 2016 23:35:14 +0800 Subject: [PATCH] modify the getListener function && add TPS in dashboard --- src/assets/static/index.html | 4 +++- src/utils/vhost/vhost.go | 18 +++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/assets/static/index.html b/src/assets/static/index.html index dc7f3626..d9170081 100644 --- a/src/assets/static/index.html +++ b/src/assets/static/index.html @@ -25,6 +25,7 @@ CurCon FlowOut FlowIn + TotalAcceptConns @@ -34,10 +35,11 @@ - + + diff --git a/src/utils/vhost/vhost.go b/src/utils/vhost/vhost.go index fb0b5c8f..a7e953f0 100644 --- a/src/utils/vhost/vhost.go +++ b/src/utils/vhost/vhost.go @@ -76,10 +76,19 @@ func (v *VhostMuxer) Listen(p *config.ProxyServerConf) (ls []*Listener) { return ls } -func (v *VhostMuxer) getListener(name string) (l *Listener, exist bool) { +func (v *VhostMuxer) getListener(reqInfoMap map[string]string) (l *Listener, exist bool) { v.mutex.RLock() defer v.mutex.RUnlock() + //host + name := strings.ToLower(reqInfoMap["Host"]) + + // http + scheme := strings.ToLower(reqInfoMap["Scheme"]) + if scheme == "http" || scheme == "" { + name = name + ":" + reqInfoMap["Path"] + } + // // first we check the full hostname vr, found := v.registryRouter.get(name) if found { @@ -126,12 +135,7 @@ func (v *VhostMuxer) handle(c *conn.Conn) { return } - name := strings.ToLower(reqInfoMap["Host"]) - // get listener by hostname - if reqInfoMap["Scheme"] == "http" { - name = name + ":" + reqInfoMap["Path"] - } - l, ok := v.getListener(name) + l, ok := v.getListener(reqInfoMap) if !ok { c.Close() return