diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-10-04 02:12:54 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-10-04 02:12:54 +0100 |
commit | f6924a64c06b36b6d90b03137da8c1a682889285 (patch) | |
tree | 28e2c0c35f9d77e826fd03c1b973561c38e71c5b | |
parent | 8d8cdb8574886137a29d8420d32ab42fcf95b75d (diff) | |
download | prosody-f6924a64c06b36b6d90b03137da8c1a682889285.tar.gz prosody-f6924a64c06b36b6d90b03137da8c1a682889285.zip |
Add "uuid" library and make sessionmanager use this.
...and yes, the uuid generation needs work :P
-rw-r--r-- | core/sessionmanager.lua | 4 | ||||
-rw-r--r-- | util/uuid.lua | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index f19721ed..f2542ed2 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -12,7 +12,7 @@ local hosts = hosts; local modulemanager = require "core.modulemanager"; local log = require "util.logger".init("sessionmanager"); local error = error; - +local uuid_generate = require "util.uuid".uuid_generate; module "sessionmanager" function new_session(conn) @@ -41,7 +41,7 @@ end function bind_resource(session, resource) if not session.username then return false, "auth"; end if session.resource then return false, "constraint"; end -- We don't support binding multiple resources - resource = resource or math.random(100000, 99999999); -- FIXME: Clearly we have issues :) + resource = resource or uuid_generate(); --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing if not hosts[session.host].sessions[session.username] then diff --git a/util/uuid.lua b/util/uuid.lua new file mode 100644 index 00000000..489522aa --- /dev/null +++ b/util/uuid.lua @@ -0,0 +1,9 @@ + +local m_random = math.random; +module "uuid" + +function uuid_generate() + return m_random(0, 99999999); +end + +return _M;
\ No newline at end of file |