handler for KeyUpdate was missing a call to apply new wireguard conf

This commit is contained in:
Matthew R. Kasun
2022-02-08 13:35:17 -05:00
committed by 0xdcarns
parent 4ffbbf128a
commit a4da05117e

View File

@@ -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
} }