Skip to content
Permalink
Browse files

Report when subdomain is unavailable. Also allow all HTTP protos

  • Loading branch information...
antoniomika committed Mar 28, 2019
1 parent 9cbabe4 commit c849006dc89ebb87f3e788adb6b21d87a1d407c3
Showing with 12 additions and 3 deletions.
  1. +3 −2 http.go
  2. +9 −1 utils.go
@@ -38,8 +38,7 @@ func startHTTPHandler(state *State) {
return
}
c.Next()
}, gin.Logger(), gin.Recovery())
r.GET("/*proxy", func(c *gin.Context) {
}, gin.Logger(), gin.Recovery(), func(c *gin.Context) {
hostname := strings.Split(c.Request.Host, ":")[0]

if hostname == *rootDomain && *redirectRoot {
@@ -78,6 +77,7 @@ func startHTTPHandler(state *State) {
},
}
gin.WrapH(wsProxy)(c)
return
} else {
proxy := httputil.NewSingleHostReverseProxy(url)
proxy.Transport = &http.Transport{
@@ -87,6 +87,7 @@ func startHTTPHandler(state *State) {
},
}
gin.WrapH(proxy)(c)
return
}
})

@@ -249,14 +249,22 @@ func getOpenHost(addr string, state *State, sshConn *SSHConnection) string {
getRandomHost := func() string {
return strings.ToLower(RandStringBytesMaskImprSrc(*domainLen) + "." + *rootDomain)
}
reportUnavailable := func(unavailable bool) {
if first && unavailable {
sshConn.Messages <- "This subdomain is unavaible. Assigning a random subdomain."
}
}

checkHost := func(checkHost string) bool {
if *forceRandomSubdomain || !first || inBannedList(host, bannedSubdomainList) {
reportUnavailable(true)
host = getRandomHost()
}

first = false
_, ok := state.HTTPListeners.Load(host)
reportUnavailable(ok)

first = false
return ok
}

0 comments on commit c849006

Please sign in to comment.
You can’t perform that action at this time.