Skip to content

Commit

Permalink
Merge pull request #793 from gravitl/NET-1154
Browse files Browse the repository at this point in the history
NET-1154:update nodes in config after host deletion or leave server to avoid z…
  • Loading branch information
abhishek9686 authored May 31, 2024
2 parents 48279ed + eea4da4 commit e131850
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ func DeleteServerHostPeerCfg() {
netclient.HostPeers = []wgtypes.PeerConfig{}
}

// DeleteClientNodes - delete the nodes in client config
func DeleteClientNodes() {
netclientCfgMutex.Lock()
defer netclientCfgMutex.Unlock()
netclient.Nodes = []string{}
}

// RemoveServerHostPeerCfg - sets remove flag for all peers on the given server peers
func RemoveServerHostPeerCfg() {
netclient := Netclient()
Expand Down
1 change: 1 addition & 0 deletions functions/mqhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func HostUpdate(client mqtt.Client, msg mqtt.Message) {
deleteHostCfg(client, serverName)
config.WriteNodeConfig()
config.WriteServerConfig()
config.DeleteClientNodes()
restartDaemon = true
case models.UpdateHost:
resetInterface, restartDaemon, sendHostUpdate = config.UpdateHost(&hostUpdate.Host)
Expand Down
1 change: 1 addition & 0 deletions functions/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func LeaveServer(s string) error {
config.DeleteServerHostPeerCfg()
config.DeleteServer(server.Name)
config.DeleteNodes()
config.DeleteClientNodes()
config.WriteServerConfig()
config.WriteNodeConfig()
config.WriteNetclientConfig()
Expand Down

0 comments on commit e131850

Please sign in to comment.