diff --git a/griddriver/main.go b/griddriver/main.go index b1af3d843..ddd0ffc3f 100644 --- a/griddriver/main.go +++ b/griddriver/main.go @@ -450,6 +450,20 @@ func main() { return generateWgPrivKey() }, }, + { + Name: "generate-wg-public-key", + Usage: "Generates wireguard public key", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "key", + Usage: "wireguard private key", + Required: true, + }, + }, + Action: func(c *cli.Context) error { + return generateWgPublicKey(c) + }, + }, { Name: "rmb", Usage: "Make RMB call", diff --git a/griddriver/network.go b/griddriver/network.go index 4db35a79b..50edbc98b 100644 --- a/griddriver/network.go +++ b/griddriver/network.go @@ -74,15 +74,15 @@ func deployVM() cli.ActionFunc { } func buildNetwork(name, solutionType string, nodes []uint32) workloads.ZNet { - return workloads.ZNet{ - Name: name, - Nodes: nodes, - IPRange: gridtypes.NewIPNet(net.IPNet{ - IP: net.IPv4(10, 20, 0, 0), - Mask: net.CIDRMask(16, 32), - }), - SolutionType: solutionType, - } + return workloads.ZNet{ + Name: name, + Nodes: nodes, + IPRange: gridtypes.NewIPNet(net.IPNet{ + IP: net.IPv4(10, 20, 0, 0), + Mask: net.CIDRMask(16, 32), + }), + SolutionType: solutionType, + } } func generateWgPrivKey() error { @@ -95,3 +95,15 @@ func generateWgPrivKey() error { return nil } + +func generateWgPublicKey(ctx *cli.Context) error { + keyStr := ctx.String("key") + key, err := wgtypes.ParseKey(keyStr) + if err != nil { + return fmt.Errorf("failed to parse private key: %w", err) + } + + fmt.Printf("%s", key.PublicKey().String()) + return nil + +} diff --git a/griddriver/rmb.go b/griddriver/rmb.go index 69aa5f386..9e81381b3 100644 --- a/griddriver/rmb.go +++ b/griddriver/rmb.go @@ -144,7 +144,7 @@ func nodeTakenPorts(c *cli.Context, client *peer.RpcClient) (interface{}, error) dst := uint32(c.Uint("dst")) var takenPorts []uint16 - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) defer cancel() if err := client.Call(ctx, dst, "zos.network.list_wg_ports", nil, &takenPorts); err != nil { @@ -172,6 +172,6 @@ func getNodePublicConfig(c *cli.Context, client *peer.RpcClient) (interface{}, e if err != nil { return nil, fmt.Errorf("failed to marshal public configuration: %w", err) } - fmt.Println(string(json)) + return string(json), nil }