mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-19 21:29:09 +02:00
Fix status and up cli output
This commit is contained in:
+24
-4
@@ -100,10 +100,30 @@ func statusFunc(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if resp.GetFullStatus() == nil {
|
||||
cmd.Printf("Daemon status: %s\n"+
|
||||
"Daemon version: %s\nCLI version: %s\n\n"+
|
||||
"Detailed status is unavailable: the connection belongs to another user.\n",
|
||||
status, resp.GetDaemonVersion(), version.NetbirdVersion())
|
||||
output := nbstatus.OutputOverview{
|
||||
DaemonVersion: resp.GetDaemonVersion(),
|
||||
CliVersion: version.NetbirdVersion(),
|
||||
DaemonStatus: nbstatus.DaemonStatus(status),
|
||||
}
|
||||
var outputString string
|
||||
var err error
|
||||
switch {
|
||||
case jsonFlag:
|
||||
outputString, err = output.JSON()
|
||||
case yamlFlag:
|
||||
outputString, err = output.YAML()
|
||||
default:
|
||||
outputString = fmt.Sprintf("Daemon status: %s\n"+
|
||||
"Daemon version: %s\nCLI version: %s\n\n"+
|
||||
"Detailed status is unavailable: the connection belongs to another user.\n",
|
||||
status, resp.GetDaemonVersion(), version.NetbirdVersion())
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.Print(outputString)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -338,6 +338,11 @@ func runInDaemonMode(ctx context.Context, cmd *cobra.Command, pm *profilemanager
|
||||
}
|
||||
|
||||
if status.Status == string(internal.StatusConnected) {
|
||||
if status.GetFullStatus() == nil {
|
||||
cmd.Println("Already connected and the connection belongs to another user.")
|
||||
cmd.Println("Run 'netbird down' as a privileged user to be able to claim the session with this user.")
|
||||
return nil
|
||||
}
|
||||
if !profileSwitched {
|
||||
cmd.Println("Already connected")
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user