Add error handling for unrecognized subdirective/options in various modules

This commit is contained in:
Steffen Busch 2025-03-07 23:05:02 +01:00
parent 48ce47f1d4
commit cf54f62015
5 changed files with 13 additions and 0 deletions

View File

@ -245,6 +245,8 @@ func unmarshalCaddyfileServerOptions(d *caddyfile.Dispenser) (any, error) {
switch d.Val() { switch d.Val() {
case "per_host": case "per_host":
serverOpts.Metrics.PerHost = true serverOpts.Metrics.PerHost = true
default:
return nil, d.Errf("unrecognized metrics option '%s'", d.Val())
} }
} }

View File

@ -1283,6 +1283,8 @@ func (m *MatchTLS) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
case "early_data": case "early_data":
var false bool var false bool
m.HandshakeComplete = &false m.HandshakeComplete = &false
default:
return d.Errf("unrecognized option '%s'", d.Val())
} }
} }
if d.NextArg() { if d.NextArg() {

View File

@ -178,6 +178,9 @@ func (iss *InternalIssuer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
return d.ArgErr() return d.ArgErr()
} }
iss.SignWithRoot = true iss.SignWithRoot = true
default:
return d.Errf("unrecognized subdirective '%s'", d.Val())
} }
} }
return nil return nil

View File

@ -296,6 +296,9 @@ func (fw *FileWriter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
return d.Errf("negative roll_keep_for duration: %v", keepFor) return d.Errf("negative roll_keep_for duration: %v", keepFor)
} }
fw.RollKeepDays = int(math.Ceil(keepFor.Hours() / 24)) fw.RollKeepDays = int(math.Ceil(keepFor.Hours() / 24))
default:
return d.Errf("unrecognized subdirective '%s'", d.Val())
} }
} }
return nil return nil

View File

@ -145,6 +145,9 @@ func (nw *NetWriter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
return d.ArgErr() return d.ArgErr()
} }
nw.SoftStart = true nw.SoftStart = true
default:
return d.Errf("unrecognized subdirective '%s'", d.Val())
} }
} }
return nil return nil