mirror of
https://github.com/netdata/netdata.git
synced 2025-04-30 07:30:04 +00:00
use v4 UUIDs (#20002)
* use v4 UUIDs * added comments to UUID generations
This commit is contained in:
parent
cecd5d8c0b
commit
be9ac7cac9
3 changed files with 5 additions and 2 deletions
src
|
@ -168,7 +168,7 @@ static ND_MACHINE_GUID machine_guid_get_or_create(void) {
|
||||||
if (UUIDiszero(h.uuid)) {
|
if (UUIDiszero(h.uuid)) {
|
||||||
// If the status file does not contain a GUID, generate a new one.
|
// If the status file does not contain a GUID, generate a new one.
|
||||||
nd_log(NDLS_DAEMON, NDLP_INFO, "MACHINE_GUID: generating a new GUID");
|
nd_log(NDLS_DAEMON, NDLP_INFO, "MACHINE_GUID: generating a new GUID");
|
||||||
uuid_generate_time(h.uuid.uuid);
|
uuid_generate(h.uuid.uuid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nd_log(NDLS_DAEMON, NDLP_INFO, "MACHINE_GUID: got previous GUID from daemon status file");
|
nd_log(NDLS_DAEMON, NDLP_INFO, "MACHINE_GUID: got previous GUID from daemon status file");
|
||||||
|
|
|
@ -29,6 +29,8 @@ void os_uuid_generate_time(void *out) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void os_uuid_generate(void *out) {
|
void os_uuid_generate(void *out) {
|
||||||
|
// IMPORTANT: this generates a UUIDv4, which is random
|
||||||
|
// and falls back to uuid_generate_time() if high resolution random generated is not available
|
||||||
uuid_generate(out);
|
uuid_generate(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +39,7 @@ void os_uuid_generate_random(void *out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void os_uuid_generate_time(void *out) {
|
void os_uuid_generate_time(void *out) {
|
||||||
|
// IMPORTANT: this generates a UUIDv1, which is not random and may suffer from collisions
|
||||||
uuid_generate_time(out);
|
uuid_generate_time(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ static char *get_mgmt_api_key(void) {
|
||||||
if(!guid[0]) {
|
if(!guid[0]) {
|
||||||
nd_uuid_t uuid;
|
nd_uuid_t uuid;
|
||||||
|
|
||||||
uuid_generate_time(uuid);
|
uuid_generate(uuid);
|
||||||
uuid_unparse_lower(uuid, guid);
|
uuid_unparse_lower(uuid, guid);
|
||||||
guid[GUID_LEN] = '\0';
|
guid[GUID_LEN] = '\0';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue