MCPcopy Create free account
hub / github.com/encodeous/nylon / ApplyCentralConfig

Method ApplyCentralConfig

core/nylon_apply.go:22–53  ·  view source on GitHub ↗
(cfg *state.CentralCfg)

Source from the content-addressed store, hash-verified

20)
21
22func (n *Nylon) ApplyCentralConfig(cfg *state.CentralCfg) (ApplyResult, error) {
23 err, next := cfg.Clone()
24 if err != nil {
25 return ApplyRejected, err
26 }
27 state.ExpandCentralConfig(next)
28 if err := state.CentralConfigValidator(next); err != nil {
29 return ApplyRejected, err
30 }
31 if !next.IsRouter(n.LocalCfg.Id) {
32 return ApplyRestartRequired, errors.New("local node is not a router in the new central config")
33 }
34 if reflect.DeepEqual(n.CentralCfg, next) {
35 return ApplyNoop, nil
36 }
37
38 if err := n.reconcileRouterState(next); err != nil {
39 return ApplyRejected, err
40 }
41 n.reconcileAdvertisedPrefixes(next)
42 n.CentralCfg = *next
43
44 if err := n.SyncWireGuard(); err != nil {
45 return ApplyRejected, err
46 }
47 if err := n.SyncSystemState(); err != nil {
48 return ApplyRejected, err
49 }
50 ComputeRoutes(n.RouterState, n)
51
52 return ApplyApplied, nil
53}
54
55func (n *Nylon) reconcileRouterState(next *state.CentralCfg) error {
56 desired := make(map[state.NodeId]state.RouterCfg)

Calls 9

reconcileRouterStateMethod · 0.95
SyncWireGuardMethod · 0.95
SyncSystemStateMethod · 0.95
ExpandCentralConfigFunction · 0.92
CentralConfigValidatorFunction · 0.92
ComputeRoutesFunction · 0.85
CloneMethod · 0.80
IsRouterMethod · 0.80