Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
httpcaddyfile: Yield cleaner JSON when conn policy or log name is empty
Matthew Holt committed
Apr 3, 2020 at 20:19 UTC
3d6fc1e1b7f41ebbd0c7cb48280ce1a14a56f4d5
1 file changed
+17
-3
caddyconfig/httpcaddyfile/httptype.go
+17
-3
@@ -449,7 +449,9 @@ func (st *ServerType) serversFromPairings(
449
}
450
}
451
for _, h := range sblock.hostsFromKeys(true, true) {
452
- srv.Logs.LoggerNames[h] = ncl.name
452
+ if ncl.name != "" {
453
+ srv.Logs.LoggerNames[h] = ncl.name
454
+ }
455
}
456
}
457
}
@@ -548,10 +550,22 @@ func detectConflictingSchemes(srv *caddyhttp.Server, serverBlocks []serverBlock,
550
return nil
551
}
552
551
-// consolidateConnPolicies combines TLS connection policies that are the same,
552
-// for a cleaner overall output.
553
+// consolidateConnPolicies removes empty TLS connection policies and combines
554
+// equivalent ones for a cleaner overall output.
555
func consolidateConnPolicies(cps caddytls.ConnectionPolicies) (caddytls.ConnectionPolicies, error) {
556
+ empty := new(caddytls.ConnectionPolicy)
557
+
558
for i := 0; i < len(cps); i++ {
559
+ // if the connection policy is empty or has
560
+ // only matchers, we can remove it entirely
561
+ empty.MatchersRaw = cps[i].MatchersRaw
562
+ if reflect.DeepEqual(empty, cps[i]) {
563
+ cps = append(cps[:i], cps[i+1:]...)
564
+ i--
565
+ continue
566
+ }
567
+
568
+ // compare it to the others
569
for j := 0; j < len(cps); j++ {
570
if j == i {
571
continue