Permalink
Browse files

Move modules and auth_method configuration options to config instead …

…of local_config for values that shouldn't change across the cluster.
  • Loading branch information...
1 parent a2c0bb0 commit 03280a5ff3c8f97bff0076b112592c24ee6637c6 @skruger committed Sep 17, 2012
@@ -382,7 +382,7 @@ auth_modules() ->
%% Return the list of authenticated modules for a given host
auth_modules(Server) ->
LServer = jlib:nameprep(Server),
- Method = ejabberd_config:get_local_option({auth_method, LServer}),
+ Method = ejabberd_config:get_global_option({auth_method, LServer}),
Methods = if
Method == undefined -> [];
is_list(Method) -> Method;
@@ -317,4 +317,5 @@ get_mod_last_configured(Server) ->
end.
is_configured(Host, Module) ->
- lists:keymember(Module, 1, ejabberd_config:get_local_option({modules, Host})).
+ lists:keymember(Module, 1, gen_mod:get_host_modules(Host)).
+
@@ -443,6 +443,9 @@ process_term(Term, State) ->
State;
{max_fsm_queue, N} ->
add_option(max_fsm_queue, N, State);
+ {modules, MList} ->
+ gen_mod:set_host_modules(global, MList),
+ State;
{_Opt, _Val} ->
lists:foldl(fun(Host, S) -> process_host_term(Term, Host, S) end,
State, State#state.hosts)
@@ -457,6 +460,10 @@ process_host_term(Term, Host, State) ->
State#state{opts = [#config{key = {access, RuleName, Host},
value = Rules} |
State#state.opts]};
+ {auth_method, Methods} ->
+ State#state{opts = [#config{key = {auth_method, Host},
+ value = Methods} |
+ State#state.opts]};
{shaper, Name, Data} ->
State#state{opts = [#config{key = {shaper, Name, Host},
value = Data} |
@@ -465,6 +472,9 @@ process_host_term(Term, Host, State) ->
State;
{hosts, _Hosts} ->
State;
+ {modules, MList} ->
+ gen_mod:set_host_modules(Host, MList),
+ State;
{odbc_server, ODBC_server} ->
add_option({odbc_server, Host}, ODBC_server, State);
{Opt, Val} ->
@@ -105,25 +105,17 @@ unregister_routes(Host) ->
start_modules(Host) ->
?INFO_MSG("Starting modules for ~p~n", [Host]),
- case ejabberd_config:get_local_option({modules, Host}) of
- undefined ->
- ok;
- Modules ->
- lists:foreach(
- fun({Module, Args}) ->
- gen_mod:start_module(Host, Module, Args)
- end, Modules)
- end.
+ Modules = gen_mod:get_host_modules(Host),
+ lists:foreach(
+ fun({Module,Args}) ->
+ gen_mod:start_module(Host, Module, Args)
+ end, Modules).
stop_modules(Host) ->
?INFO_MSG("Stopping modules for ~p~n", [Host]),
- case ejabberd_config:get_local_option({modules, Host}) of
- undefined ->
- ok;
- Modules ->
- lists:foreach(
- fun({Module, _Args}) ->
- gen_mod:stop_module_keep_config(Host, Module)
- end, Modules)
- end.
+ Modules = gen_mod:loaded_modules(Host),
+ lists:foreach(
+ fun(Module) ->
+ gen_mod:stop_module_keep_config(Host, Module)
+ end, Modules).
View
@@ -31,6 +31,8 @@
start_module/3,
stop_module/2,
stop_module_keep_config/2,
+ get_host_modules/1,
+ set_host_modules/2,
get_opt/2,
get_opt/3,
get_opt_host/3,
@@ -206,25 +208,33 @@ loaded_modules_with_opts(Host) ->
[{{'$1', '$2'}}]}]).
set_module_opts_mnesia(Host, Module, Opts) ->
- Modules = case ejabberd_config:get_local_option({modules, Host}) of
- undefined ->
- [];
- Ls ->
- Ls
- end,
+ Modules = get_host_modules(Host),
Modules1 = lists:keydelete(Module, 1, Modules),
Modules2 = [{Module, Opts} | Modules1],
- ejabberd_config:add_local_option({modules, Host}, Modules2).
+ set_host_modules(Host, Modules2).
del_module_mnesia(Host, Module) ->
- Modules = case ejabberd_config:get_local_option({modules, Host}) of
- undefined ->
- [];
- Ls ->
- Ls
- end,
+ Modules = get_host_modules(Host),
Modules1 = lists:keydelete(Module, 1, Modules),
- ejabberd_config:add_local_option({modules, Host}, Modules1).
+ set_host_modules(Host, Modules1).
+
+get_host_modules(Host) ->
+ case ejabberd_config:get_local_option({modules, Host}) of
+ undefined ->
+ case ejabberd_config:get_global_option({modules, Host}) of
+ undefined ->
+ case ejabberd_config:get_global_option({modules, global}) of
+ undefined ->
+ [];
+ Mods -> Mods
+ end;
+ Mods -> Mods
+ end;
+ Mods -> Mods
+ end.
+
+set_host_modules(Host, Modules) ->
+ ejabberd_config:add_global_option({modules, Host}, Modules).
get_hosts(Opts, Prefix) ->
case catch gen_mod:get_opt(hosts, Opts) of
@@ -284,7 +284,7 @@ path_to_node(Path) ->
%% Check that the mod_caps module is enabled in that Jabber Host
%% If not, show a warning message in the ejabberd log file.
complain_if_modcaps_disabled(ServerHost) ->
- Modules = ejabberd_config:get_local_option({modules, ServerHost}),
+ Modules = gen_mod:get_host_modules(ServerHost),
ModCaps = [mod_caps_enabled || {mod_caps, _Opts} <- Modules],
case ModCaps of
[] ->
@@ -323,7 +323,7 @@ path_to_node(Path) ->
%% Check that the mod_caps module is enabled in that Jabber Host
%% If not, show a warning message in the ejabberd log file.
complain_if_modcaps_disabled(ServerHost) ->
- Modules = ejabberd_config:get_local_option({modules, ServerHost}),
+ Modules = gen_mod:get_host_modules(ServerHost),
ModCaps = [mod_caps_enabled || {mod_caps, _Opts} <- Modules],
case ModCaps of
[] ->

0 comments on commit 03280a5

Please sign in to comment.