2023-01-21 00:37:26 +02:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/DataDrake/cli-ng/v2/cmd"
|
|
|
|
"github.com/hyprspace/hyprspace/rpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
var Status = cmd.Sub{
|
|
|
|
Name: "status",
|
|
|
|
Alias: "s",
|
|
|
|
Short: "Display Hyprspace daemon status",
|
|
|
|
Run: StatusRun,
|
|
|
|
}
|
|
|
|
|
|
|
|
func StatusRun(r *cmd.Root, c *cmd.Sub) {
|
2023-03-24 17:36:13 +02:00
|
|
|
ifName := r.Flags.(*GlobalFlags).InterfaceName
|
|
|
|
if ifName == "" {
|
|
|
|
ifName = "hyprspace"
|
|
|
|
}
|
2023-01-21 00:37:26 +02:00
|
|
|
|
2023-03-24 17:36:13 +02:00
|
|
|
status := rpc.Status(ifName)
|
2023-01-21 00:37:26 +02:00
|
|
|
fmt.Println("PeerID:", status.PeerID)
|
|
|
|
fmt.Println("Swarm peers:", status.SwarmPeersCurrent)
|
|
|
|
fmt.Printf("Connected VPN nodes: %d/%d\n", status.NetPeersCurrent, status.NetPeersMax)
|
|
|
|
printList(status.NetPeerAddrsCurrent)
|
|
|
|
fmt.Println("Addresses:")
|
|
|
|
printList(status.ListenAddrs)
|
|
|
|
}
|