stats: use persistent UUID identifier
This commit is contained in:
parent
f172aa4144
commit
b452f0598e
1 changed files with 19 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue