mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2025-08-19 09:21:29 +02:00
Few refactorings of managing the mesh and a graph
visualisation tool for seeing the state of a mesh.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user