Error out if unknown properties are found in the config file
And thanks to this, an inconsistency in the example config file vs the parser was found (`timeout` vs `timeout_ms`). Fixes #113
This commit is contained in:
parent
32db89d2ee
commit
2f00ad5ff0
|
@ -23,7 +23,7 @@ type Config struct {
|
|||
ListenAddresses []string `toml:"listen_addresses"`
|
||||
Daemonize bool
|
||||
ForceTCP bool `toml:"force_tcp"`
|
||||
Timeout int `toml:"timeout_ms"`
|
||||
Timeout int `toml:"timeout"`
|
||||
CertRefreshDelay int `toml:"cert_refresh_delay"`
|
||||
CertIgnoreTimestamp bool `toml:"cert_ignore_timestamp"`
|
||||
LBStrategy string `toml:"lb_strategy"`
|
||||
|
@ -148,9 +148,14 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error {
|
|||
os.Exit(0)
|
||||
}
|
||||
config := newConfig()
|
||||
if _, err := toml.DecodeFile(*configFile, &config); err != nil {
|
||||
md, err := toml.DecodeFile(*configFile, &config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
undecoded := md.Undecoded()
|
||||
if len(undecoded) > 0 {
|
||||
return fmt.Errorf("Unsupported key in configuration file: [%s]", undecoded[0])
|
||||
}
|
||||
cdFileDir(*configFile)
|
||||
if config.LogLevel >= 0 && config.LogLevel < int(dlog.SeverityLast) {
|
||||
dlog.SetLogLevel(dlog.Severity(config.LogLevel))
|
||||
|
|
Loading…
Reference in New Issue