Comparison

plugins/mod_dialback.lua @ 6300:4b0172dc5e3a

mod_dialback: Keep the same dialback secret across module reloads
author Kim Alvefur <zash@zash.se>
date Thu, 03 Jul 2014 15:38:53 +0200
parent 6299:a1da78658a82
child 6301:2fdd71b08126
comparison
equal deleted inserted replaced
6299:a1da78658a82 6300:4b0172dc5e3a
17 17
18 local xmlns_stream = "http://etherx.jabber.org/streams"; 18 local xmlns_stream = "http://etherx.jabber.org/streams";
19 19
20 local dialback_requests = setmetatable({}, { __mode = 'v' }); 20 local dialback_requests = setmetatable({}, { __mode = 'v' });
21 21
22 local dialback_secret = module.host .. (module:get_option_string("dialback_secret") or uuid_gen()); 22 local dialback_secret = module.host .. module:get_option_string("dialback_secret", uuid_gen());
23
24 function module.save()
25 return { dialback_secret = dialback_secret };
26 end
27
28 function module.restore(state)
29 dialback_secret = state.dialback_secret;
30 end
23 31
24 function generate_dialback(id, to, from) 32 function generate_dialback(id, to, from)
25 return sha256_hash(id..to..dialback_secret, true); 33 return sha256_hash(id..to..dialback_secret, true);
26 end 34 end
27 35