mirror of
https://github.com/hyprspace/hyprspace.git
synced 2026-09-14 11:06:22 +05:00
cli: add hyprspace tui subcommand with interactive dashboard
Adds a read-only TUI dashboard that polls the existing RPC socket every 2s and displays state in three tabbed views (Status, Peers, Routes). - cli/tui.go: subcommand registration + all TUI logic (~246 lines) - Status tab: peer ID, swarm count, VPN nodes, listen addresses - Peers tab: table of connected peers (name, latency, multiaddr) - Routes tab: table of routes (network, target, relay, connected status) - Navigation: Tab/Shift+Tab, quit with q/Esc/Ctrl+C - rpc/client.go: add TryStatus/TryRoute/TryPeers (return error instead of log.Fatal) - cli/root.go: register TUI subcommand - go.mod/go.sum: add github.com/rivo/tview dependency
This commit is contained in:
parent
7e03fcc1d5
commit
4f032e1749
@ -35,6 +35,7 @@ func init() {
|
||||
cmd.Register(&Status)
|
||||
cmd.Register(&Peers)
|
||||
cmd.Register(&Route)
|
||||
cmd.Register(&TUI)
|
||||
cmd.Register(&cmd.Version)
|
||||
}
|
||||
|
||||
|
||||
267
cli/tui.go
Normal file
267
cli/tui.go
Normal file
@ -0,0 +1,267 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/DataDrake/cli-ng/v2/cmd"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
|
||||
"github.com/hyprspace/hyprspace/rpc"
|
||||
)
|
||||
|
||||
const pollInterval = 2 * time.Second
|
||||
|
||||
var tabs = []struct {
|
||||
id string
|
||||
title string
|
||||
}{
|
||||
{"status", "Status"},
|
||||
{"peers", "Peers"},
|
||||
{"routes", "Routes"},
|
||||
}
|
||||
|
||||
// TUI starts the interactive TUI dashboard.
|
||||
var TUI = cmd.Sub{
|
||||
Name: "tui",
|
||||
Short: "Interactive TUI dashboard for monitoring Hyprspace",
|
||||
Run: TUIRun,
|
||||
}
|
||||
|
||||
func TUIRun(r *cmd.Root, c *cmd.Sub) {
|
||||
ifName := r.Flags.(*GlobalFlags).InterfaceName
|
||||
if ifName == "" {
|
||||
ifName = "hyprspace"
|
||||
}
|
||||
runTUI(ifName)
|
||||
}
|
||||
|
||||
// runTUI starts the TUI dashboard application. It blocks until the user quits.
|
||||
func runTUI(ifName string) {
|
||||
app := tview.NewApplication()
|
||||
pages := tview.NewPages()
|
||||
|
||||
navBar := tview.NewTextView()
|
||||
navBar.SetDynamicColors(true)
|
||||
navBar.SetTextAlign(tview.AlignCenter)
|
||||
navBar.SetTextStyle(tcell.StyleDefault.Background(tcell.ColorDarkSlateGray))
|
||||
|
||||
statusView := tview.NewTextView()
|
||||
statusView.SetDynamicColors(true)
|
||||
statusView.SetWordWrap(true)
|
||||
statusView.SetScrollable(true)
|
||||
statusView.SetBorder(true)
|
||||
statusView.SetTitle(" Status ")
|
||||
|
||||
peersTable := tview.NewTable()
|
||||
peersTable.SetBorders(false)
|
||||
peersTable.SetSelectable(false, false)
|
||||
peersTable.SetBorder(true)
|
||||
peersTable.SetTitle(" Peers ")
|
||||
|
||||
routesTable := tview.NewTable()
|
||||
routesTable.SetBorders(false)
|
||||
routesTable.SetSelectable(false, false)
|
||||
routesTable.SetBorder(true)
|
||||
routesTable.SetTitle(" Routes ")
|
||||
|
||||
pages.AddPage("status", statusView, true, true)
|
||||
pages.AddPage("peers", peersTable, true, false)
|
||||
pages.AddPage("routes", routesTable, true, false)
|
||||
|
||||
currentTab := 0
|
||||
updateNavBar(navBar, currentTab)
|
||||
|
||||
flex := tview.NewFlex().SetDirection(tview.FlexRow).
|
||||
AddItem(navBar, 1, 0, false).
|
||||
AddItem(pages, 0, 1, true)
|
||||
|
||||
app.SetRoot(flex, true)
|
||||
|
||||
switchTab := func(idx int) {
|
||||
if idx < 0 {
|
||||
idx = len(tabs) - 1
|
||||
} else if idx >= len(tabs) {
|
||||
idx = 0
|
||||
}
|
||||
currentTab = idx
|
||||
pages.SwitchToPage(tabs[idx].id)
|
||||
updateNavBar(navBar, idx)
|
||||
}
|
||||
|
||||
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch event.Key() {
|
||||
case tcell.KeyTAB:
|
||||
switchTab(currentTab + 1)
|
||||
return nil
|
||||
case tcell.KeyBacktab:
|
||||
switchTab(currentTab - 1)
|
||||
return nil
|
||||
case tcell.KeyESC:
|
||||
app.Stop()
|
||||
return nil
|
||||
case tcell.KeyCtrlC:
|
||||
app.Stop()
|
||||
return nil
|
||||
}
|
||||
if event.Rune() == 'q' || event.Rune() == 'Q' {
|
||||
app.Stop()
|
||||
return nil
|
||||
}
|
||||
return event
|
||||
})
|
||||
|
||||
// Poll goroutine — immediately fetches, then polls every 2s.
|
||||
go func() {
|
||||
fetchAndUpdate(app, ifName, statusView, peersTable, routesTable)
|
||||
ticker := time.NewTicker(pollInterval)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
fetchAndUpdate(app, ifName, statusView, peersTable, routesTable)
|
||||
}
|
||||
}()
|
||||
|
||||
if err := app.Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func updateNavBar(navBar *tview.TextView, active int) {
|
||||
var b strings.Builder
|
||||
for i, tab := range tabs {
|
||||
if i > 0 {
|
||||
b.WriteString(" ")
|
||||
}
|
||||
if i == active {
|
||||
fmt.Fprintf(&b, "[white:darkcyan] %s ", tab.title)
|
||||
} else {
|
||||
fmt.Fprintf(&b, "[gray:darkolivegreen] %s ", tab.title)
|
||||
}
|
||||
}
|
||||
navBar.SetText(b.String())
|
||||
}
|
||||
|
||||
func fetchAndUpdate(
|
||||
app *tview.Application,
|
||||
ifName string,
|
||||
statusView *tview.TextView,
|
||||
peersTable *tview.Table,
|
||||
routesTable *tview.Table,
|
||||
) {
|
||||
status, err := rpc.TryStatus(ifName)
|
||||
if err != nil {
|
||||
app.QueueUpdateDraw(func() {
|
||||
statusView.Clear()
|
||||
fmt.Fprintf(statusView, "[red]⚠ RPC connection failed: %v[-]\n\n", err)
|
||||
peersTable.Clear()
|
||||
peersTable.SetCell(0, 0, tview.NewTableCell("[gray]No data (RPC unavailable)[-]"))
|
||||
routesTable.Clear()
|
||||
routesTable.SetCell(0, 0, tview.NewTableCell("[gray]No data (RPC unavailable)[-]"))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Fetch routes in the same poll cycle.
|
||||
routeReply, routeErr := rpc.TryRoute(ifName, rpc.RouteArgs{Action: rpc.Show})
|
||||
if routeErr != nil {
|
||||
app.QueueUpdateDraw(func() {
|
||||
statusView.Clear()
|
||||
fmt.Fprintf(statusView, "[red]⚠ RPC route call failed: %v[-]\n\n", routeErr)
|
||||
routesTable.Clear()
|
||||
routesTable.SetCell(0, 0, tview.NewTableCell("[gray]No data (RPC unavailable)[-]"))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
app.QueueUpdateDraw(func() {
|
||||
updateStatusView(statusView, status)
|
||||
updatePeersTable(peersTable, status)
|
||||
updateRoutesTable(routesTable, routeReply)
|
||||
})
|
||||
}
|
||||
|
||||
func updateStatusView(v *tview.TextView, s rpc.StatusReply) {
|
||||
v.Clear()
|
||||
fmt.Fprintf(v, "Peer ID: [yellow]%s[-]\n", s.PeerID)
|
||||
fmt.Fprintf(v, "Swarm Peers: %d\n", s.SwarmPeersCurrent)
|
||||
fmt.Fprintf(v, "VPN Nodes: %d/%d\n", s.NetPeersCurrent, s.NetPeersMax)
|
||||
|
||||
if len(s.ListenAddrs) > 0 {
|
||||
fmt.Fprintf(v, "\nListen Addresses:\n")
|
||||
for _, addr := range s.ListenAddrs {
|
||||
disp := addr
|
||||
if strings.HasSuffix(addr, "/p2p-circuit") || strings.Contains(addr, "/p2p-circuit/p2p/") {
|
||||
disp = "[gray]" + addr + "[-]"
|
||||
}
|
||||
fmt.Fprintf(v, " %s\n", disp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updatePeersTable(t *tview.Table, s rpc.StatusReply) {
|
||||
t.Clear()
|
||||
if len(s.NetPeerAddrsCurrent) == 0 {
|
||||
t.SetCell(0, 0, tview.NewTableCell("[gray]No peers connected.[-]"))
|
||||
return
|
||||
}
|
||||
|
||||
// Header row.
|
||||
t.SetCell(0, 0, tview.NewTableCell("[::b]Name").SetSelectable(false))
|
||||
t.SetCell(0, 1, tview.NewTableCell("[::b]Latency").SetSelectable(false))
|
||||
t.SetCell(0, 2, tview.NewTableCell("[::b]Multiaddr").SetSelectable(false))
|
||||
|
||||
for i, entry := range s.NetPeerAddrsCurrent {
|
||||
row := i + 1
|
||||
name, latency, addr := parsePeerEntry(entry)
|
||||
t.SetCell(row, 0, tview.NewTableCell(name).SetExpansion(0))
|
||||
t.SetCell(row, 1, tview.NewTableCell(latency).SetExpansion(0))
|
||||
t.SetCell(row, 2, tview.NewTableCell(addr).SetExpansion(1))
|
||||
}
|
||||
}
|
||||
|
||||
func updateRoutesTable(t *tview.Table, reply rpc.RouteReply) {
|
||||
t.Clear()
|
||||
if len(reply.Routes) == 0 {
|
||||
t.SetCell(0, 0, tview.NewTableCell("[gray]No routes configured.[-]"))
|
||||
return
|
||||
}
|
||||
|
||||
// Header row.
|
||||
t.SetCell(0, 0, tview.NewTableCell("[::b]Network").SetSelectable(false))
|
||||
t.SetCell(0, 1, tview.NewTableCell("[::b]Target").SetSelectable(false))
|
||||
t.SetCell(0, 2, tview.NewTableCell("[::b]Relay").SetSelectable(false))
|
||||
t.SetCell(0, 3, tview.NewTableCell("[::b]Status").SetSelectable(false))
|
||||
|
||||
for i, r := range reply.Routes {
|
||||
row := i + 1
|
||||
target := r.TargetName
|
||||
if target == "" {
|
||||
target = r.TargetAddr.String()
|
||||
}
|
||||
relay := ""
|
||||
if r.IsRelay {
|
||||
relay = r.RelayAddr.String()
|
||||
}
|
||||
status := "[green]connected[-]"
|
||||
if !r.IsConnected {
|
||||
status = "[red]disconnected[-]"
|
||||
}
|
||||
t.SetCell(row, 0, tview.NewTableCell(r.Network.String()).SetExpansion(0))
|
||||
t.SetCell(row, 1, tview.NewTableCell(target).SetExpansion(1))
|
||||
t.SetCell(row, 2, tview.NewTableCell(relay).SetExpansion(1))
|
||||
t.SetCell(row, 3, tview.NewTableCell(status).SetExpansion(0))
|
||||
}
|
||||
}
|
||||
|
||||
// parsePeerEntry extracts name, latency, and multiaddr from a peer entry string.
|
||||
// Input format: @name (latency) multiaddr/p2p/peerid
|
||||
func parsePeerEntry(s string) (name, latency, addr string) {
|
||||
s = strings.TrimPrefix(s, "@")
|
||||
name, rest, _ := strings.Cut(s, " ")
|
||||
latency, rest, _ = strings.Cut(rest, ") ")
|
||||
latency = strings.TrimLeft(latency, "(")
|
||||
addr = rest
|
||||
return
|
||||
}
|
||||
10
go.mod
10
go.mod
@ -24,9 +24,13 @@ require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dunglas/httpsfv v1.1.0 // indirect
|
||||
github.com/filecoin-project/go-clock v0.1.0 // indirect
|
||||
github.com/gdamore/encoding v1.0.1 // indirect
|
||||
github.com/gdamore/tcell/v2 v2.8.1 // indirect
|
||||
github.com/google/btree v1.1.2 // indirect
|
||||
github.com/libp2p/go-libp2p-routing-helpers v0.7.5 // indirect
|
||||
github.com/libp2p/go-yamux/v5 v5.0.1 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pion/datachannel v1.5.10 // indirect
|
||||
github.com/pion/dtls/v3 v3.1.2 // indirect
|
||||
@ -45,12 +49,18 @@ require (
|
||||
github.com/pion/transport/v4 v4.0.1 // indirect
|
||||
github.com/pion/turn/v4 v4.0.2 // indirect
|
||||
github.com/pion/webrtc/v4 v4.1.2 // indirect
|
||||
<<<<<<< HEAD
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
=======
|
||||
github.com/rivo/tview v0.42.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
>>>>>>> 24dd159 (cli: add hyprspace tui subcommand with interactive dashboard)
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.uber.org/mock v0.5.2 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.4 // indirect
|
||||
golang.org/x/telemetry v0.0.0-20260311193753-579e4da9a98c // indirect
|
||||
golang.org/x/term v0.41.0 // indirect
|
||||
golang.org/x/time v0.12.0 // indirect
|
||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
49
go.sum
49
go.sum
@ -99,6 +99,10 @@ github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwU
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
|
||||
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
|
||||
github.com/gdamore/tcell/v2 v2.8.1 h1:KPNxyqclpWpWQlPLx6Xui1pMk8S+7+R37h3g07997NU=
|
||||
github.com/gdamore/tcell/v2 v2.8.1/go.mod h1:bj8ori1BG3OYMjmb3IklZVWfZUJ1UBQt9JXrOCOhGWw=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
@ -160,6 +164,7 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
@ -296,6 +301,8 @@ github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQsc
|
||||
github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU=
|
||||
github.com/libp2p/go-yamux/v5 v5.0.1 h1:f0WoX/bEF2E8SbE4c/k1Mo+/9z0O4oC/hWEA+nfYRSg=
|
||||
github.com/libp2p/go-yamux/v5 v5.0.1/go.mod h1:en+3cdX51U0ZslwRdRLrvQsdayFt3TSUKvBGErzpWbU=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/marcopolo/simnet v0.0.4 h1:50Kx4hS9kFGSRIbrt9xUS3NJX33EyPqHVmpXvaKLqrY=
|
||||
github.com/marcopolo/simnet v0.0.4/go.mod h1:tfQF1u2DmaB6WHODMtQaLtClEf3a296CKQLq5gAsIS0=
|
||||
@ -305,6 +312,8 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/miekg/dns v1.1.42/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4=
|
||||
github.com/miekg/dns v1.1.72 h1:vhmr+TF2A3tuoGNkLDFK9zi36F2LS+hKTRW0Uf8kbzI=
|
||||
@ -419,6 +428,12 @@ github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SA
|
||||
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
||||
github.com/quic-go/webtransport-go v0.10.0 h1:LqXXPOXuETY5Xe8ITdGisBzTYmUOy5eSj+9n4hLTjHI=
|
||||
github.com/quic-go/webtransport-go v0.10.0/go.mod h1:LeGIXr5BQKE3UsynwVBeQrU1TPrbh73MGoC6jd+V7ow=
|
||||
github.com/rivo/tview v0.42.0 h1:b/ftp+RxtDsHSaynXTbJb+/n/BxDEi+W3UfF5jILK6c=
|
||||
github.com/rivo/tview v0.42.0/go.mod h1:cSfIYfhpSGCjp3r/ECJb+GKS7cGJnqV8vfjQPwoXyfY=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
@ -535,6 +550,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
|
||||
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@ -577,6 +595,9 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI=
|
||||
golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@ -619,6 +640,10 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
|
||||
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@ -646,6 +671,10 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@ -700,14 +729,27 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
||||
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/telemetry v0.0.0-20260311193753-579e4da9a98c h1:6a8FdnNk6bTXBjR4AGKFgUKuo+7GnR3FX5L7CbveeZc=
|
||||
golang.org/x/telemetry v0.0.0-20260311193753-579e4da9a98c/go.mod h1:TpUTTEp9frx7rTdLpC9gFG9kdI7zVLFTFFlqaH2Cncw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||
golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU=
|
||||
golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@ -718,6 +760,11 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
|
||||
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
@ -780,6 +827,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/tools v0.43.0 h1:12BdW9CeB3Z+J/I/wj34VMl8X+fEXBxVR90JeMX5E7s=
|
||||
golang.org/x/tools v0.43.0/go.mod h1:uHkMso649BX2cZK6+RpuIPXS3ho2hZo4FVwfoy1vIk0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@ -40,3 +40,39 @@ func Route(ifname string, args RouteArgs) RouteReply {
|
||||
}
|
||||
return reply
|
||||
}
|
||||
|
||||
func TryStatus(ifname string) (StatusReply, error) {
|
||||
client, err := rpc.Dial("unix", fmt.Sprintf("/run/hyprspace-rpc.%s.sock", ifname))
|
||||
if err != nil {
|
||||
return StatusReply{}, err
|
||||
}
|
||||
var reply StatusReply
|
||||
if err := client.Call("HyprspaceRPC.Status", new(Args), &reply); err != nil {
|
||||
return StatusReply{}, err
|
||||
}
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func TryPeers(ifname string) (PeersReply, error) {
|
||||
client, err := rpc.Dial("unix", fmt.Sprintf("/run/hyprspace-rpc.%s.sock", ifname))
|
||||
if err != nil {
|
||||
return PeersReply{}, err
|
||||
}
|
||||
var reply PeersReply
|
||||
if err := client.Call("HyprspaceRPC.Peers", new(Args), &reply); err != nil {
|
||||
return PeersReply{}, err
|
||||
}
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func TryRoute(ifname string, args RouteArgs) (RouteReply, error) {
|
||||
client, err := rpc.Dial("unix", fmt.Sprintf("/run/hyprspace-rpc.%s.sock", ifname))
|
||||
if err != nil {
|
||||
return RouteReply{}, err
|
||||
}
|
||||
var reply RouteReply
|
||||
if err := client.Call("HyprspaceRPC.Route", args, &reply); err != nil {
|
||||
return RouteReply{}, err
|
||||
}
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user