Software /
code /
prosody
File
util/id.lua @ 9493:55b40f3fa659
mod_storage_sql: Change prosodyarchive_index to be non-unique (fixes #1087)
MySQL requires that the first 20 bytes are unique, even if they differ after
the first 20 bytes. This breaks e.g. pubsub/PEP nodes longer than 20 characters
that have common prefixes.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 11 Oct 2018 19:23:21 +0100 |
parent | 8016:9546c629289b |
child | 12110:b5b799a2a10c |
line wrap: on
line source
-- Prosody IM -- Copyright (C) 2008-2017 Matthew Wild -- Copyright (C) 2008-2017 Waqas Hussain -- Copyright (C) 2008-2017 Kim Alvefur -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. -- local s_gsub = string.gsub; local random_bytes = require "util.random".bytes; local base64_encode = require "util.encodings".base64.encode; local b64url = { ["+"] = "-", ["/"] = "_", ["="] = "" }; local function b64url_random(len) return (s_gsub(base64_encode(random_bytes(len)), "[+/=]", b64url)); end return { short = function () return b64url_random(6); end; medium = function () return b64url_random(12); end; long = function () return b64url_random(24); end; custom = function (size) return function () return b64url_random(size); end; end; }