diff options
| author | historia <[not public]> | 2026-09-18 05:31:09 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-18 05:31:09 -0400 |
| commit | 153acb7f644d755c45533b7c5311e3ffa47e8973 (patch) | |
| tree | 7645e6f7b65bc3830b078e3b9336d2e6b199d584 /internal/config/config.go | |
| parent | 87d08f0151e643951769e323995f1c5ed89ee200 (diff) | |
| download | thehouseoficarus-153acb7f644d755c45533b7c5311e3ffa47e8973.tar.gz | |
fix: harden engine across casino, economy, concurrency, security, and content
Diffstat (limited to 'internal/config/config.go')
| -rw-r--r-- | internal/config/config.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 362c9c1..852a6d6 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,6 +3,9 @@ package config import ( + "bytes" + "errors" + "io" "os" "gopkg.in/yaml.v3" @@ -242,7 +245,15 @@ func Load(path string) (*Config, error) { return nil, err } cfg := Default() - if err := yaml.Unmarshal(data, cfg); err != nil { + // KnownFields makes a misspelled key (e.g. telnet_listen) a hard error + // instead of silently leaving the default in place. ColorsConfig is a map, + // so arbitrary color keys remain allowed. + dec := yaml.NewDecoder(bytes.NewReader(data)) + dec.KnownFields(true) + // An empty or comment-only file yields io.EOF, which means "no keys set" + // rather than a broken config: the defaults above stay in effect. A real + // syntax/unknown-field error is still returned. + if err := dec.Decode(cfg); err != nil && !errors.Is(err, io.EOF) { return nil, err } return cfg, nil |
