diff --git a/controllers/node.go b/controllers/node.go index d0a77ce75..2ff0456c9 100644 --- a/controllers/node.go +++ b/controllers/node.go @@ -645,6 +645,17 @@ func updateNode(w http.ResponseWriter, r *http.Request) { } relayUpdate := logic.RelayUpdates(¤tNode, newNode) + if relayUpdate && newNode.IsRelay { + err = logic.ValidateRelay(models.RelayRequest{ + NodeID: newNode.ID.String(), + NetID: newNode.Network, + RelayedNodes: newNode.RelayedNodes, + }) + if err != nil { + logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest")) + return + } + } _, err = logic.GetHost(newNode.HostID.String()) if err != nil { logger.Log(0, r.Header.Get("user"), diff --git a/logic/relay.go b/logic/relay.go index 181cf5114..225c77dc8 100644 --- a/logic/relay.go +++ b/logic/relay.go @@ -28,3 +28,7 @@ var SetRelayedNodes = func(setRelayed bool, relay string, relayed []string) []mo var RelayUpdates = func(currentNode, newNode *models.Node) bool { return false } + +var ValidateRelay = func(relay models.RelayRequest) error { + return nil +} diff --git a/pro/initialize.go b/pro/initialize.go index 2c06d3bb6..13e2bfaa6 100644 --- a/pro/initialize.go +++ b/pro/initialize.go @@ -101,6 +101,7 @@ func InitPro() { logic.UpdateRelayed = proLogic.UpdateRelayed logic.SetRelayedNodes = proLogic.SetRelayedNodes logic.RelayUpdates = proLogic.RelayUpdates + logic.ValidateRelay = proLogic.ValidateRelay logic.GetTrialEndDate = getTrialEndDate logic.SetDefaultGw = proLogic.SetDefaultGw logic.SetDefaultGwForRelayedUpdate = proLogic.SetDefaultGwForRelayedUpdate diff --git a/pro/logic/relays.go b/pro/logic/relays.go index 09e56dc0b..6be0c8a78 100644 --- a/pro/logic/relays.go +++ b/pro/logic/relays.go @@ -119,6 +119,9 @@ func ValidateRelay(relay models.RelayRequest) error { if relayedNode.IsIngressGateway { return errors.New("cannot relay an ingress gateway (" + relayedNodeID + ")") } + if relayedNode.IsInternetGateway { + return errors.New("cannot relay an internet gateway (" + relayedNodeID + ")") + } } return err }