fix(config): stop mutating shared config structs during parsing

Prevent data loss and nil panics across 5 parse functions:
- chain: nil-guard hop entries to avoid deref on empty YAML lists
- hop: build merged metadata map instead of writing inherited values
  into the original NodeConfig; swap+restore around ParseNode call
- node: use local connCfg/dialCfg instead of overwriting cfg.Connector
  and cfg.Dialer fields; only fill in Type when empty
- parser: preserve existing config file fields when env vars override
  Level/Addr (was replacing the entire struct)
- router: only update ipNet from dst CIDR if parse succeeds, keeping
  the route.Net fallback instead of overwriting with nil
This commit is contained in:
ginuerzh
2026-05-24 12:56:54 +08:00
parent 8390ccadab
commit 9febb23bc9
5 changed files with 60 additions and 54 deletions
+4
View File
@@ -33,6 +33,10 @@ func ParseChain(cfg *config.ChainConfig, log logger.Logger) (chain.Chainer, erro
)
for _, ch := range cfg.Hops {
if ch == nil {
continue
}
var hop hop.Hop
var err error