Fix changing alias

Former-commit-id: 0391106477
This commit is contained in:
Owen
2025-12-05 12:05:48 -05:00
parent 2ddb4a5645
commit 35544e1081
2 changed files with 27 additions and 13 deletions

View File

@@ -661,14 +661,26 @@ func (pm *PeerManager) RemoveAlias(siteId int, aliasName string) error {
}
}
// remove the allowed IP for the alias
if err := pm.removeAllowedIp(siteId, aliasToRemove.AliasAddress+"/32"); err != nil {
return err
}
peer.Aliases = newAliases
pm.peers[siteId] = peer
// Check if any other alias is still using this IP address before removing from allowed IPs
ipStillInUse := false
aliasIP := aliasToRemove.AliasAddress + "/32"
for _, a := range newAliases {
if a.AliasAddress+"/32" == aliasIP {
ipStillInUse = true
break
}
}
// Only remove the allowed IP if no other alias is using it
if !ipStillInUse {
if err := pm.removeAllowedIp(siteId, aliasIP); err != nil {
return err
}
}
return nil
}