diff options
-rw-r--r-- | config/serve.go | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/config/serve.go b/config/serve.go index 10eed911..8c7d833c 100644 --- a/config/serve.go +++ b/config/serve.go @@ -17,32 +17,42 @@ func ReadConfigfileServe(path, format string, configCh chan BgpConfigSet, reload <-reloadCh b := Bgp{} - p := RoutingPolicy{} v := viper.New() v.SetConfigFile(path) v.SetConfigType(format) err := v.ReadInConfig() + c := struct { + Global Global `mapstructure:"global"` + Neighbors []Neighbor `mapstructure:"neighbors"` + RpkiServers []RpkiServer `mapstructure:"rpki-servers"` + DefinedSets DefinedSets `mapstructure:"defined-sets"` + PolicyDefinitions []PolicyDefinition `mapstructure:"policy-definitions"` + }{} if err != nil { goto ERROR } - err = v.Unmarshal(&b) + err = v.UnmarshalExact(&c) if err != nil { goto ERROR } + b.Global = c.Global + b.Neighbors = c.Neighbors + b.RpkiServers = c.RpkiServers err = SetDefaultConfigValues(v, &b) if err != nil { goto ERROR } - err = v.Unmarshal(&p) - if err != nil { - goto ERROR - } - if cnt == 0 { log.Info("finished reading the config file") } cnt++ - configCh <- BgpConfigSet{Bgp: b, Policy: p} + configCh <- BgpConfigSet{ + Bgp: b, + Policy: RoutingPolicy{ + DefinedSets: c.DefinedSets, + PolicyDefinitions: c.PolicyDefinitions, + }, + } continue ERROR: |