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:
@@ -51,7 +51,9 @@ func ParseRouter(cfg *config.RouterConfig) router.Router {
|
||||
_, ipNet, _ := net.ParseCIDR(route.Net)
|
||||
dst := route.Dst
|
||||
if dst != "" {
|
||||
_, ipNet, _ = net.ParseCIDR(dst)
|
||||
if _, parsed, _ := net.ParseCIDR(dst); parsed != nil {
|
||||
ipNet = parsed
|
||||
}
|
||||
} else {
|
||||
if ipNet != nil {
|
||||
dst = ipNet.String()
|
||||
|
||||
Reference in New Issue
Block a user