|
@@ -194,14 +194,16 @@ func SaveExtClient(extclient *models.ExtClient) error {
|
|
}
|
|
}
|
|
|
|
|
|
// UpdateExtClient - updates an ext client with new values
|
|
// UpdateExtClient - updates an ext client with new values
|
|
-func UpdateExtClient(old *models.ExtClient, update *models.CustomExtClient) (*models.ExtClient, error) {
|
|
|
|
|
|
+func UpdateExtClient(old *models.ExtClient, update *models.CustomExtClient) (*models.ExtClient, bool, error) {
|
|
new := old
|
|
new := old
|
|
|
|
+ replaceOldClient := false
|
|
err := DeleteExtClient(old.Network, old.ClientID)
|
|
err := DeleteExtClient(old.Network, old.ClientID)
|
|
if err != nil {
|
|
if err != nil {
|
|
- return new, err
|
|
|
|
|
|
+ return new, replaceOldClient, err
|
|
}
|
|
}
|
|
new.ClientID = update.ClientID
|
|
new.ClientID = update.ClientID
|
|
if update.PublicKey != "" && old.PublicKey != update.PublicKey {
|
|
if update.PublicKey != "" && old.PublicKey != update.PublicKey {
|
|
|
|
+ replaceOldClient = true
|
|
new.PublicKey = update.PublicKey
|
|
new.PublicKey = update.PublicKey
|
|
}
|
|
}
|
|
if update.DNS != "" && update.DNS != old.DNS {
|
|
if update.DNS != "" && update.DNS != old.DNS {
|
|
@@ -213,7 +215,7 @@ func UpdateExtClient(old *models.ExtClient, update *models.CustomExtClient) (*mo
|
|
if update.ExtraAllowedIPs != nil && StringDifference(old.ExtraAllowedIPs, update.ExtraAllowedIPs) != nil {
|
|
if update.ExtraAllowedIPs != nil && StringDifference(old.ExtraAllowedIPs, update.ExtraAllowedIPs) != nil {
|
|
new.ExtraAllowedIPs = update.ExtraAllowedIPs
|
|
new.ExtraAllowedIPs = update.ExtraAllowedIPs
|
|
}
|
|
}
|
|
- return new, CreateExtClient(new)
|
|
|
|
|
|
+ return new, replaceOldClient, CreateExtClient(new)
|
|
}
|
|
}
|
|
|
|
|
|
// GetExtClientsByID - gets the clients of attached gateway
|
|
// GetExtClientsByID - gets the clients of attached gateway
|