summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2022-09-02 13:04:31 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2022-09-02 13:04:31 -0600
commit005c5a63823b19382aa918f1e1f3288e66446225 (patch)
tree75a95df8ef46e3b1251024fc3977f4c51fd7287b
parent6c0d0511ba07f607bfa58e07caff176296c61b53 (diff)
Minor style adjustments for HTTP redir logging
-rw-r--r--modules/caddyhttp/autohttps.go10
-rw-r--r--modules/caddyhttp/server.go13
2 files changed, 13 insertions, 10 deletions
diff --git a/modules/caddyhttp/autohttps.go b/modules/caddyhttp/autohttps.go
index 70f999b..3d476cb 100644
--- a/modules/caddyhttp/autohttps.go
+++ b/modules/caddyhttp/autohttps.go
@@ -93,8 +93,8 @@ func (app *App) automaticHTTPSPhase1(ctx caddy.Context, repl *caddy.Replacer) er
// https://github.com/caddyserver/caddy/issues/3443)
redirDomains := make(map[string][]caddy.NetworkAddress)
- // the configured logger for an HTTPS enabled server
- var logger *ServerLogConfig
+ // the log configuration for an HTTPS enabled server
+ var logCfg *ServerLogConfig
for srvName, srv := range app.Servers {
// as a prerequisite, provision route matchers; this is
@@ -176,8 +176,10 @@ func (app *App) automaticHTTPSPhase1(ctx caddy.Context, repl *caddy.Replacer) er
}
// clone the logger so we can apply it to the HTTP server
+ // (not sure if necessary to clone it; but probably safer)
+ // (we choose one log cfg arbitrarily; not sure which is best)
if srv.Logs != nil {
- logger = srv.Logs.clone()
+ logCfg = srv.Logs.clone()
}
// for all the hostnames we found, filter them so we have
@@ -408,7 +410,7 @@ redirServersLoop:
app.Servers["remaining_auto_https_redirects"] = &Server{
Listen: redirServerAddrsList,
Routes: appendCatchAll(redirRoutes),
- Logs: logger,
+ Logs: logCfg,
}
}
diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go
index 2dabf46..1bba34c 100644
--- a/modules/caddyhttp/server.go
+++ b/modules/caddyhttp/server.go
@@ -664,15 +664,16 @@ func (slc ServerLogConfig) getLoggerName(host string) string {
}
func (slc *ServerLogConfig) clone() *ServerLogConfig {
- clone := &ServerLogConfig{}
- clone.DefaultLoggerName = slc.DefaultLoggerName
- clone.LoggerNames = make(map[string]string)
+ clone := &ServerLogConfig{
+ DefaultLoggerName: slc.DefaultLoggerName,
+ LoggerNames: make(map[string]string),
+ SkipHosts: append([]string{}, slc.SkipHosts...),
+ SkipUnmappedHosts: slc.SkipUnmappedHosts,
+ ShouldLogCredentials: slc.ShouldLogCredentials,
+ }
for k, v := range slc.LoggerNames {
clone.LoggerNames[k] = v
}
- clone.SkipHosts = append(clone.SkipHosts, slc.SkipHosts...)
- clone.SkipUnmappedHosts = slc.SkipUnmappedHosts
- clone.ShouldLogCredentials = slc.ShouldLogCredentials
return clone
}