2023-09-18 13:59:28 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-09-18 16:52:28 +02:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/akamensky/argparse"
|
|
|
|
meshtypes "github.com/tim-beatham/wgmesh/pkg/wg-mesh"
|
2023-09-18 13:59:28 +02:00
|
|
|
)
|
|
|
|
|
2023-09-18 16:52:28 +02:00
|
|
|
func main() {
|
|
|
|
parser := argparse.NewParser("wg-mesh",
|
|
|
|
"wg-mesh Manipulate WireGuard meshes")
|
|
|
|
|
|
|
|
newMeshCmd := parser.NewCommand("new-mesh", "Create a new mesh")
|
|
|
|
err := parser.Parse(os.Args)
|
2023-09-18 13:59:28 +02:00
|
|
|
|
2023-09-18 16:52:28 +02:00
|
|
|
if err != nil {
|
|
|
|
fmt.Print(parser.Usage(err))
|
|
|
|
return
|
|
|
|
}
|
2023-09-18 13:59:28 +02:00
|
|
|
|
2023-09-18 16:52:28 +02:00
|
|
|
if newMeshCmd.Happened() {
|
|
|
|
mesh, err := meshtypes.NewWgMesh()
|
2023-09-18 13:59:28 +02:00
|
|
|
|
2023-09-18 16:52:28 +02:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Could not generate new WgMesh")
|
|
|
|
} else {
|
|
|
|
fmt.Println(mesh.SharedKey.String())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|