mirror of
https://github.com/ehang-io/nps.git
synced 2025-08-31 17:56:56 +00:00
fixes #367
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -328,13 +327,16 @@ func (s *DbUtils) GetInfoByHost(host string, r *http.Request) (h *Host, err erro
|
||||
}
|
||||
//Remove http(s) http(s)://a.proxy.com
|
||||
//*.proxy.com *.a.proxy.com Do some pan-parsing
|
||||
tmp := strings.Replace(v.Host, "*", `\w+?`, -1)
|
||||
var re *regexp.Regexp
|
||||
if re, err = regexp.Compile(tmp); err != nil {
|
||||
if v.Scheme != "all" && v.Scheme != r.URL.Scheme {
|
||||
return true
|
||||
}
|
||||
if len(re.FindAllString(host, -1)) > 0 && (v.Scheme == "all" || v.Scheme == r.URL.Scheme) {
|
||||
//URL routing
|
||||
tmpHost := v.Host
|
||||
if strings.Contains(tmpHost, "*") {
|
||||
tmpHost = strings.Replace(tmpHost, "*", "", -1)
|
||||
if strings.Contains(host, tmpHost) {
|
||||
hosts = append(hosts, v)
|
||||
}
|
||||
} else if v.Host == host {
|
||||
hosts = append(hosts, v)
|
||||
}
|
||||
return true
|
||||
|
Reference in New Issue
Block a user