This commit is contained in:
Gerasimos (Makis) Maropoulos 2020-08-14 14:18:41 +03:00
parent 9f0872719f
commit d0d7679a98
No known key found for this signature in database
GPG Key ID: 5DBE766BD26A54E7
3 changed files with 3 additions and 5 deletions

View File

@ -910,7 +910,6 @@ func GetDomain(hostport string) string {
host = tmp host = tmp
} }
// has port.
switch host { switch host {
case "127.0.0.1", "0.0.0.0", "::1", "[::1]", "0:0:0:0:0:0:0:0", "0:0:0:0:0:0:0:1": case "127.0.0.1", "0.0.0.0", "::1", "[::1]", "0:0:0:0:0:0:0:0", "0:0:0:0:0:0:0:1":
// loopback. // loopback.

View File

@ -38,12 +38,11 @@ var IsLoopbackSubdomain = func(s string) bool {
// GetLoopbackSubdomain returns the part of the loopback subdomain. // GetLoopbackSubdomain returns the part of the loopback subdomain.
func GetLoopbackSubdomain(s string) string { func GetLoopbackSubdomain(s string) string {
if strings.HasPrefix(s, "127.0.0.1:") || s == "127.0.0.1" || if strings.HasPrefix(s, "127.0.0.1:") || s == "127.0.0.1" ||
strings.HasPrefix(s, "0.0.0.0:") || s == "0.0.0.0" /* let's resolve that without regex (see below)*/ { strings.HasPrefix(s, "0.0.0.0:") || s == "0.0.0.0" {
return s return s
} }
ss := loopbackSubRegex.FindString(s) return loopbackSubRegex.FindString(s)
return ss
} }
// IsLoopbackHost tries to catch the local addresses when a developer // IsLoopbackHost tries to catch the local addresses when a developer

View File

@ -115,7 +115,7 @@ func (s *subdomainRedirectWrapper) Wrapper(w http.ResponseWriter, r *http.Reques
if loopback := netutil.GetLoopbackSubdomain(root); loopback != "" { if loopback := netutil.GetLoopbackSubdomain(root); loopback != "" {
root = strings.Replace(root, loopback, context.GetDomain(host), 1) root = strings.Replace(root, loopback, context.GetDomain(host), 1)
} }
// println("root: " + root)
hasSubdomain := host != root hasSubdomain := host != root
if !hasSubdomain && !s.isFromRoot { if !hasSubdomain && !s.isFromRoot {