Software / code / prosody
Comparison
core/sessionmanager.lua @ 1873:3b770710a1ee
sessionmanager: Use UUID for stream ids to clients, no math.random anymore :)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 03 Oct 2009 18:40:47 +0100 |
| parent | 1872:1905eca82ddf |
| child | 1929:b8e6764ffefd |
comparison
equal
deleted
inserted
replaced
| 1872:1905eca82ddf | 1873:3b770710a1ee |
|---|---|
| 9 | 9 |
| 10 | 10 |
| 11 local tonumber, tostring = tonumber, tostring; | 11 local tonumber, tostring = tonumber, tostring; |
| 12 local ipairs, pairs, print, next= ipairs, pairs, print, next; | 12 local ipairs, pairs, print, next= ipairs, pairs, print, next; |
| 13 local collectgarbage = collectgarbage; | 13 local collectgarbage = collectgarbage; |
| 14 local m_random = import("math", "random"); | |
| 15 local format = import("string", "format"); | 14 local format = import("string", "format"); |
| 16 | 15 |
| 17 local hosts = hosts; | 16 local hosts = hosts; |
| 18 local full_sessions = full_sessions; | 17 local full_sessions = full_sessions; |
| 19 local bare_sessions = bare_sessions; | 18 local bare_sessions = bare_sessions; |
| 166 function streamopened(session, attr) | 165 function streamopened(session, attr) |
| 167 local send = session.send; | 166 local send = session.send; |
| 168 session.host = attr.to or error("Client failed to specify destination hostname"); | 167 session.host = attr.to or error("Client failed to specify destination hostname"); |
| 169 session.host = nameprep(session.host); | 168 session.host = nameprep(session.host); |
| 170 session.version = tonumber(attr.version) or 0; | 169 session.version = tonumber(attr.version) or 0; |
| 171 session.streamid = m_random(1000000, 99999999); | 170 session.streamid = uuid_generate(); |
| 172 (session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host); | 171 (session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host); |
| 173 | 172 |
| 174 send("<?xml version='1.0'?>"); | 173 send("<?xml version='1.0'?>"); |
| 175 send(format("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='%s' from='%s' version='1.0' xml:lang='en'>", session.streamid, session.host)); | 174 send(format("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='%s' from='%s' version='1.0' xml:lang='en'>", session.streamid, session.host)); |
| 176 | 175 |