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{
|
var Peers = cmd.Sub{
|
||||||
Name: "peers",
|
Name: "peers",
|
||||||
Short: "List peer connections",
|
Short: "List peer connections",
|
||||||
Args: &PeersArgs{},
|
|
||||||
Run: PeersRun,
|
Run: PeersRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
type PeersArgs struct {
|
|
||||||
InterfaceName string
|
|
||||||
}
|
|
||||||
|
|
||||||
func PeersRun(r *cmd.Root, c *cmd.Sub) {
|
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 {
|
for _, ma := range peers.PeerAddrs {
|
||||||
fmt.Println(ma)
|
fmt.Println(ma)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@ var appVersion string = "develop"
|
||||||
|
|
||||||
// GlobalFlags contains the flags for commands.
|
// GlobalFlags contains the flags for commands.
|
||||||
type GlobalFlags struct {
|
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.
|
// Root is the main command.
|
||||||
|
|
|
@ -11,19 +11,16 @@ var Status = cmd.Sub{
|
||||||
Name: "status",
|
Name: "status",
|
||||||
Alias: "s",
|
Alias: "s",
|
||||||
Short: "Display Hyprspace daemon status",
|
Short: "Display Hyprspace daemon status",
|
||||||
Args: &StatusArgs{},
|
|
||||||
Run: StatusRun,
|
Run: StatusRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
type StatusArgs struct {
|
|
||||||
InterfaceName string
|
|
||||||
}
|
|
||||||
|
|
||||||
func StatusRun(r *cmd.Root, c *cmd.Sub) {
|
func StatusRun(r *cmd.Root, c *cmd.Sub) {
|
||||||
// Parse Command Args
|
ifName := r.Flags.(*GlobalFlags).InterfaceName
|
||||||
args := c.Args.(*StatusArgs)
|
if ifName == "" {
|
||||||
|
ifName = "hyprspace"
|
||||||
|
}
|
||||||
|
|
||||||
status := rpc.Status(args.InterfaceName)
|
status := rpc.Status(ifName)
|
||||||
fmt.Println("PeerID:", status.PeerID)
|
fmt.Println("PeerID:", status.PeerID)
|
||||||
fmt.Println("Swarm peers:", status.SwarmPeersCurrent)
|
fmt.Println("Swarm peers:", status.SwarmPeersCurrent)
|
||||||
fmt.Printf("Connected VPN nodes: %d/%d\n", status.NetPeersCurrent, status.NetPeersMax)
|
fmt.Printf("Connected VPN nodes: %d/%d\n", status.NetPeersCurrent, status.NetPeersMax)
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
};
|
};
|
||||||
packages.hyprspace = with pkgs; buildGo119Module {
|
packages.hyprspace = with pkgs; buildGo119Module {
|
||||||
pname = "hyprspace";
|
pname = "hyprspace";
|
||||||
version = "0.6.1";
|
version = "0.6.2";
|
||||||
|
|
||||||
src = with inputs.nix-filter.lib; let
|
src = with inputs.nix-filter.lib; let
|
||||||
dirs = map inDirectory;
|
dirs = map inDirectory;
|
||||||
|
|
Loading…
Reference in a new issue