mod_dialback: Keep the same dialback secret across module reloads
authorKim Alvefur <zash@zash.se>
Thu, 3 Jul 2014 13:38:53 +0000 (15:38 +0200)
committerKim Alvefur <zash@zash.se>
Thu, 3 Jul 2014 13:38:53 +0000 (15:38 +0200)
plugins/mod_dialback.lua

index b32160c474c3c67b4391f0610985320a5d997280..2959358bed945182839d2c39cfe759539742638f 100644 (file)
@@ -19,7 +19,15 @@ local xmlns_stream = "http://etherx.jabber.org/streams";
 
 local dialback_requests = setmetatable({}, { __mode = 'v' });
 
-local dialback_secret = module.host .. (module:get_option_string("dialback_secret") or uuid_gen());
+local dialback_secret = module.host .. module:get_option_string("dialback_secret", uuid_gen());
+
+function module.save()
+       return { dialback_secret = dialback_secret };
+end
+
+function module.restore(state)
+       dialback_secret = state.dialback_secret;
+end
 
 function generate_dialback(id, to, from)
        return sha256_hash(id..to..dialback_secret, true);