|
@@ -34,23 +34,45 @@ func (router *Router) getProxyEndpointFromHostname(hostname string) *ProxyEndpoi
|
|
|
var targetSubdomainEndpoint *ProxyEndpoint = nil
|
|
|
ep, ok := router.ProxyEndpoints.Load(hostname)
|
|
|
if ok {
|
|
|
+ //Exact hit
|
|
|
targetSubdomainEndpoint = ep.(*ProxyEndpoint)
|
|
|
+ if !targetSubdomainEndpoint.Disabled {
|
|
|
+ return targetSubdomainEndpoint
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //No hit. Try with wildcard
|
|
|
+ //No hit. Try with wildcard and alias
|
|
|
matchProxyEndpoints := []*ProxyEndpoint{}
|
|
|
router.ProxyEndpoints.Range(func(k, v interface{}) bool {
|
|
|
ep := v.(*ProxyEndpoint)
|
|
|
match, err := filepath.Match(ep.RootOrMatchingDomain, hostname)
|
|
|
if err != nil {
|
|
|
- //Continue
|
|
|
+ //Bad pattern. Skip this rule
|
|
|
return true
|
|
|
}
|
|
|
+
|
|
|
if match {
|
|
|
- //targetSubdomainEndpoint = ep
|
|
|
+ //Wildcard matches. Skip checking alias
|
|
|
matchProxyEndpoints = append(matchProxyEndpoints, ep)
|
|
|
return true
|
|
|
}
|
|
|
+
|
|
|
+ //Wildcard not match. Check for alias
|
|
|
+ if ep.MatchingDomainAlias != nil && len(ep.MatchingDomainAlias) > 0 {
|
|
|
+ for _, aliasDomain := range ep.MatchingDomainAlias {
|
|
|
+ match, err := filepath.Match(aliasDomain, hostname)
|
|
|
+ if err != nil {
|
|
|
+ //Bad pattern. Skip this alias
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if match {
|
|
|
+ //This alias match
|
|
|
+ matchProxyEndpoints = append(matchProxyEndpoints, ep)
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return true
|
|
|
})
|
|
|
|