Skip to content

Commit 3d74a0a

Browse files
committed
add list wg ports endpoint
1 parent 5450038 commit 3d74a0a

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

pkg/gridtypes/zos/network_light.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ func NetworkIDFromWorkloadID(wl gridtypes.WorkloadID) (NetID, error) {
5555
// - For each PC or a laptop (for each wireguard peer) there must be a peer in the peer list (on all nodes)
5656
// This is why this can get complicated.
5757
type NetworkLight struct {
58-
// IP range of the network, must be an IPv4 /16
59-
// for example a 10.1.0.0/16
60-
NetworkIPRange gridtypes.IPNet `json:"ip_range"`
61-
6258
// IPV4 subnet for this network resource
6359
// this must be a valid subnet of the entire network ip range.
6460
// for example 10.1.1.0/24
@@ -70,6 +66,9 @@ type NetworkLight struct {
7066
// get mycelium IPs.
7167
Mycelium Mycelium `json:"mycelium,omitempty"`
7268

69+
// IP range of the network, must be an IPv4 /16
70+
// for example a 10.1.0.0/16
71+
NetworkIPRange gridtypes.IPNet `json:"ip_range"`
7372
// The private wg key of this node (this peer) which is installing this
7473
// network workload right now.
7574
// This has to be filled in by the user (and not generated for example)

pkg/netlight/resource/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ func (r *Resource) HasWireguard() (bool, error) {
490490

491491
// Namespace returns the name of the network namespace to create for the network resource
492492
func (r *Resource) Namespace() (string, error) {
493-
name := fmt.Sprintf("n-%s", r.name)
493+
name := fmt.Sprintf("n%s", r.name)
494494
if len(name) > 15 {
495495
return "", errors.Errorf("network namespace too long %s", name)
496496
}

pkg/zos_api/network.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
"github.com/threefoldtech/zos/pkg/gridtypes"
1111
)
1212

13+
func (g *ZosAPI) networkListWGPortsHandler(ctx context.Context, payload []byte) (interface{}, error) {
14+
return g.networkerLightStub.WireguardPorts(ctx)
15+
}
16+
1317
func (g *ZosAPI) networkInterfacesHandler(ctx context.Context, payload []byte) (interface{}, error) {
1418
results := make(map[string][]net.IPNet)
1519
interfaces, err := g.networkerLightStub.Interfaces(ctx, "zos", "")

pkg/zos_api/routes.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
)
66

77
func (g *ZosAPI) SetupRoutes(router *peer.Router) {
8-
98
root := router.SubRoute("zos")
109
root.Use(g.log)
1110
system := root.SubRoute("system")
@@ -26,7 +25,7 @@ func (g *ZosAPI) SetupRoutes(router *peer.Router) {
2625
storage.WithHandler("pools", g.storagePoolsHandler)
2726

2827
network := root.SubRoute("network")
29-
// network.WithHandler("list_wg_ports", g.networkListWGPortsHandler)
28+
network.WithHandler("list_wg_ports", g.networkListWGPortsHandler)
3029
// network.WithHandler("public_config_get", g.networkPublicConfigGetHandler)
3130
network.WithHandler("interfaces", g.networkInterfacesHandler)
3231
network.WithHandler("has_ipv6", g.networkHasIPv6Handler)

0 commit comments

Comments
 (0)