add client postup & postdown

This commit is contained in:
sunyu 2020-09-25 15:35:23 +08:00
parent a89fb34555
commit 03428646e1
5 changed files with 37 additions and 5 deletions

View file

@ -3,11 +3,12 @@ package handler
import (
"encoding/json"
"fmt"
rice "github.com/GeertJohan/go.rice"
"net/http"
"strings"
"time"
rice "github.com/GeertJohan/go.rice"
"github.com/gorilla/sessions"
"github.com/labstack/echo-contrib/session"
"github.com/labstack/echo/v4"
@ -192,7 +193,6 @@ func NewClient() echo.HandlerFunc {
client.HasPrivateSubnet = true
}
}
// write client to the database
db.Write("clients", client.ID, client)
@ -256,6 +256,8 @@ func UpdateClient() echo.HandlerFunc {
client.AllocatedIPs = _client.AllocatedIPs
client.AllowedIPs = _client.AllowedIPs
client.PrivateSubnets = _client.PrivateSubnets
client.PostUp = _client.PostUp
client.PostDown = _client.PostDown
client.UpdatedAt = time.Now().UTC()
client.HasPrivateSubnet = false