packages/hyprspace: add --interface, implement for commands: peers, status
This commit is contained in:
parent
9358527fb5
commit
6826ac254d
4 changed files with 13 additions and 17 deletions
|
@ -10,18 +10,16 @@ import (
|
|||
var Peers = cmd.Sub{
|
||||
Name: "peers",
|
||||
Short: "List peer connections",
|
||||
Args: &PeersArgs{},
|
||||
Run: PeersRun,
|
||||
}
|
||||
|
||||
type PeersArgs struct {
|
||||
InterfaceName string
|
||||
}
|
||||
|
||||
func PeersRun(r *cmd.Root, c *cmd.Sub) {
|
||||
args := c.Args.(*PeersArgs)
|
||||
ifName := r.Flags.(*GlobalFlags).InterfaceName
|
||||
if ifName == "" {
|
||||
ifName = "hyprspace"
|
||||
}
|
||||
|
||||
peers := rpc.Peers(args.InterfaceName)
|
||||
peers := rpc.Peers(ifName)
|
||||
for _, ma := range peers.PeerAddrs {
|
||||
fmt.Println(ma)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ var appVersion string = "develop"
|
|||
|
||||
// GlobalFlags contains the flags for commands.
|
||||
type GlobalFlags struct {
|
||||
Config string `short:"c" long:"config" desc:"Specify a custom config path."`
|
||||
Config string `short:"c" long:"config" desc:"Specify a custom config path."`
|
||||
InterfaceName string `short:"i" long:"interface" desc:"Interface name."`
|
||||
}
|
||||
|
||||
// Root is the main command.
|
||||
|
|
|
@ -11,19 +11,16 @@ var Status = cmd.Sub{
|
|||
Name: "status",
|
||||
Alias: "s",
|
||||
Short: "Display Hyprspace daemon status",
|
||||
Args: &StatusArgs{},
|
||||
Run: StatusRun,
|
||||
}
|
||||
|
||||
type StatusArgs struct {
|
||||
InterfaceName string
|
||||
}
|
||||
|
||||
func StatusRun(r *cmd.Root, c *cmd.Sub) {
|
||||
// Parse Command Args
|
||||
args := c.Args.(*StatusArgs)
|
||||
ifName := r.Flags.(*GlobalFlags).InterfaceName
|
||||
if ifName == "" {
|
||||
ifName = "hyprspace"
|
||||
}
|
||||
|
||||
status := rpc.Status(args.InterfaceName)
|
||||
status := rpc.Status(ifName)
|
||||
fmt.Println("PeerID:", status.PeerID)
|
||||
fmt.Println("Swarm peers:", status.SwarmPeersCurrent)
|
||||
fmt.Printf("Connected VPN nodes: %d/%d\n", status.NetPeersCurrent, status.NetPeersMax)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
};
|
||||
packages.hyprspace = with pkgs; buildGo119Module {
|
||||
pname = "hyprspace";
|
||||
version = "0.6.1";
|
||||
version = "0.6.2";
|
||||
|
||||
src = with inputs.nix-filter.lib; let
|
||||
dirs = map inDirectory;
|
||||
|
|
Loading…
Reference in a new issue