add ability to set failover nodes

This commit is contained in:
afeiszli 2022-09-27 14:04:28 -04:00
parent 29ce2fa57a
commit 54258bcbac
2 changed files with 6 additions and 3 deletions

View file

@ -754,9 +754,10 @@ func deleteEgressGateway(w http.ResponseWriter, r *http.Request) {
func createIngressGateway(w http.ResponseWriter, r *http.Request) {
var params = mux.Vars(r)
w.Header().Set("Content-Type", "application/json")
failover := r.Header.Get("failover") == "yes"
nodeid := params["nodeid"]
netid := params["network"]
node, err := logic.CreateIngressGateway(netid, nodeid)
node, err := logic.CreateIngressGateway(netid, nodeid, failover)
if err != nil {
logger.Log(0, r.Header.Get("user"),
fmt.Sprintf("failed to create ingress gateway on node [%s] on network [%s]: %v",

View file

@ -172,7 +172,7 @@ func DeleteEgressGateway(network, nodeid string) (models.Node, error) {
}
// CreateIngressGateway - creates an ingress gateway
func CreateIngressGateway(netid string, nodeid string) (models.Node, error) {
func CreateIngressGateway(netid string, nodeid string, failover bool) (models.Node, error) {
var postUpCmd, postDownCmd string
node, err := GetNodeByID(nodeid)
@ -224,7 +224,9 @@ func CreateIngressGateway(netid string, nodeid string) (models.Node, error) {
node.PostUp = postUpCmd
node.PostDown = postDownCmd
node.UDPHolePunch = "no"
if failover {
node.Failover = "yes"
}
data, err := json.Marshal(&node)
if err != nil {
return models.Node{}, err