]> granicus.if.org Git - ejabberd/commitdiff
Add global static shared_key option
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sun, 1 Jun 2014 10:20:09 +0000 (14:20 +0400)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sun, 1 Jun 2014 10:20:09 +0000 (14:20 +0400)
src/ejabberd_config.erl

index 06db8b5692a0068d1decb629f0a4f684c2e32a26..c0b78d9ba9cc04162b0a8594795365a0b1f6c613 100644 (file)
@@ -68,8 +68,15 @@ start() ->
     %% This start time is used by mod_last:
     {MegaSecs, Secs, _} = now(),
     UnixTime = MegaSecs*1000000 + Secs,
+    SharedKey = case erlang:get_cookie() of
+                    nocookie ->
+                        p1_sha:sha(randoms:get_string());
+                    Cookie ->
+                        p1_sha:sha(jlib:atom_to_binary(Cookie))
+                end,
     State1 = set_option({node_start, global}, UnixTime, State),
-    set_opts(State1).
+    State2 = set_option({shared_key, global}, SharedKey, State1),
+    set_opts(State2).
 
 %% @doc Get the filename of the ejabberd configuration file.
 %% The filename can be specified with: erl -config "/path/to/ejabberd.yml".