Support atomically swapping http handler for passhtrough

This commit is contained in:
WeebDataHoarder
2025-04-23 17:28:44 +02:00
parent 3b11792594
commit 9719c0ff39
3 changed files with 74 additions and 106 deletions

View File

@@ -10,7 +10,6 @@ import (
"log/slog"
"maps"
"net/http"
"strings"
)
// Defines challenge.StateInterface
@@ -142,17 +141,5 @@ func (state *State) Settings() policy.Settings {
}
func (state *State) GetBackend(host string) http.Handler {
backend, ok := state.Settings().Backends[host]
if !ok {
// do wildcard match
wildcard := "*." + strings.Join(strings.Split(host, ".")[1:], ".")
backend, ok = state.Settings().Backends[wildcard]
if !ok {
// return fallback
backend = state.Settings().Backends["*"]
}
}
//TODO: dynamic
return backend
return utils.SelectHTTPHandler(state.Settings().Backends, host)
}