mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-07-06 17:13:13 +03:00
Changed GetAllocatedIPs to use IStore
Previously the GetAllocatedIPs function used it's own database connection. It now uses a pointer with the store.IStore interface to access the DB. Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
parent
25588b5000
commit
228d434405
2 changed files with 11 additions and 19 deletions
|
@ -148,7 +148,7 @@ func NewClient(db store.IStore) echo.HandlerFunc {
|
|||
}
|
||||
|
||||
// validate the input Allocation IPs
|
||||
allocatedIPs, err := util.GetAllocatedIPs("")
|
||||
allocatedIPs, err := util.GetAllocatedIPs(db, "")
|
||||
check, err := util.ValidateIPAllocation(server.Interface.Addresses, allocatedIPs, client.AllocatedIPs)
|
||||
if !check {
|
||||
return c.JSON(http.StatusBadRequest, jsonHTTPResponse{false, fmt.Sprintf("%s", err)})
|
||||
|
@ -268,7 +268,7 @@ func UpdateClient(db store.IStore) echo.HandlerFunc {
|
|||
}
|
||||
client := *clientData.Client
|
||||
// validate the input Allocation IPs
|
||||
allocatedIPs, err := util.GetAllocatedIPs(client.ID)
|
||||
allocatedIPs, err := util.GetAllocatedIPs(db, client.ID)
|
||||
check, err := util.ValidateIPAllocation(server.Interface.Addresses, allocatedIPs, _client.AllocatedIPs)
|
||||
if !check {
|
||||
return c.JSON(http.StatusBadRequest, jsonHTTPResponse{false, fmt.Sprintf("%s", err)})
|
||||
|
@ -624,7 +624,7 @@ func SuggestIPAllocation(db store.IStore) echo.HandlerFunc {
|
|||
// we take the first available ip address from
|
||||
// each server's network addresses.
|
||||
suggestedIPs := make([]string, 0)
|
||||
allocatedIPs, err := util.GetAllocatedIPs("")
|
||||
allocatedIPs, err := util.GetAllocatedIPs(db, "")
|
||||
if err != nil {
|
||||
log.Error("Cannot suggest ip allocation. Failed to get list of allocated ip addresses: ", err)
|
||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue