feat: match proxy's from on whole targeted url
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good

This commit is contained in:
2024-03-29 09:21:01 +01:00
parent f548c8c8e7
commit 274bef13d8
2 changed files with 29 additions and 2 deletions

View File

@ -3,7 +3,6 @@ package director
import (
"context"
"net/http"
"net/url"
"sort"
"forge.cadoles.com/Cadoles/go-proxy"
@ -28,12 +27,23 @@ func (d *Director) rewriteRequest(r *http.Request) (*http.Request, error) {
return r, errors.WithStack(err)
}
url := getRequestURL(r)
ctx = logger.With(r.Context(), logger.F("url", url.String()))
var match *store.Proxy
MAIN:
for _, p := range proxies {
for _, from := range p.From {
if matches := wildcard.Match(r.Host, from); !matches {
logger.Debug(
ctx, "matching request with proxy's from",
logger.F("from", from),
)
if matches := wildcard.Match(url.String(), from); !matches {
logger.Debug(
ctx, "proxy's from matched",
logger.F("from", from),
)
continue
}