Merge pull request #2100 from gravitl/GRA-1335-ext-client-pubkeys

GRA-1335 allowed public key input for ext clients
This commit is contained in:
dcarns
2023-03-08 16:19:53 -05:00
committed by GitHub
4 changed files with 29 additions and 18 deletions

View File

@@ -117,14 +117,15 @@ func GetExtClient(clientid string, network string) (models.ExtClient, error) {
// CreateExtClient - creates an extclient
func CreateExtClient(extclient *models.ExtClient) error {
if extclient.PrivateKey == "" {
if len(extclient.PublicKey) == 0 {
privateKey, err := wgtypes.GeneratePrivateKey()
if err != nil {
return err
}
extclient.PrivateKey = privateKey.String()
extclient.PublicKey = privateKey.PublicKey().String()
} else {
extclient.PrivateKey = "[ENTER PRIVATE KEY]"
}
parentNetwork, err := GetNetwork(extclient.Network)
@@ -156,7 +157,6 @@ func CreateExtClient(extclient *models.ExtClient) error {
}
extclient.LastModified = time.Now().Unix()
key, err := GetRecordKey(extclient.ClientID, extclient.Network)
if err != nil {
return err