Check GetAllocatedIPs error in client create/update

This commit is contained in:
Ioannis Dressos 2026-07-08 12:16:01 +03:00
parent 283ba7155d
commit c2f268edec
No known key found for this signature in database
1 changed files with 8 additions and 0 deletions

View File

@ -475,6 +475,10 @@ func NewClient(db store.IStore) echo.HandlerFunc {
// validate the input Allocation IPs
allocatedIPs, err := util.GetAllocatedIPs("")
if err != nil {
log.Error("Cannot get allocated IP addresses: ", err)
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot get allocated IP addresses"})
}
check, err := util.ValidateIPAllocation(server.Interface.Addresses, allocatedIPs, client.AllocatedIPs)
if !check {
return c.JSON(http.StatusBadRequest, jsonHTTPResponse{false, fmt.Sprintf("%s", err)})
@ -697,6 +701,10 @@ func UpdateClient(db store.IStore) echo.HandlerFunc {
client := *clientData.Client
// validate the input Allocation IPs
allocatedIPs, err := util.GetAllocatedIPs(client.ID)
if err != nil {
log.Error("Cannot get allocated IP addresses: ", err)
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot get allocated IP addresses"})
}
check, err := util.ValidateIPAllocation(server.Interface.Addresses, allocatedIPs, _client.AllocatedIPs)
if !check {
return c.JSON(http.StatusBadRequest, jsonHTTPResponse{false, fmt.Sprintf("%s", err)})