Giter Club home page Giter Club logo

uuid's Introduction

Build Status

uuid

Modified module from Rackspace original. Generates uuids in pure Lua.

Notes

Please read documentation carefully regarding random seeds or unique strings to be provided to get a decent randomized uuid value.

Home

Source code is on github

License & copyright

Rackspace (original) and Thijs Schreijer (modifications), Apache 2.0, see uuid.lua

Install

Use LuaRocks. To fetch and install from a LuaRocks server do luarocks install uuid. For a development installation from local source, do luarocks make from the main directory.

Test

Tests are available and can be executed using busted, and LuaCheck for linting.

Changes

0.3 11-Jul-2021

  • Fix: set proper type for UUIDv4 type
  • Feat: improve seeding for OpenResty
  • Doc: fix link in readme

0.2 09-May-2013

  • Bugfix; 0-hex was displayed as "" instead of "00", making some uuids too short
  • Bugfix; math.randomseed() overflow caused bad seeding

0.1 28-Apr-2013

  • initial version

uuid's People

Contributors

gfv avatar hbagdi avatar thibaultcha avatar tieske avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uuid's Issues

UUIDs are predictable

You only seed once, and with a poor quality source (time).

It's entirely possible to predict all your UUIDs, which makes them not universally unique.

thread-safe mode with luasocket, microtime and central storage

Hello, I'm following from this Kong/kong#695 and sailorproject/sailor#58

I want to propose the following solution for the seeding issue:

  1. Seeding: threads use output of require 'socket':gettime()
  2. Seed needs to be confirmed by creating a file /temp_folder/[timestamp].uuid
  3. If file exists already then get a new timestamp (retry 256 times by default)

This way we get a different seed for each thread. Production servers can run tmpfs (in-memory filesystem) to optimize speeds (no need to relay on database storage).

I know this has limitations, but who in the world is running more than 256 threads on a single microsecond?

some generated UUID's are too short

62abb19f-5f58-47e7-c733-adda664a4915
7ceb1b55-15b3-462e-c6fe-78b719cc07
38e119ad-3e2a-4513-c5b3-ce77e2e34acb
c130483d-dd58-40c6-c050-a3a34b206268
437b4790-225c-4132-c165-5bcb515f70b3
8d845a3f-fa-401b-c02d-c9ddea642d6a
aa4a0b1a-d8c0-4e41-ceb4-550f444b4e55
892bc63f-1021-4b7e-cbf2-99f467a72468

Lua version check fails

Hello,
Thanks a lot for this useful project!

I'm having an issue with the code line below

uuid/src/uuid.lua

Lines 178 to 184 in 190b336

if lua_version < 5.2 then
-- 5.1 uses (incorrect) signed int
math.randomseed(seed - 2^(bitsize-1))
else
-- 5.2 uses (correct) unsigned int
math.randomseed(seed)
end

For my Lua version 5.2.4 (ubuntu), _VERSION seems not to be assigned and thus is set to nil. I had to modify the code and manually assign it to 5.2 to prevent it to fail.

The good news is, I don't have this issue with other versions.

Now, would it be sane to do the following right before line 178?

if lua_version == nil then
    lua_version = 5.2
end

Or maybe there is another way to circumvent this issue?
Thanks a lot for your time!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.