Few refactorings of managing the mesh and a graph

visualisation tool for seeing the state of a mesh.
This commit is contained in:
Tim Beatham
2023-10-22 13:34:49 +01:00
parent c4dc984fc7
commit 360f9d3c54
11 changed files with 288 additions and 15 deletions

View File

@@ -87,6 +87,19 @@ func enableInterface(client *ipcRpc.Client, meshId string) {
fmt.Println(reply)
}
func getGraph(client *ipcRpc.Client, meshId string) {
var reply string
err := client.Call("RobinIpc.GetDOT", &meshId, &reply)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(reply)
}
func main() {
parser := argparse.NewParser("wg-mesh",
"wg-mesh Manipulate WireGuard meshes")
@@ -96,12 +109,13 @@ func main() {
joinMeshCmd := parser.NewCommand("join-mesh", "Join a mesh network")
getMeshCmd := parser.NewCommand("get-mesh", "Get a mesh network")
enableInterfaceCmd := parser.NewCommand("enable-interface", "Enable A Specific Mesh Interface")
getGraphCmd := parser.NewCommand("get-graph", "Convert a mesh into DOT format")
var meshId *string = joinMeshCmd.String("m", "mesh", &argparse.Options{Required: true})
var ipAddress *string = joinMeshCmd.String("i", "ip", &argparse.Options{Required: true})
var getMeshId *string = getMeshCmd.String("m", "mesh", &argparse.Options{Required: true})
var enableInterfaceMeshId *string = enableInterfaceCmd.String("m", "mesh", &argparse.Options{Required: true})
var getGraphMeshId *string = getGraphCmd.String("m", "mesh", &argparse.Options{Required: true})
err := parser.Parse(os.Args)
@@ -132,6 +146,10 @@ func main() {
getMesh(client, *getMeshId)
}
if getGraphCmd.Happened() {
getGraph(client, *getGraphMeshId)
}
if enableInterfaceCmd.Happened() {
enableInterface(client, *enableInterfaceMeshId)
}