瀏覽代碼

leave comms automatically if last network

afeiszli 3 年之前
父節點
當前提交
f5c8f6ed22
共有 1 個文件被更改,包括 7 次插入0 次删除
  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 {
 		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
 }