sync always

This commit is contained in:
0xdcarns 2022-01-31 11:29:00 -05:00
parent 3aaf83d04d
commit c621f6c2d6

View file

@ -275,22 +275,22 @@ func UpdatePeers(client mqtt.Client, msg mqtt.Message) {
insert(peerUpdate.Network, lastPeerUpdate, string(data)) insert(peerUpdate.Network, lastPeerUpdate, string(data))
ncutils.Log("update peer handler") ncutils.Log("update peer handler")
file := ncutils.GetNetclientPathSpecific() + cfg.Node.Interface + ".conf"
var shouldReSub = shouldResub(cfg.Node.NetworkSettings.DefaultServerAddrs, peerUpdate.ServerAddrs) var shouldReSub = shouldResub(cfg.Node.NetworkSettings.DefaultServerAddrs, peerUpdate.ServerAddrs)
if shouldReSub { if shouldReSub {
Resubscribe(client, &cfg) Resubscribe(client, &cfg)
cfg.Node.NetworkSettings.DefaultServerAddrs = peerUpdate.ServerAddrs cfg.Node.NetworkSettings.DefaultServerAddrs = peerUpdate.ServerAddrs
file := ncutils.GetNetclientPathSpecific() + cfg.Node.Interface + ".conf" }
err = wireguard.UpdateWgPeers(file, peerUpdate.Peers) err = wireguard.UpdateWgPeers(file, peerUpdate.Peers)
if err != nil { if err != nil {
ncutils.Log("error updating wireguard peers" + err.Error()) ncutils.Log("error updating wireguard peers" + err.Error())
return return
} }
ncutils.Log("syncing conf to " + file) ncutils.Log("syncing conf to " + file)
err = wireguard.SyncWGQuickConf(cfg.Node.Interface, file) err = wireguard.SyncWGQuickConf(cfg.Node.Interface, file)
if err != nil { if err != nil {
ncutils.Log("error syncing wg after peer update " + err.Error()) ncutils.Log("error syncing wg after peer update " + err.Error())
return return
}
} }
}() }()
} }