Skip to content

Commit

Permalink
Merge pull request antoniomika#202 from antoniomika/am/fix-loaders
Browse files Browse the repository at this point in the history
Updated loader functions to support new forward params
  • Loading branch information
antoniomika authored Dec 7, 2021
2 parents aee4770 + b5dd6b9 commit 24e9f31
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
14 changes: 13 additions & 1 deletion httpmuxer/httpmuxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,19 @@ func Start(state *utils.State) {
return fmt.Errorf("ondemand certificate retrieval is not enabled")
}

_, ok := state.HTTPListeners.Load(name)
ok := false

state.HTTPListeners.Range(func(key, value interface{}) bool {
locationListener := value.(*utils.HTTPHolder)

if name == locationListener.HTTPUrl.Host {
ok = true
return false
}

return true
})

if !ok {
return fmt.Errorf("cannot find connection for host: %s", name)
}
Expand Down
20 changes: 18 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,25 @@ func GetOpenHost(addr string, state *State, sshConn *SSHConnection) (*url.URL, *
host = getRandomHost()
}

holder, ok := state.HTTPListeners.Load(host)
var holder *HTTPHolder
ok := false

state.HTTPListeners.Range(func(key, value interface{}) bool {
locationListener := value.(*HTTPHolder)

parsedPassword, _ := locationListener.HTTPUrl.User.Password()

if host == locationListener.HTTPUrl.Host && strings.HasPrefix(path, locationListener.HTTPUrl.Path) && username == locationListener.HTTPUrl.User.Username() && password == parsedPassword {
ok = true
holder = locationListener
return false
}

return true
})

if ok && viper.GetBool("http-load-balancer") {
pH = holder.(*HTTPHolder)
pH = holder
ok = false
}

Expand Down

0 comments on commit 24e9f31

Please sign in to comment.