summaryrefslogtreecommitdiff
path: root/caddyconfig
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-04-03 20:19:46 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-04-03 20:19:46 -0600
commit3d6fc1e1b7f41ebbd0c7cb48280ce1a14a56f4d5 (patch)
treeac3c7a54c7dd78d27a9c3a7fcea6370d336c2391 /caddyconfig
parentc7ac7de38ae3a2e549a085bf8633a3e8449f9234 (diff)
httpcaddyfile: Yield cleaner JSON when conn policy or log name is empty
Diffstat (limited to 'caddyconfig')
-rw-r--r--caddyconfig/httpcaddyfile/httptype.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go
index 7fbf724..4e69895 100644
--- a/caddyconfig/httpcaddyfile/httptype.go
+++ b/caddyconfig/httpcaddyfile/httptype.go
@@ -449,7 +449,9 @@ func (st *ServerType) serversFromPairings(
}
}
for _, h := range sblock.hostsFromKeys(true, true) {
- srv.Logs.LoggerNames[h] = ncl.name
+ if ncl.name != "" {
+ srv.Logs.LoggerNames[h] = ncl.name
+ }
}
}
}
@@ -548,10 +550,22 @@ func detectConflictingSchemes(srv *caddyhttp.Server, serverBlocks []serverBlock,
return nil
}
-// consolidateConnPolicies combines TLS connection policies that are the same,
-// for a cleaner overall output.
+// consolidateConnPolicies removes empty TLS connection policies and combines
+// equivalent ones for a cleaner overall output.
func consolidateConnPolicies(cps caddytls.ConnectionPolicies) (caddytls.ConnectionPolicies, error) {
+ empty := new(caddytls.ConnectionPolicy)
+
for i := 0; i < len(cps); i++ {
+ // if the connection policy is empty or has
+ // only matchers, we can remove it entirely
+ empty.MatchersRaw = cps[i].MatchersRaw
+ if reflect.DeepEqual(empty, cps[i]) {
+ cps = append(cps[:i], cps[i+1:]...)
+ i--
+ continue
+ }
+
+ // compare it to the others
for j := 0; j < len(cps); j++ {
if j == i {
continue