mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-10 22:05:58 +08:00
handler for KeyUpdate was missing a call to apply new wireguard conf
This commit is contained in:
parent
4ffbbf128a
commit
a4da05117e
1 changed files with 13 additions and 1 deletions
|
@ -275,6 +275,14 @@ func NodeUpdate(client mqtt.Client, msg mqtt.Message) {
|
||||||
if !strings.Contains("rpc error", err.Error()) {
|
if !strings.Contains("rpc error", err.Error()) {
|
||||||
ncutils.PrintLog(fmt.Sprintf("failed to leave, please check that local files for network %s were removed", cfg.Node.Network), 1)
|
ncutils.PrintLog(fmt.Sprintf("failed to leave, please check that local files for network %s were removed", cfg.Node.Network), 1)
|
||||||
}
|
}
|
||||||
|
ncutils.PrintLog(fmt.Sprintf("%s was removed", cfg.Node.Name), 1)
|
||||||
|
return
|
||||||
|
case models.NODE_UPDATE_KEY:
|
||||||
|
if err := UpdateKeys(&cfg, client); err != nil {
|
||||||
|
ncutils.PrintLog("err updating wireguard keys: "+err.Error(), 1)
|
||||||
|
}
|
||||||
|
case models.NODE_NOOP:
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
ncutils.PrintLog(fmt.Sprintf("%s was removed", cfg.Node.Name), 1)
|
ncutils.PrintLog(fmt.Sprintf("%s was removed", cfg.Node.Name), 1)
|
||||||
return
|
return
|
||||||
|
@ -462,10 +470,14 @@ func UpdateKeys(cfg *config.ClientConfig, client mqtt.Client) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cfg.Node.PublicKey = key.PublicKey().String()
|
cfg.Node.PublicKey = key.PublicKey().String()
|
||||||
PublishNodeUpdate(cfg)
|
|
||||||
if err := config.ModConfig(&cfg.Node); err != nil {
|
if err := config.ModConfig(&cfg.Node); err != nil {
|
||||||
ncutils.Log("error updating local config " + err.Error())
|
ncutils.Log("error updating local config " + err.Error())
|
||||||
}
|
}
|
||||||
|
PublishNodeUpdate(cfg)
|
||||||
|
if err = wireguard.ApplyConf(&cfg.Node, cfg.Node.Interface, file); err != nil {
|
||||||
|
ncutils.Log("error applying new config " + err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue