Skip to content

Commit

Permalink
add list wg ports endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Eslam-Nawara committed Oct 8, 2024
1 parent 5450038 commit 3d74a0a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
7 changes: 3 additions & 4 deletions pkg/gridtypes/zos/network_light.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ func NetworkIDFromWorkloadID(wl gridtypes.WorkloadID) (NetID, error) {
// - For each PC or a laptop (for each wireguard peer) there must be a peer in the peer list (on all nodes)
// This is why this can get complicated.
type NetworkLight struct {
// IP range of the network, must be an IPv4 /16
// for example a 10.1.0.0/16
NetworkIPRange gridtypes.IPNet `json:"ip_range"`

// IPV4 subnet for this network resource
// this must be a valid subnet of the entire network ip range.
// for example 10.1.1.0/24
Expand All @@ -70,6 +66,9 @@ type NetworkLight struct {
// get mycelium IPs.
Mycelium Mycelium `json:"mycelium,omitempty"`

// IP range of the network, must be an IPv4 /16
// for example a 10.1.0.0/16
NetworkIPRange gridtypes.IPNet `json:"ip_range"`
// The private wg key of this node (this peer) which is installing this
// network workload right now.
// This has to be filled in by the user (and not generated for example)
Expand Down
2 changes: 1 addition & 1 deletion pkg/netlight/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func (r *Resource) HasWireguard() (bool, error) {

// Namespace returns the name of the network namespace to create for the network resource
func (r *Resource) Namespace() (string, error) {
name := fmt.Sprintf("n-%s", r.name)
name := fmt.Sprintf("n%s", r.name)
if len(name) > 15 {
return "", errors.Errorf("network namespace too long %s", name)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/zos_api/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"github.com/threefoldtech/zos/pkg/gridtypes"
)

func (g *ZosAPI) networkListWGPortsHandler(ctx context.Context, payload []byte) (interface{}, error) {
return g.networkerLightStub.WireguardPorts(ctx)
}

func (g *ZosAPI) networkInterfacesHandler(ctx context.Context, payload []byte) (interface{}, error) {
results := make(map[string][]net.IPNet)
interfaces, err := g.networkerLightStub.Interfaces(ctx, "zos", "")
Expand Down
3 changes: 1 addition & 2 deletions pkg/zos_api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
)

func (g *ZosAPI) SetupRoutes(router *peer.Router) {

root := router.SubRoute("zos")
root.Use(g.log)
system := root.SubRoute("system")
Expand All @@ -26,7 +25,7 @@ func (g *ZosAPI) SetupRoutes(router *peer.Router) {
storage.WithHandler("pools", g.storagePoolsHandler)

network := root.SubRoute("network")
// network.WithHandler("list_wg_ports", g.networkListWGPortsHandler)
network.WithHandler("list_wg_ports", g.networkListWGPortsHandler)
// network.WithHandler("public_config_get", g.networkPublicConfigGetHandler)
network.WithHandler("interfaces", g.networkInterfacesHandler)
network.WithHandler("has_ipv6", g.networkHasIPv6Handler)
Expand Down

0 comments on commit 3d74a0a

Please sign in to comment.