leave comms automatically if last network

This commit is contained in:
afeiszli 2022-02-21 08:47:47 -05:00
parent 49b29a6615
commit f5c8f6ed22

View file

@ -95,6 +95,13 @@ func Leave(cfg config.ClientConfig, force bool) error {
} else {
ncutils.PrintLog("success", 0)
}
nets, err := ncutils.GetSystemNetworks()
if err == nil && len(nets) == 1 {
if nets[0] == cfg.Node.CommID {
ncutils.PrintLog("detected comms as remaining network, removing...", 1)
err = functions.LeaveNetwork(nets[0], true)
}
}
return err
}