Comparison

plugins/mod_smacks.lua @ 12112:08a949e63541

mod_smacks: Use more compact resumption tokens UUID seems like insane overkill for something user-scoped and not security-sensitive. All that is needed is to avoid conflicts among what should be relatively long-lived sessions.
author Kim Alvefur <zash@zash.se>
date Wed, 22 Dec 2021 18:47:45 +0100
parent 12081:6cc3135138d7
child 12114:e32f90c81519
comparison
equal deleted inserted replaced
12111:f8d280215633 12112:08a949e63541
19 local add_filter = require "util.filters".add_filter; 19 local add_filter = require "util.filters".add_filter;
20 local jid = require "util.jid"; 20 local jid = require "util.jid";
21 local smqueue = require "util.smqueue"; 21 local smqueue = require "util.smqueue";
22 local st = require "util.stanza"; 22 local st = require "util.stanza";
23 local timer = require "util.timer"; 23 local timer = require "util.timer";
24 local uuid_generate = require "util.uuid".generate; 24 local new_id = require "util.id".short;
25 local watchdog = require "util.watchdog"; 25 local watchdog = require "util.watchdog";
26 26
27 local sessionmanager = require "core.sessionmanager"; 27 local sessionmanager = require "core.sessionmanager";
28 local core_process_stanza = prosody.core_process_stanza; 28 local core_process_stanza = prosody.core_process_stanza;
29 29
257 257
258 local resume_max; 258 local resume_max;
259 local resume_token; 259 local resume_token;
260 local resume = stanza.attr.resume; 260 local resume = stanza.attr.resume;
261 if resume == "true" or resume == "1" then 261 if resume == "true" or resume == "1" then
262 resume_token = uuid_generate(); 262 resume_token = new_id();
263 session_registry[jid.join(session.username, session.host, resume_token)] = session; 263 session_registry[jid.join(session.username, session.host, resume_token)] = session;
264 session.resumption_token = resume_token; 264 session.resumption_token = resume_token;
265 resume_max = tostring(resume_timeout); 265 resume_max = tostring(resume_timeout);
266 end 266 end
267 (session.sends2s or session.send)(st.stanza("enabled", { xmlns = xmlns_sm, id = resume_token, resume = resume, max = resume_max })); 267 (session.sends2s or session.send)(st.stanza("enabled", { xmlns = xmlns_sm, id = resume_token, resume = resume, max = resume_max }));