|
|
@@ -92,8 +92,8 @@ func bootstrapBroadcastState(config structs.SysConfig) (structs.AuthBroadcast, e
|
|
|
currentState = GetState()
|
|
|
// get startram regions
|
|
|
logger.Info("Retrieving StarTram region info")
|
|
|
- wgRegistered := config.WgRegistered
|
|
|
- wgOn := config.WgOn
|
|
|
+ //wgRegistered := config.WgRegistered
|
|
|
+ //wgOn := config.WgOn
|
|
|
regions, err := startram.GetRegions()
|
|
|
if err != nil {
|
|
|
logger.Warn("Couldn't get StarTram regions")
|
|
|
@@ -106,7 +106,7 @@ func bootstrapBroadcastState(config structs.SysConfig) (structs.AuthBroadcast, e
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- }
|
|
|
+ }
|
|
|
err := UpdateBroadcastState(updates)
|
|
|
if err != nil {
|
|
|
errmsg := fmt.Sprintf("Error updating broadcast state:", err)
|
|
|
@@ -135,17 +135,17 @@ func UpdateBroadcastState(values map[string]interface{}) error {
|
|
|
if err := recursiveUpdate(field, val); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
BroadcastToClients()
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// this allows us to insert stuff into nested structs/keys and not overwrite the existing contents
|
|
|
func recursiveUpdate(dst, src reflect.Value) error {
|
|
|
- if !dst.CanSet() {
|
|
|
- return fmt.Errorf("field is not settable")
|
|
|
- }
|
|
|
- // If dst is a struct and src is a map, handle them field by field
|
|
|
+ if !dst.CanSet() {
|
|
|
+ return fmt.Errorf("field is not settable")
|
|
|
+ }
|
|
|
+ // If dst is a struct and src is a map, handle them field by field
|
|
|
if dst.Kind() == reflect.Struct && src.Kind() == reflect.Map {
|
|
|
for _, key := range src.MapKeys() {
|
|
|
dstField := dst.FieldByName(key.String())
|
|
|
@@ -169,33 +169,33 @@ func recursiveUpdate(dst, src reflect.Value) error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
- // If both dst and src are maps, handle them recursively
|
|
|
- if dst.Kind() == reflect.Map && src.Kind() == reflect.Map {
|
|
|
- for _, key := range src.MapKeys() {
|
|
|
- srcVal := src.MapIndex(key)
|
|
|
- // If the key doesn't exist in dst, initialize it
|
|
|
- dstVal := dst.MapIndex(key)
|
|
|
- if !dstVal.IsValid() {
|
|
|
- dstVal = reflect.New(dst.Type().Elem()).Elem()
|
|
|
- }
|
|
|
- // Recursive call to handle potential nested maps or structs
|
|
|
- if err := recursiveUpdate(dstVal, srcVal); err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- // Initialize the map if it's nil
|
|
|
- if dst.IsNil() {
|
|
|
- dst.Set(reflect.MakeMap(dst.Type()))
|
|
|
- }
|
|
|
- dst.SetMapIndex(key, dstVal)
|
|
|
- }
|
|
|
- return nil
|
|
|
- }
|
|
|
- // For non-map or non-struct fields, or for direct updates
|
|
|
- if dst.Type() != src.Type() {
|
|
|
- return fmt.Errorf("type mismatch: expected %s, got %s", dst.Type(), src.Type())
|
|
|
- }
|
|
|
- dst.Set(src)
|
|
|
- return nil
|
|
|
+ // If both dst and src are maps, handle them recursively
|
|
|
+ if dst.Kind() == reflect.Map && src.Kind() == reflect.Map {
|
|
|
+ for _, key := range src.MapKeys() {
|
|
|
+ srcVal := src.MapIndex(key)
|
|
|
+ // If the key doesn't exist in dst, initialize it
|
|
|
+ dstVal := dst.MapIndex(key)
|
|
|
+ if !dstVal.IsValid() {
|
|
|
+ dstVal = reflect.New(dst.Type().Elem()).Elem()
|
|
|
+ }
|
|
|
+ // Recursive call to handle potential nested maps or structs
|
|
|
+ if err := recursiveUpdate(dstVal, srcVal); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ // Initialize the map if it's nil
|
|
|
+ if dst.IsNil() {
|
|
|
+ dst.Set(reflect.MakeMap(dst.Type()))
|
|
|
+ }
|
|
|
+ dst.SetMapIndex(key, dstVal)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ // For non-map or non-struct fields, or for direct updates
|
|
|
+ if dst.Type() != src.Type() {
|
|
|
+ return fmt.Errorf("type mismatch: expected %s, got %s", dst.Type(), src.Type())
|
|
|
+ }
|
|
|
+ dst.Set(src)
|
|
|
+ return nil
|
|
|
}
|
|
|
|
|
|
// return broadcast state
|