Skip to content

Commit 2f4a47d

Browse files
committed
chore(snowflake): add more randomness in server id fallback
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
1 parent 7426420 commit 2f4a47d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/private/Snowflake/SnowflakeGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ private function getCurrentTime(): array {
107107
*/
108108
private function getServerId(): int {
109109
$serverid = $this->config->getSystemValueInt('serverid', -1);
110+
110111
return $serverid > 0
111112
? $serverid
112-
: crc32(gethostname() ?: random_bytes(8));
113+
: hexdec(hash('xxh32', gethostname() ?: random_bytes(8)));
113114
}
114115

115116
private function isCli(): bool {

0 commit comments

Comments
 (0)