diff --git a/rhodecode/lib/utils.py b/rhodecode/lib/utils.py index 998352a7..293a400e 100644 --- a/rhodecode/lib/utils.py +++ b/rhodecode/lib/utils.py @@ -900,9 +900,27 @@ def generate_platform_uuid(): Generates platform UUID based on it's name """ import platform + import uuid + + def generate_stable_v5_uuid(): + """Generates a stable, repeatable Version 5 UUID based on the MAC address.""" + # Use a fixed, arbitrary UUID as the namespace for the machine IDs. + # This ensures that all generated IDs are distinct from standard UUID namespaces. + machine_namespace = uuid.UUID("10000000-0000-0000-0000-000000000001") + + # Get the 48-bit MAC address as an integer + mac_int = uuid.getnode() + + # Convert MAC address integer to a string name + mac_str = str(mac_int) + + # Create the Version 5 UUID (SHA-1 hash of Namespace + MAC string) + stable_uuid = uuid.uuid5(machine_namespace, mac_str) + + return str(stable_uuid) try: - uuid_list = [platform.platform()] + uuid_list = [platform.platform(), generate_stable_v5_uuid()] return sha256_safe(":".join(uuid_list)) except Exception as e: log.error("Failed to generate host uuid: %s", e)