mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-05-24 00:24:06 +03:00
Add preshared key in wireguard config (#15)
This commit is contained in:
parent
f76de28a17
commit
9617425033
4 changed files with 13 additions and 1 deletions
|
@ -136,8 +136,16 @@ func NewClient() echo.HandlerFunc {
|
|||
log.Error("Cannot generate wireguard key pair: ", err)
|
||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot generate Wireguard key pair"})
|
||||
}
|
||||
|
||||
presharedKey, err := wgtypes.GenerateKey()
|
||||
if err != nil {
|
||||
log.Error("Cannot generated preshared key: ", err)
|
||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot generate Wireguard preshared key"})
|
||||
}
|
||||
|
||||
client.PrivateKey = key.String()
|
||||
client.PublicKey = key.PublicKey().String()
|
||||
client.PresharedKey = presharedKey.String()
|
||||
client.CreatedAt = time.Now().UTC()
|
||||
client.UpdatedAt = client.CreatedAt
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue