if DEBUG then extra log

This commit is contained in:
Bel LaPointe
2026-09-09 07:38:20 -07:00
parent 1f76e3ff2f
commit 4b41ba6ff4
2 changed files with 8 additions and 0 deletions
+2
View File
@@ -9,6 +9,8 @@ import (
"gopkg.in/yaml.v2"
)
var debug = os.Getenv("DEBUG") != ""
type (
Config struct {
Cert Cert
+6
View File
@@ -107,6 +107,9 @@ func (c Config) serveHTTPProxy(w http.ResponseWriter, r *http.Request, endpoint
u3 := *u
u3.Path = "/"
r2.Header.Set("Origin", u3.String())
if debug {
log.Printf("r2.Header[Origin] = %q", r2.Header.Get("Origin"))
}
return nil
})
if err != nil {
@@ -177,6 +180,9 @@ func (c Config) endpoint(r *http.Request) Endpoint {
key := c.key(r)
domain := strings.Split(strings.TrimPrefix(r.Host, key), ":")[0]
m, ok := c.Domains[domain]
if debug {
log.Printf("[%s][%s] = %+v", key, domain, m[key])
}
if !ok {
return Endpoint{}
}