Skip to content

Commit f4432a3

Browse files
authored
caddyfile: add error handling for unrecognized subdirective/options in various modules (#6884)
1 parent 220cd1c commit f4432a3

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

caddyconfig/httpcaddyfile/serveroptions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ func unmarshalCaddyfileServerOptions(d *caddyfile.Dispenser) (any, error) {
246246
switch d.Val() {
247247
case "per_host":
248248
serverOpts.Metrics.PerHost = true
249+
default:
250+
return nil, d.Errf("unrecognized metrics option '%s'", d.Val())
249251
}
250252
}
251253

modules/caddyhttp/matchers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,8 @@ func (m *MatchTLS) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
13421342
case "early_data":
13431343
var false bool
13441344
m.HandshakeComplete = &false
1345+
default:
1346+
return d.Errf("unrecognized option '%s'", d.Val())
13451347
}
13461348
}
13471349
if d.NextArg() {

modules/caddytls/internalissuer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ func (iss *InternalIssuer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
178178
return d.ArgErr()
179179
}
180180
iss.SignWithRoot = true
181+
182+
default:
183+
return d.Errf("unrecognized subdirective '%s'", d.Val())
181184
}
182185
}
183186
return nil

modules/logging/filewriter.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ func (fw *FileWriter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
313313
return d.Errf("negative roll_keep_for duration: %v", keepFor)
314314
}
315315
fw.RollKeepDays = int(math.Ceil(keepFor.Hours() / 24))
316+
317+
default:
318+
return d.Errf("unrecognized subdirective '%s'", d.Val())
316319
}
317320
}
318321
return nil

modules/logging/netwriter.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ func (nw *NetWriter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
145145
return d.ArgErr()
146146
}
147147
nw.SoftStart = true
148+
149+
default:
150+
return d.Errf("unrecognized subdirective '%s'", d.Val())
148151
}
149152
}
150153
return nil

0 commit comments

Comments
 (0)