From 59ef50532cbedbf9ddd883f5817c09463eef5d12 Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Thu, 3 Jul 2014 15:38:53 +0200
Subject: mod_dialback: Keep the same dialback secret across module reloads

---
 plugins/mod_dialback.lua | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua
index b32160c4..2959358b 100644
--- a/plugins/mod_dialback.lua
+++ b/plugins/mod_dialback.lua
@@ -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);
-- 
cgit v1.2.3