mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-07-23 19:42:57 +03:00
raise an error if duplicate key is present
This commit is contained in:
parent
5a6a19c661
commit
94aaef70a7
1 changed files with 15 additions and 2 deletions
|
@ -185,6 +185,19 @@ func NewClient(db store.IStore) echo.HandlerFunc {
|
||||||
log.Error("Cannot verify wireguard public key: ", err)
|
log.Error("Cannot verify wireguard public key: ", err)
|
||||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot verify Wireguard public key"})
|
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot verify Wireguard public key"})
|
||||||
}
|
}
|
||||||
|
// check for duplicates
|
||||||
|
clients, err := db.GetClients(false)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Cannot get clients for duplicate check")
|
||||||
|
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot get clients for duplicate check"})
|
||||||
|
}
|
||||||
|
for _, other := range clients {
|
||||||
|
if other.Client.PublicKey == client.PublicKey {
|
||||||
|
log.Error("Duplicate Public Key")
|
||||||
|
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Duplicate Public Key"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.PresharedKey == "" {
|
if client.PresharedKey == "" {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue