Browse Source

leave comms automatically if last network

afeiszli 3 years ago
parent
commit
f5c8f6ed22
1 changed files with 7 additions and 0 deletions
  1. 7 0
      netclient/command/commands.go

+ 7 - 0
netclient/command/commands.go

@@ -95,6 +95,13 @@ func Leave(cfg config.ClientConfig, force bool) error {
 	} else {
 	} else {
 		ncutils.PrintLog("success", 0)
 		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
 	return err
 }
 }