mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Remove 'iqdisc' option
Since we got rid of all bottle-neck processes and we have a connection pool for every database, the option is no longer needed and in fact is detrimental: in practice what you get is just a bunch of overloaded processes in the IQ handlers pool no matter how much you increase the `iqdisc` value. Given that there are close to zero operators understanding the meaning of the option and, hence, not using it all, it's not simply deprecated but completely removed. The commit also deprecates the following functions: - gen_iq_handler:add_iq_handler/6 - gen_iq_handler:handle/5 - gen_iq_handler:iqdisc/1
This commit is contained in:
parent
11a58f8dff
commit
66fc1bf3b6
@ -283,9 +283,8 @@ process(_Handlers, _Request) ->
|
|||||||
ejabberd_web:error(not_found).
|
ejabberd_web:error(not_found).
|
||||||
|
|
||||||
host_up(Host) ->
|
host_up(Host) ->
|
||||||
IQDisc = gen_iq_handler:iqdisc(Host),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_CAPTCHA,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_CAPTCHA,
|
||||||
?MODULE, process_iq, IQDisc).
|
?MODULE, process_iq).
|
||||||
|
|
||||||
host_down(Host) ->
|
host_down(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_CAPTCHA).
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_CAPTCHA).
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
-export([route/1, process_iq/1,
|
-export([route/1, process_iq/1,
|
||||||
get_features/1,
|
get_features/1,
|
||||||
register_iq_handler/5,
|
register_iq_handler/4,
|
||||||
unregister_iq_handler/2,
|
unregister_iq_handler/2,
|
||||||
bounce_resource_packet/1,
|
bounce_resource_packet/1,
|
||||||
host_up/1, host_down/1]).
|
host_up/1, host_down/1]).
|
||||||
@ -78,8 +78,8 @@ process_iq(#iq{to = To, type = T, lang = Lang, sub_els = [El]} = Packet)
|
|||||||
XMLNS = xmpp:get_ns(El),
|
XMLNS = xmpp:get_ns(El),
|
||||||
Host = To#jid.lserver,
|
Host = To#jid.lserver,
|
||||||
case ets:lookup(?IQTABLE, {Host, XMLNS}) of
|
case ets:lookup(?IQTABLE, {Host, XMLNS}) of
|
||||||
[{_, Module, Function, Opts}] ->
|
[{_, Module, Function}] ->
|
||||||
gen_iq_handler:handle(Host, Module, Function, Opts, Packet);
|
gen_iq_handler:handle(Host, Module, Function, Packet);
|
||||||
[] ->
|
[] ->
|
||||||
Txt = <<"No module is handling this query">>,
|
Txt = <<"No module is handling this query">>,
|
||||||
Err = xmpp:err_service_unavailable(Txt, Lang),
|
Err = xmpp:err_service_unavailable(Txt, Lang),
|
||||||
@ -112,11 +112,10 @@ route_iq(IQ, Fun) ->
|
|||||||
route_iq(IQ, Fun, Timeout) ->
|
route_iq(IQ, Fun, Timeout) ->
|
||||||
ejabberd_router:route_iq(IQ, Fun, undefined, Timeout).
|
ejabberd_router:route_iq(IQ, Fun, undefined, Timeout).
|
||||||
|
|
||||||
-spec register_iq_handler(binary(), binary(), module(), function(),
|
-spec register_iq_handler(binary(), binary(), module(), function()) -> ok.
|
||||||
gen_iq_handler:opts()) -> ok.
|
register_iq_handler(Host, XMLNS, Module, Fun) ->
|
||||||
register_iq_handler(Host, XMLNS, Module, Fun, Opts) ->
|
|
||||||
gen_server:cast(?MODULE,
|
gen_server:cast(?MODULE,
|
||||||
{register_iq_handler, Host, XMLNS, Module, Fun, Opts}).
|
{register_iq_handler, Host, XMLNS, Module, Fun}).
|
||||||
|
|
||||||
-spec unregister_iq_handler(binary(), binary()) -> ok.
|
-spec unregister_iq_handler(binary(), binary()) -> ok.
|
||||||
unregister_iq_handler(Host, XMLNS) ->
|
unregister_iq_handler(Host, XMLNS) ->
|
||||||
@ -160,19 +159,13 @@ init([]) ->
|
|||||||
handle_call(_Request, _From, State) ->
|
handle_call(_Request, _From, State) ->
|
||||||
Reply = ok, {reply, Reply, State}.
|
Reply = ok, {reply, Reply, State}.
|
||||||
|
|
||||||
handle_cast({register_iq_handler, Host, XMLNS, Module,
|
handle_cast({register_iq_handler, Host, XMLNS, Module, Function},
|
||||||
Function, Opts},
|
|
||||||
State) ->
|
State) ->
|
||||||
ets:insert(?IQTABLE,
|
ets:insert(?IQTABLE,
|
||||||
{{Host, XMLNS}, Module, Function, Opts}),
|
{{Host, XMLNS}, Module, Function}),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_cast({unregister_iq_handler, Host, XMLNS},
|
handle_cast({unregister_iq_handler, Host, XMLNS},
|
||||||
State) ->
|
State) ->
|
||||||
case ets:lookup(?IQTABLE, {Host, XMLNS}) of
|
|
||||||
[{_, Module, Function, Opts}] ->
|
|
||||||
gen_iq_handler:stop_iq_handler(Module, Function, Opts);
|
|
||||||
_ -> ok
|
|
||||||
end,
|
|
||||||
ets:delete(?IQTABLE, {Host, XMLNS}),
|
ets:delete(?IQTABLE, {Host, XMLNS}),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_cast(_Msg, State) -> {noreply, State}.
|
handle_cast(_Msg, State) -> {noreply, State}.
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
get_vh_session_list/1,
|
get_vh_session_list/1,
|
||||||
get_vh_session_number/1,
|
get_vh_session_number/1,
|
||||||
get_vh_by_backend/1,
|
get_vh_by_backend/1,
|
||||||
register_iq_handler/5,
|
register_iq_handler/4,
|
||||||
unregister_iq_handler/2,
|
unregister_iq_handler/2,
|
||||||
force_update_presence/1,
|
force_update_presence/1,
|
||||||
connected_users/0,
|
connected_users/0,
|
||||||
@ -397,11 +397,11 @@ get_vh_session_number(Server) ->
|
|||||||
Mod = get_sm_backend(LServer),
|
Mod = get_sm_backend(LServer),
|
||||||
length(online(get_sessions(Mod, LServer))).
|
length(online(get_sessions(Mod, LServer))).
|
||||||
|
|
||||||
-spec register_iq_handler(binary(), binary(), atom(), atom(), list()) -> ok.
|
-spec register_iq_handler(binary(), binary(), atom(), atom()) -> ok.
|
||||||
|
|
||||||
register_iq_handler(Host, XMLNS, Module, Fun, Opts) ->
|
register_iq_handler(Host, XMLNS, Module, Fun) ->
|
||||||
?GEN_SERVER:cast(?MODULE,
|
?GEN_SERVER:cast(?MODULE,
|
||||||
{register_iq_handler, Host, XMLNS, Module, Fun, Opts}).
|
{register_iq_handler, Host, XMLNS, Module, Fun}).
|
||||||
|
|
||||||
-spec unregister_iq_handler(binary(), binary()) -> ok.
|
-spec unregister_iq_handler(binary(), binary()) -> ok.
|
||||||
|
|
||||||
@ -448,19 +448,13 @@ init([]) ->
|
|||||||
handle_call(_Request, _From, State) ->
|
handle_call(_Request, _From, State) ->
|
||||||
Reply = ok, {reply, Reply, State}.
|
Reply = ok, {reply, Reply, State}.
|
||||||
|
|
||||||
handle_cast({register_iq_handler, Host, XMLNS, Module,
|
handle_cast({register_iq_handler, Host, XMLNS, Module, Function},
|
||||||
Function, Opts},
|
|
||||||
State) ->
|
State) ->
|
||||||
ets:insert(sm_iqtable,
|
ets:insert(sm_iqtable,
|
||||||
{{Host, XMLNS}, Module, Function, Opts}),
|
{{Host, XMLNS}, Module, Function}),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_cast({unregister_iq_handler, Host, XMLNS},
|
handle_cast({unregister_iq_handler, Host, XMLNS},
|
||||||
State) ->
|
State) ->
|
||||||
case ets:lookup(sm_iqtable, {Host, XMLNS}) of
|
|
||||||
[{_, Module, Function, Opts}] ->
|
|
||||||
gen_iq_handler:stop_iq_handler(Module, Function, Opts);
|
|
||||||
_ -> ok
|
|
||||||
end,
|
|
||||||
ets:delete(sm_iqtable, {Host, XMLNS}),
|
ets:delete(sm_iqtable, {Host, XMLNS}),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_cast(_Msg, State) -> {noreply, State}.
|
handle_cast(_Msg, State) -> {noreply, State}.
|
||||||
@ -862,8 +856,8 @@ process_iq(#iq{to = To, type = T, lang = Lang, sub_els = [El]} = Packet)
|
|||||||
XMLNS = xmpp:get_ns(El),
|
XMLNS = xmpp:get_ns(El),
|
||||||
Host = To#jid.lserver,
|
Host = To#jid.lserver,
|
||||||
case ets:lookup(sm_iqtable, {Host, XMLNS}) of
|
case ets:lookup(sm_iqtable, {Host, XMLNS}) of
|
||||||
[{_, Module, Function, Opts}] ->
|
[{_, Module, Function}] ->
|
||||||
gen_iq_handler:handle(Host, Module, Function, Opts, Packet);
|
gen_iq_handler:handle(Host, Module, Function, Packet);
|
||||||
[] ->
|
[] ->
|
||||||
Txt = <<"No module is handling this query">>,
|
Txt = <<"No module is handling this query">>,
|
||||||
Err = xmpp:err_service_unavailable(Txt, Lang),
|
Err = xmpp:err_service_unavailable(Txt, Lang),
|
||||||
|
@ -92,14 +92,6 @@ init([]) ->
|
|||||||
infinity,
|
infinity,
|
||||||
supervisor,
|
supervisor,
|
||||||
[ejabberd_tmp_sup]},
|
[ejabberd_tmp_sup]},
|
||||||
IQSupervisor =
|
|
||||||
{ejabberd_iq_sup,
|
|
||||||
{ejabberd_tmp_sup, start_link,
|
|
||||||
[ejabberd_iq_sup, gen_iq_handler]},
|
|
||||||
permanent,
|
|
||||||
infinity,
|
|
||||||
supervisor,
|
|
||||||
[ejabberd_tmp_sup]},
|
|
||||||
BackendSupervisor = {ejabberd_backend_sup,
|
BackendSupervisor = {ejabberd_backend_sup,
|
||||||
{ejabberd_backend_sup, start_link, []},
|
{ejabberd_backend_sup, start_link, []},
|
||||||
permanent, infinity, supervisor,
|
permanent, infinity, supervisor,
|
||||||
@ -169,7 +161,6 @@ init([]) ->
|
|||||||
S2SInSupervisor,
|
S2SInSupervisor,
|
||||||
S2SOutSupervisor,
|
S2SOutSupervisor,
|
||||||
ServiceSupervisor,
|
ServiceSupervisor,
|
||||||
IQSupervisor,
|
|
||||||
ACL,
|
ACL,
|
||||||
Shaper,
|
Shaper,
|
||||||
BackendSupervisor,
|
BackendSupervisor,
|
||||||
|
@ -27,110 +27,38 @@
|
|||||||
|
|
||||||
-author('alexey@process-one.net').
|
-author('alexey@process-one.net').
|
||||||
|
|
||||||
-ifndef(GEN_SERVER).
|
|
||||||
-define(GEN_SERVER, gen_server).
|
|
||||||
-endif.
|
|
||||||
-behaviour(?GEN_SERVER).
|
|
||||||
-behaviour(ejabberd_config).
|
-behaviour(ejabberd_config).
|
||||||
|
|
||||||
%% API
|
%% API
|
||||||
-export([start_link/3, add_iq_handler/6,
|
-export([add_iq_handler/5, remove_iq_handler/3, handle/4,
|
||||||
remove_iq_handler/3, stop_iq_handler/3, handle/5,
|
|
||||||
process_iq/4, check_type/1, transform_module_options/1,
|
process_iq/4, check_type/1, transform_module_options/1,
|
||||||
opt_type/1, iqdisc/1]).
|
opt_type/1]).
|
||||||
|
%% Deprecated functions
|
||||||
%% gen_server callbacks
|
-export([add_iq_handler/6, handle/5, iqdisc/1]).
|
||||||
-export([init/1, handle_call/3, handle_cast/2,
|
-deprecated([{add_iq_handler, 6}, {handle, 5}, {iqdisc, 1}]).
|
||||||
handle_info/2, terminate/2, code_change/3]).
|
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
-include("xmpp.hrl").
|
-include("xmpp.hrl").
|
||||||
|
|
||||||
-record(state, {host, module, function}).
|
|
||||||
|
|
||||||
-type component() :: ejabberd_sm | ejabberd_local.
|
-type component() :: ejabberd_sm | ejabberd_local.
|
||||||
-type type() :: no_queue | one_queue | pos_integer() | parallel.
|
|
||||||
-type opts() :: no_queue | {one_queue, pid()} | {queues, [pid()]} | parallel.
|
|
||||||
-export_type([opts/0, type/0]).
|
|
||||||
|
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%%--------------------------------------------------------------------
|
-spec add_iq_handler(module(), binary(), binary(), module(), atom()) -> ok.
|
||||||
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
|
add_iq_handler(Component, Host, NS, Module, Function) ->
|
||||||
%% Description: Starts the server
|
Component:register_iq_handler(Host, NS, Module, Function).
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
start_link(Host, Module, Function) ->
|
|
||||||
?GEN_SERVER:start_link(?MODULE, [Host, Module, Function],
|
|
||||||
[]).
|
|
||||||
|
|
||||||
-spec add_iq_handler(module(), binary(), binary(), module(), atom(), type()) -> ok.
|
|
||||||
|
|
||||||
add_iq_handler(Component, Host, NS, Module, Function,
|
|
||||||
Type) ->
|
|
||||||
case Type of
|
|
||||||
no_queue ->
|
|
||||||
Component:register_iq_handler(Host, NS, Module,
|
|
||||||
Function, no_queue);
|
|
||||||
one_queue ->
|
|
||||||
{ok, Pid} = supervisor:start_child(ejabberd_iq_sup,
|
|
||||||
[Host, Module, Function]),
|
|
||||||
Component:register_iq_handler(Host, NS, Module,
|
|
||||||
Function, {one_queue, Pid});
|
|
||||||
N when is_integer(N) ->
|
|
||||||
Pids = lists:map(fun (_) ->
|
|
||||||
{ok, Pid} =
|
|
||||||
supervisor:start_child(ejabberd_iq_sup,
|
|
||||||
[Host, Module,
|
|
||||||
Function]),
|
|
||||||
Pid
|
|
||||||
end,
|
|
||||||
lists:seq(1, N)),
|
|
||||||
Component:register_iq_handler(Host, NS, Module,
|
|
||||||
Function, {queues, Pids});
|
|
||||||
parallel ->
|
|
||||||
Component:register_iq_handler(Host, NS, Module,
|
|
||||||
Function, parallel)
|
|
||||||
end.
|
|
||||||
|
|
||||||
-spec remove_iq_handler(component(), binary(), binary()) -> ok.
|
-spec remove_iq_handler(component(), binary(), binary()) -> ok.
|
||||||
|
|
||||||
remove_iq_handler(Component, Host, NS) ->
|
remove_iq_handler(Component, Host, NS) ->
|
||||||
Component:unregister_iq_handler(Host, NS).
|
Component:unregister_iq_handler(Host, NS).
|
||||||
|
|
||||||
-spec stop_iq_handler(atom(), atom(), [pid()]) -> any().
|
-spec handle(binary(), atom(), atom(), iq()) -> any().
|
||||||
|
handle(Host, Module, Function, IQ) ->
|
||||||
stop_iq_handler(_Module, _Function, Opts) ->
|
process_iq(Host, Module, Function, IQ).
|
||||||
case Opts of
|
|
||||||
{one_queue, Pid} -> ?GEN_SERVER:call(Pid, stop);
|
|
||||||
{queues, Pids} ->
|
|
||||||
lists:foreach(fun (Pid) ->
|
|
||||||
catch ?GEN_SERVER:call(Pid, stop)
|
|
||||||
end,
|
|
||||||
Pids);
|
|
||||||
_ -> ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
-spec handle(binary(), atom(), atom(), opts(), iq()) -> any().
|
|
||||||
|
|
||||||
handle(Host, Module, Function, Opts, IQ) ->
|
|
||||||
case Opts of
|
|
||||||
no_queue ->
|
|
||||||
process_iq(Host, Module, Function, IQ);
|
|
||||||
{one_queue, Pid} ->
|
|
||||||
Pid ! {process_iq, IQ};
|
|
||||||
{queues, Pids} ->
|
|
||||||
Pid = lists:nth(erlang:phash(p1_time_compat:unique_integer(),
|
|
||||||
length(Pids)), Pids),
|
|
||||||
Pid ! {process_iq, IQ};
|
|
||||||
parallel ->
|
|
||||||
spawn(?MODULE, process_iq, [Host, Module, Function, IQ]);
|
|
||||||
_ -> todo
|
|
||||||
end.
|
|
||||||
|
|
||||||
-spec process_iq(binary(), atom(), atom(), iq()) -> any().
|
-spec process_iq(binary(), atom(), atom(), iq()) -> any().
|
||||||
|
|
||||||
process_iq(_Host, Module, Function, IQ) ->
|
process_iq(_Host, Module, Function, IQ) ->
|
||||||
try
|
try
|
||||||
ResIQ = case erlang:function_exported(Module, Function, 1) of
|
ResIQ = case erlang:function_exported(Module, Function, 1) of
|
||||||
@ -178,15 +106,14 @@ process_iq(Module, Function, From, To, IQ) ->
|
|||||||
To, From)
|
To, From)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec check_type(type()) -> type().
|
-spec check_type(any()) -> no_queue.
|
||||||
|
check_type(_Type) ->
|
||||||
|
?WARNING_MSG("Option 'iqdisc' is deprecated and has no effect anymore", []),
|
||||||
|
no_queue.
|
||||||
|
|
||||||
check_type(no_queue) -> no_queue;
|
-spec iqdisc(binary() | global) -> no_queue.
|
||||||
check_type(one_queue) -> one_queue;
|
iqdisc(_Host) ->
|
||||||
check_type(N) when is_integer(N), N>0 -> N;
|
no_queue.
|
||||||
check_type(parallel) -> parallel.
|
|
||||||
|
|
||||||
iqdisc(Host) ->
|
|
||||||
ejabberd_config:get_option({iqdisc, Host}, no_queue).
|
|
||||||
|
|
||||||
-spec transform_module_options([{atom(), any()}]) -> [{atom(), any()}].
|
-spec transform_module_options([{atom(), any()}]) -> [{atom(), any()}].
|
||||||
|
|
||||||
@ -198,37 +125,18 @@ transform_module_options(Opts) ->
|
|||||||
Opt
|
Opt
|
||||||
end, Opts).
|
end, Opts).
|
||||||
|
|
||||||
-spec opt_type(iqdisc) -> fun((type()) -> type());
|
-spec opt_type(iqdisc) -> fun((any()) -> no_queue);
|
||||||
(atom()) -> [atom()].
|
(atom()) -> [atom()].
|
||||||
opt_type(iqdisc) -> fun check_type/1;
|
opt_type(iqdisc) -> fun check_type/1;
|
||||||
opt_type(_) -> [iqdisc].
|
opt_type(_) -> [iqdisc].
|
||||||
|
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% gen_server callbacks
|
%% Deprecated API
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
|
-spec add_iq_handler(module(), binary(), binary(), module(), atom(), any()) -> ok.
|
||||||
|
add_iq_handler(Component, Host, NS, Module, Function, _Type) ->
|
||||||
|
add_iq_handler(Component, Host, NS, Module, Function).
|
||||||
|
|
||||||
init([Host, Module, Function]) ->
|
-spec handle(binary(), atom(), atom(), any(), iq()) -> any().
|
||||||
{ok,
|
handle(Host, Module, Function, _Opts, IQ) ->
|
||||||
#state{host = Host, module = Module,
|
handle(Host, Module, Function, IQ).
|
||||||
function = Function}}.
|
|
||||||
|
|
||||||
handle_call(stop, _From, State) ->
|
|
||||||
Reply = ok, {stop, normal, Reply, State}.
|
|
||||||
|
|
||||||
handle_cast(_Msg, State) -> {noreply, State}.
|
|
||||||
|
|
||||||
handle_info({process_iq, IQ},
|
|
||||||
#state{host = Host, module = Module,
|
|
||||||
function = Function} =
|
|
||||||
State) ->
|
|
||||||
process_iq(Host, Module, Function, IQ),
|
|
||||||
{noreply, State};
|
|
||||||
handle_info(_Info, State) -> {noreply, State}.
|
|
||||||
|
|
||||||
terminate(_Reason, _State) -> ok.
|
|
||||||
|
|
||||||
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%%% Internal functions
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
@ -42,13 +42,11 @@
|
|||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
-include("xmpp.hrl").
|
-include("xmpp.hrl").
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, _Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
||||||
?NS_COMMANDS, ?MODULE, process_local_iq,
|
?NS_COMMANDS, ?MODULE, process_local_iq),
|
||||||
IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_COMMANDS, ?MODULE, process_sm_iq, IQDisc),
|
?NS_COMMANDS, ?MODULE, process_sm_iq),
|
||||||
ejabberd_hooks:add(disco_local_identity, Host, ?MODULE,
|
ejabberd_hooks:add(disco_local_identity, Host, ?MODULE,
|
||||||
get_local_identity, 99),
|
get_local_identity, 99),
|
||||||
ejabberd_hooks:add(disco_local_features, Host, ?MODULE,
|
ejabberd_hooks:add(disco_local_features, Host, ?MODULE,
|
||||||
@ -88,16 +86,8 @@ stop(Host) ->
|
|||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
||||||
?NS_COMMANDS).
|
?NS_COMMANDS).
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
ok.
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_COMMANDS,
|
|
||||||
?MODULE, process_local_iq, IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_COMMANDS,
|
|
||||||
?MODULE, process_sm_iq, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
%-------------------------------------------------------------------------
|
%-------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -280,10 +270,8 @@ ping_command(Acc, _From, _To, _Request) -> Acc.
|
|||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(report_commands_node) ->
|
mod_opt_type(report_commands_node) ->
|
||||||
fun (B) when is_boolean(B) -> B end.
|
fun (B) when is_boolean(B) -> B end.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(_Host) ->
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)},
|
[{report_commands_node, false}].
|
||||||
{report_commands_node, false}].
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
-protocol({xep, 191, '1.2'}).
|
-protocol({xep, 191, '1.2'}).
|
||||||
|
|
||||||
-export([start/2, stop/1, reload/3, process_iq/1, mod_opt_type/1, depends/2,
|
-export([start/2, stop/1, reload/3, process_iq/1, depends/2,
|
||||||
disco_features/5, mod_options/1]).
|
disco_features/5, mod_options/1]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -39,24 +39,17 @@
|
|||||||
|
|
||||||
-include("mod_privacy.hrl").
|
-include("mod_privacy.hrl").
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, _Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
ejabberd_hooks:add(disco_local_features, Host, ?MODULE, disco_features, 50),
|
ejabberd_hooks:add(disco_local_features, Host, ?MODULE, disco_features, 50),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_BLOCKING, ?MODULE, process_iq, IQDisc).
|
?NS_BLOCKING, ?MODULE, process_iq).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, disco_features, 50),
|
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, disco_features, 50),
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_BLOCKING).
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_BLOCKING).
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
ok.
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_BLOCKING,
|
|
||||||
?MODULE, process_iq, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[{mod_privacy, hard}].
|
[{mod_privacy, hard}].
|
||||||
@ -267,7 +260,5 @@ err_db_failure(#iq{lang = Lang} = IQ) ->
|
|||||||
Txt = <<"Database failure">>,
|
Txt = <<"Database failure">>,
|
||||||
xmpp:make_error(IQ, xmpp:err_internal_server_error(Txt, Lang)).
|
xmpp:make_error(IQ, xmpp:err_internal_server_error(Txt, Lang)).
|
||||||
|
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1.
|
mod_options(_Host) ->
|
||||||
|
[].
|
||||||
mod_options(Host) ->
|
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)}].
|
|
||||||
|
@ -62,7 +62,6 @@ is_carbon_copy(_) ->
|
|||||||
false.
|
false.
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
ejabberd_hooks:add(disco_local_features, Host, ?MODULE, disco_features, 50),
|
ejabberd_hooks:add(disco_local_features, Host, ?MODULE, disco_features, 50),
|
||||||
Mod = gen_mod:ram_db_mod(Host, ?MODULE),
|
Mod = gen_mod:ram_db_mod(Host, ?MODULE),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
@ -72,7 +71,7 @@ start(Host, Opts) ->
|
|||||||
%% why priority 89: to define clearly that we must run BEFORE mod_logdb hook (90)
|
%% why priority 89: to define clearly that we must run BEFORE mod_logdb hook (90)
|
||||||
ejabberd_hooks:add(user_send_packet,Host, ?MODULE, user_send_packet, 89),
|
ejabberd_hooks:add(user_send_packet,Host, ?MODULE, user_send_packet, 89),
|
||||||
ejabberd_hooks:add(user_receive_packet,Host, ?MODULE, user_receive_packet, 89),
|
ejabberd_hooks:add(user_receive_packet,Host, ?MODULE, user_receive_packet, 89),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_CARBONS_2, ?MODULE, iq_handler, IQDisc).
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_CARBONS_2, ?MODULE, iq_handler).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_CARBONS_2),
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_CARBONS_2),
|
||||||
@ -95,13 +94,6 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
ets_cache:new(?CARBONCOPY_CACHE, cache_opts(NewOpts));
|
ets_cache:new(?CARBONCOPY_CACHE, cache_opts(NewOpts));
|
||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end,
|
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_CARBONS_2,
|
|
||||||
?MODULE, iq_handler, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec disco_features({error, stanza_error()} | {result, [binary()]} | empty,
|
-spec disco_features({error, stanza_error()} | {result, [binary()]} | empty,
|
||||||
@ -378,7 +370,6 @@ delete_cache(Mod, User, Server) ->
|
|||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(ram_db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
mod_opt_type(ram_db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
||||||
mod_opt_type(O) when O == use_cache; O == cache_missed ->
|
mod_opt_type(O) when O == use_cache; O == cache_missed ->
|
||||||
fun(B) when is_boolean(B) -> B end;
|
fun(B) when is_boolean(B) -> B end;
|
||||||
@ -389,8 +380,7 @@ mod_opt_type(O) when O == cache_size; O == cache_life_time ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(Host) ->
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)},
|
[{ram_db_type, ejabberd_config:default_ram_db(Host, ?MODULE)},
|
||||||
{ram_db_type, ejabberd_config:default_ram_db(Host, ?MODULE)},
|
|
||||||
{use_cache, ejabberd_config:use_cache(Host)},
|
{use_cache, ejabberd_config:use_cache(Host)},
|
||||||
{cache_size, ejabberd_config:cache_size(Host)},
|
{cache_size, ejabberd_config:cache_size(Host)},
|
||||||
{cache_missed, ejabberd_config:cache_missed(Host)},
|
{cache_missed, ejabberd_config:cache_missed(Host)},
|
||||||
|
@ -61,7 +61,6 @@ stop(Host) ->
|
|||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(namespaces) ->
|
mod_opt_type(namespaces) ->
|
||||||
fun(L) ->
|
fun(L) ->
|
||||||
lists:map(
|
lists:map(
|
||||||
@ -72,9 +71,8 @@ mod_opt_type(namespaces) ->
|
|||||||
end, L)
|
end, L)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(_Host) ->
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)},
|
[{namespaces, []}].
|
||||||
{namespaces, []}].
|
|
||||||
|
|
||||||
depends(_, _) ->
|
depends(_, _) ->
|
||||||
[].
|
[].
|
||||||
@ -295,7 +293,7 @@ process_disco_info(State, Type, Host, NS, Info) ->
|
|||||||
sub_els = [#delegation{delegated = [#delegated{ns = NS}]}]},
|
sub_els = [#delegation{delegated = [#delegated{ns = NS}]}]},
|
||||||
Delegations = dict:store({NS, Type}, {Host, Info}, State#state.delegations),
|
Delegations = dict:store({NS, Type}, {Host, Info}, State#state.delegations),
|
||||||
gen_iq_handler:add_iq_handler(Type, State#state.server_host, NS,
|
gen_iq_handler:add_iq_handler(Type, State#state.server_host, NS,
|
||||||
?MODULE, Type, gen_iq_handler:iqdisc(Host)),
|
?MODULE, Type),
|
||||||
ejabberd_router:route(Msg),
|
ejabberd_router:route(Msg),
|
||||||
?INFO_MSG("Namespace '~s' is delegated to external component '~s'",
|
?INFO_MSG("Namespace '~s' is delegated to external component '~s'",
|
||||||
[NS, Host]),
|
[NS, Host]),
|
||||||
|
@ -51,19 +51,16 @@
|
|||||||
-type items_acc() :: {error, stanza_error()} | {result, [disco_item()]} | empty.
|
-type items_acc() :: {error, stanza_error()} | {result, [disco_item()]} | empty.
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
||||||
?NS_DISCO_ITEMS, ?MODULE,
|
?NS_DISCO_ITEMS, ?MODULE,
|
||||||
process_local_iq_items, IQDisc),
|
process_local_iq_items),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
||||||
?NS_DISCO_INFO, ?MODULE,
|
?NS_DISCO_INFO, ?MODULE,
|
||||||
process_local_iq_info, IQDisc),
|
process_local_iq_info),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_DISCO_ITEMS, ?MODULE, process_sm_iq_items,
|
?NS_DISCO_ITEMS, ?MODULE, process_sm_iq_items),
|
||||||
IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_DISCO_INFO, ?MODULE, process_sm_iq_info,
|
?NS_DISCO_INFO, ?MODULE, process_sm_iq_info),
|
||||||
IQDisc),
|
|
||||||
catch ets:new(disco_extra_domains,
|
catch ets:new(disco_extra_domains,
|
||||||
[named_table, ordered_set, public,
|
[named_table, ordered_set, public,
|
||||||
{heir, erlang:group_leader(), none}]),
|
{heir, erlang:group_leader(), none}]),
|
||||||
@ -128,23 +125,6 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
end, OldDomains -- NewDomains);
|
end, OldDomains -- NewDomains);
|
||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end,
|
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
|
||||||
?NS_DISCO_ITEMS, ?MODULE,
|
|
||||||
process_local_iq_items, IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
|
||||||
?NS_DISCO_INFO, ?MODULE,
|
|
||||||
process_local_iq_info, IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
|
||||||
?NS_DISCO_ITEMS, ?MODULE, process_sm_iq_items,
|
|
||||||
IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
|
||||||
?NS_DISCO_INFO, ?MODULE, process_sm_iq_info,
|
|
||||||
IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec register_extra_domain(binary(), binary()) -> true.
|
-spec register_extra_domain(binary(), binary()) -> true.
|
||||||
@ -458,7 +438,6 @@ depends(_Host, _Opts) ->
|
|||||||
|
|
||||||
mod_opt_type(extra_domains) ->
|
mod_opt_type(extra_domains) ->
|
||||||
fun (Hs) -> [iolist_to_binary(H) || H <- Hs] end;
|
fun (Hs) -> [iolist_to_binary(H) || H <- Hs] end;
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(name) -> fun iolist_to_binary/1;
|
mod_opt_type(name) -> fun iolist_to_binary/1;
|
||||||
mod_opt_type(server_info) ->
|
mod_opt_type(server_info) ->
|
||||||
fun (L) ->
|
fun (L) ->
|
||||||
@ -471,8 +450,7 @@ mod_opt_type(server_info) ->
|
|||||||
L)
|
L)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(_Host) ->
|
||||||
[{extra_domains, []},
|
[{extra_domains, []},
|
||||||
{iqdisc, gen_iq_handler:iqdisc(Host)},
|
|
||||||
{server_info, []},
|
{server_info, []},
|
||||||
{name, ?T("ejabberd")}].
|
{name, ?T("ejabberd")}].
|
||||||
|
@ -101,10 +101,9 @@ init([Host, Opts]) ->
|
|||||||
catch ets:new(irc_connection,
|
catch ets:new(irc_connection,
|
||||||
[named_table, public,
|
[named_table, public,
|
||||||
{keypos, #irc_connection.jid_server_host}]),
|
{keypos, #irc_connection.jid_server_host}]),
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(MyHost) ->
|
fun(MyHost) ->
|
||||||
register_hooks(MyHost, IQDisc),
|
register_hooks(MyHost),
|
||||||
ejabberd_router:register_route(MyHost, Host)
|
ejabberd_router:register_route(MyHost, Host)
|
||||||
end, MyHosts),
|
end, MyHosts),
|
||||||
{ok,
|
{ok,
|
||||||
@ -132,8 +131,6 @@ handle_call(stop, _From, State) ->
|
|||||||
handle_cast({reload, ServerHost, NewOpts, OldOpts}, State) ->
|
handle_cast({reload, ServerHost, NewOpts, OldOpts}, State) ->
|
||||||
NewHosts = gen_mod:get_opt_hosts(ServerHost, NewOpts),
|
NewHosts = gen_mod:get_opt_hosts(ServerHost, NewOpts),
|
||||||
OldHosts = gen_mod:get_opt_hosts(ServerHost, OldOpts),
|
OldHosts = gen_mod:get_opt_hosts(ServerHost, OldOpts),
|
||||||
NewIQDisc = gen_mod:get_opt(iqdisc, NewOpts),
|
|
||||||
OldIQDisc = gen_mod:get_opt(iqdisc, OldOpts),
|
|
||||||
NewMod = gen_mod:db_mod(ServerHost, NewOpts, ?MODULE),
|
NewMod = gen_mod:db_mod(ServerHost, NewOpts, ?MODULE),
|
||||||
OldMod = gen_mod:db_mod(ServerHost, OldOpts, ?MODULE),
|
OldMod = gen_mod:db_mod(ServerHost, OldOpts, ?MODULE),
|
||||||
Access = gen_mod:get_opt(access, NewOpts),
|
Access = gen_mod:get_opt(access, NewOpts),
|
||||||
@ -142,18 +139,10 @@ handle_cast({reload, ServerHost, NewOpts, OldOpts}, State) ->
|
|||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
if (NewIQDisc /= OldIQDisc) ->
|
|
||||||
lists:foreach(
|
|
||||||
fun(NewHost) ->
|
|
||||||
register_hooks(NewHost, NewIQDisc)
|
|
||||||
end, NewHosts -- (NewHosts -- OldHosts));
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end,
|
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(NewHost) ->
|
fun(NewHost) ->
|
||||||
ejabberd_router:register_route(NewHost, ServerHost),
|
ejabberd_router:register_route(NewHost, ServerHost),
|
||||||
register_hooks(NewHost, NewIQDisc)
|
register_hooks(NewHost)
|
||||||
end, NewHosts -- OldHosts),
|
end, NewHosts -- OldHosts),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(OldHost) ->
|
fun(OldHost) ->
|
||||||
@ -207,17 +196,17 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
|||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
register_hooks(Host, IQDisc) ->
|
register_hooks(Host) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO,
|
||||||
?MODULE, process_disco_info, IQDisc),
|
?MODULE, process_disco_info),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS,
|
||||||
?MODULE, process_disco_items, IQDisc),
|
?MODULE, process_disco_items),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_REGISTER,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_REGISTER,
|
||||||
?MODULE, process_register, IQDisc),
|
?MODULE, process_register),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
||||||
?MODULE, process_vcard, IQDisc),
|
?MODULE, process_vcard),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_COMMANDS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_COMMANDS,
|
||||||
?MODULE, process_command, IQDisc).
|
?MODULE, process_command).
|
||||||
|
|
||||||
unregister_hooks(Host) ->
|
unregister_hooks(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO),
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO),
|
||||||
@ -989,13 +978,11 @@ mod_opt_type(hosts) ->
|
|||||||
mod_opt_type(realname) ->
|
mod_opt_type(realname) ->
|
||||||
fun iolist_to_binary/1;
|
fun iolist_to_binary/1;
|
||||||
mod_opt_type(webirc_password) ->
|
mod_opt_type(webirc_password) ->
|
||||||
fun iolist_to_binary/1;
|
fun iolist_to_binary/1.
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1.
|
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(Host) ->
|
||||||
[{access, all},
|
[{access, all},
|
||||||
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||||
{iqdisc, gen_iq_handler:iqdisc(Host)},
|
|
||||||
{default_encoding, <<"iso8859-15">>},
|
{default_encoding, <<"iso8859-15">>},
|
||||||
{host, <<"irc.@HOST@">>},
|
{host, <<"irc.@HOST@">>},
|
||||||
{hosts, []},
|
{hosts, []},
|
||||||
|
@ -59,14 +59,13 @@
|
|||||||
-optional_callbacks([use_cache/1, cache_nodes/1]).
|
-optional_callbacks([use_cache/1, cache_nodes/1]).
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
||||||
?NS_LAST, ?MODULE, process_local_iq, IQDisc),
|
?NS_LAST, ?MODULE, process_local_iq),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_LAST, ?MODULE, process_sm_iq, IQDisc),
|
?NS_LAST, ?MODULE, process_sm_iq),
|
||||||
ejabberd_hooks:add(privacy_check_packet, Host, ?MODULE,
|
ejabberd_hooks:add(privacy_check_packet, Host, ?MODULE,
|
||||||
privacy_check_packet, 30),
|
privacy_check_packet, 30),
|
||||||
ejabberd_hooks:add(register_user, Host, ?MODULE,
|
ejabberd_hooks:add(register_user, Host, ?MODULE,
|
||||||
@ -98,16 +97,7 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
init_cache(NewMod, Host, NewOpts),
|
init_cache(NewMod, Host, NewOpts).
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_LAST,
|
|
||||||
?MODULE, process_local_iq, IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_LAST,
|
|
||||||
?MODULE, process_sm_iq, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
%%%
|
%%%
|
||||||
%%% Uptime of ejabberd node
|
%%% Uptime of ejabberd node
|
||||||
@ -331,7 +321,6 @@ depends(_Host, _Opts) ->
|
|||||||
[].
|
[].
|
||||||
|
|
||||||
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(O) when O == cache_life_time; O == cache_size ->
|
mod_opt_type(O) when O == cache_life_time; O == cache_size ->
|
||||||
fun (I) when is_integer(I), I > 0 -> I;
|
fun (I) when is_integer(I), I > 0 -> I;
|
||||||
(infinity) -> infinity
|
(infinity) -> infinity
|
||||||
@ -340,8 +329,7 @@ mod_opt_type(O) when O == use_cache; O == cache_missed ->
|
|||||||
fun (B) when is_boolean(B) -> B end.
|
fun (B) when is_boolean(B) -> B end.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(Host) ->
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)},
|
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||||
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
|
||||||
{use_cache, ejabberd_config:use_cache(Host)},
|
{use_cache, ejabberd_config:use_cache(Host)},
|
||||||
{cache_size, ejabberd_config:cache_size(Host)},
|
{cache_size, ejabberd_config:cache_size(Host)},
|
||||||
{cache_missed, ejabberd_config:cache_missed(Host)},
|
{cache_missed, ejabberd_config:cache_missed(Host)},
|
||||||
|
@ -75,11 +75,10 @@
|
|||||||
%%% API
|
%%% API
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Host, Opts),
|
init_cache(Host, Opts),
|
||||||
register_iq_handlers(Host, IQDisc),
|
register_iq_handlers(Host),
|
||||||
ejabberd_hooks:add(sm_receive_packet, Host, ?MODULE,
|
ejabberd_hooks:add(sm_receive_packet, Host, ?MODULE,
|
||||||
sm_receive_packet, 50),
|
sm_receive_packet, 50),
|
||||||
ejabberd_hooks:add(user_receive_packet, Host, ?MODULE,
|
ejabberd_hooks:add(user_receive_packet, Host, ?MODULE,
|
||||||
@ -187,12 +186,6 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
ets_cache:setopts(archive_prefs_cache, cache_opts(NewOpts)),
|
ets_cache:setopts(archive_prefs_cache, cache_opts(NewOpts)),
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
|
||||||
{false, IQDisc, _} ->
|
|
||||||
register_iq_handlers(Host, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end,
|
|
||||||
case gen_mod:is_equal_opt(assume_mam_usage, NewOpts, OldOpts) of
|
case gen_mod:is_equal_opt(assume_mam_usage, NewOpts, OldOpts) of
|
||||||
{false, true, _} ->
|
{false, true, _} ->
|
||||||
ejabberd_hooks:add(message_is_archived, Host, ?MODULE,
|
ejabberd_hooks:add(message_is_archived, Host, ?MODULE,
|
||||||
@ -207,24 +200,24 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
-spec register_iq_handlers(binary(), gen_iq_handler:type()) -> ok.
|
-spec register_iq_handlers(binary()) -> ok.
|
||||||
register_iq_handlers(Host, IQDisc) ->
|
register_iq_handlers(Host) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MAM_TMP,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MAM_TMP,
|
||||||
?MODULE, process_iq_v0_2, IQDisc),
|
?MODULE, process_iq_v0_2),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM_TMP,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM_TMP,
|
||||||
?MODULE, process_iq_v0_2, IQDisc),
|
?MODULE, process_iq_v0_2),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MAM_0,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MAM_0,
|
||||||
?MODULE, process_iq_v0_3, IQDisc),
|
?MODULE, process_iq_v0_3),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM_0, ?MODULE,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM_0, ?MODULE,
|
||||||
process_iq_v0_3, IQDisc),
|
process_iq_v0_3),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MAM_1,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MAM_1,
|
||||||
?MODULE, process_iq_v0_3, IQDisc),
|
?MODULE, process_iq_v0_3),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM_1,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM_1,
|
||||||
?MODULE, process_iq_v0_3, IQDisc),
|
?MODULE, process_iq_v0_3),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MAM_2,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MAM_2,
|
||||||
?MODULE, process_iq_v0_3, IQDisc),
|
?MODULE, process_iq_v0_3),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM_2,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM_2,
|
||||||
?MODULE, process_iq_v0_3, IQDisc).
|
?MODULE, process_iq_v0_3).
|
||||||
|
|
||||||
-spec unregister_iq_handlers(binary()) -> ok.
|
-spec unregister_iq_handlers(binary()) -> ok.
|
||||||
unregister_iq_handlers(Host) ->
|
unregister_iq_handlers(Host) ->
|
||||||
@ -1076,7 +1069,6 @@ mod_opt_type(default) ->
|
|||||||
(never) -> never;
|
(never) -> never;
|
||||||
(roster) -> roster
|
(roster) -> roster
|
||||||
end;
|
end;
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(request_activates_archiving) ->
|
mod_opt_type(request_activates_archiving) ->
|
||||||
fun (B) when is_boolean(B) -> B end.
|
fun (B) when is_boolean(B) -> B end.
|
||||||
|
|
||||||
@ -1084,7 +1076,6 @@ mod_options(Host) ->
|
|||||||
[{assume_mam_usage, false},
|
[{assume_mam_usage, false},
|
||||||
{default, never},
|
{default, never},
|
||||||
{request_activates_archiving, false},
|
{request_activates_archiving, false},
|
||||||
{iqdisc, gen_iq_handler:iqdisc(Host)},
|
|
||||||
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||||
{use_cache, ejabberd_config:use_cache(Host)},
|
{use_cache, ejabberd_config:use_cache(Host)},
|
||||||
{cache_size, ejabberd_config:cache_size(Host)},
|
{cache_size, ejabberd_config:cache_size(Host)},
|
||||||
|
@ -125,7 +125,6 @@ process_iq(#iq{lang = Lang} = IQ) ->
|
|||||||
init([ServerHost, Opts]) ->
|
init([ServerHost, Opts]) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
Hosts = gen_mod:get_opt_hosts(ServerHost, Opts),
|
Hosts = gen_mod:get_opt_hosts(ServerHost, Opts),
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(Host) ->
|
fun(Host) ->
|
||||||
ConfigTab = gen_mod:get_module_proc(Host, config),
|
ConfigTab = gen_mod:get_module_proc(Host, config),
|
||||||
@ -140,20 +139,20 @@ init([ServerHost, Opts]) ->
|
|||||||
ejabberd_hooks:add(disco_info, Host, ?MODULE, disco_info, 100),
|
ejabberd_hooks:add(disco_info, Host, ?MODULE, disco_info, 100),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
||||||
?NS_DISCO_ITEMS, mod_disco,
|
?NS_DISCO_ITEMS, mod_disco,
|
||||||
process_local_iq_items, IQDisc),
|
process_local_iq_items),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
||||||
?NS_DISCO_INFO, mod_disco,
|
?NS_DISCO_INFO, mod_disco,
|
||||||
process_local_iq_info, IQDisc),
|
process_local_iq_info),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_DISCO_ITEMS, mod_disco,
|
?NS_DISCO_ITEMS, mod_disco,
|
||||||
process_local_iq_items, IQDisc),
|
process_local_iq_items),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_DISCO_INFO, mod_disco,
|
?NS_DISCO_INFO, mod_disco,
|
||||||
process_local_iq_info, IQDisc),
|
process_local_iq_info),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_PUBSUB, mod_pubsub, iq_sm, IQDisc),
|
?NS_PUBSUB, mod_pubsub, iq_sm),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_MIX_0, ?MODULE, process_iq, IQDisc),
|
?NS_MIX_0, ?MODULE, process_iq),
|
||||||
ejabberd_router:register_route(Host, ServerHost)
|
ejabberd_router:register_route(Host, ServerHost)
|
||||||
end, Hosts),
|
end, Hosts),
|
||||||
{ok, #state{server_host = ServerHost, hosts = Hosts}}.
|
{ok, #state{server_host = ServerHost, hosts = Hosts}}.
|
||||||
@ -316,12 +315,10 @@ is_not_subscribed({error, StanzaError}) ->
|
|||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[{mod_pubsub, hard}].
|
[{mod_pubsub, hard}].
|
||||||
|
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(host) -> fun iolist_to_binary/1;
|
mod_opt_type(host) -> fun iolist_to_binary/1;
|
||||||
mod_opt_type(hosts) ->
|
mod_opt_type(hosts) ->
|
||||||
fun (L) -> lists:map(fun iolist_to_binary/1, L) end.
|
fun (L) -> lists:map(fun iolist_to_binary/1, L) end.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(_Host) ->
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)},
|
[{host, <<"mix.@HOST@">>},
|
||||||
{host, <<"mix.@HOST@">>},
|
|
||||||
{hosts, []}].
|
{hosts, []}].
|
||||||
|
@ -233,7 +233,6 @@ get_online_rooms_by_user(ServerHost, LUser, LServer) ->
|
|||||||
|
|
||||||
init([Host, Opts]) ->
|
init([Host, Opts]) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
#state{access = Access, hosts = MyHosts,
|
#state{access = Access, hosts = MyHosts,
|
||||||
history_size = HistorySize, queue_type = QueueType,
|
history_size = HistorySize, queue_type = QueueType,
|
||||||
room_shaper = RoomShaper} = State = init_state(Host, Opts),
|
room_shaper = RoomShaper} = State = init_state(Host, Opts),
|
||||||
@ -243,7 +242,7 @@ init([Host, Opts]) ->
|
|||||||
RMod:init(Host, [{hosts, MyHosts}|Opts]),
|
RMod:init(Host, [{hosts, MyHosts}|Opts]),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(MyHost) ->
|
fun(MyHost) ->
|
||||||
register_iq_handlers(MyHost, IQDisc),
|
register_iq_handlers(MyHost),
|
||||||
ejabberd_router:register_route(MyHost, Host),
|
ejabberd_router:register_route(MyHost, Host),
|
||||||
load_permanent_rooms(MyHost, Host, Access, HistorySize,
|
load_permanent_rooms(MyHost, Host, Access, HistorySize,
|
||||||
RoomShaper, QueueType)
|
RoomShaper, QueueType)
|
||||||
@ -273,8 +272,6 @@ handle_call({create, Room, Host, From, Nick, Opts}, _From,
|
|||||||
{reply, ok, State}.
|
{reply, ok, State}.
|
||||||
|
|
||||||
handle_cast({reload, ServerHost, NewOpts, OldOpts}, #state{hosts = OldHosts}) ->
|
handle_cast({reload, ServerHost, NewOpts, OldOpts}, #state{hosts = OldHosts}) ->
|
||||||
NewIQDisc = gen_mod:get_opt(iqdisc, NewOpts),
|
|
||||||
OldIQDisc = gen_mod:get_opt(iqdisc, OldOpts),
|
|
||||||
NewMod = gen_mod:db_mod(ServerHost, NewOpts, ?MODULE),
|
NewMod = gen_mod:db_mod(ServerHost, NewOpts, ?MODULE),
|
||||||
NewRMod = gen_mod:ram_db_mod(ServerHost, NewOpts, ?MODULE),
|
NewRMod = gen_mod:ram_db_mod(ServerHost, NewOpts, ?MODULE),
|
||||||
OldMod = gen_mod:db_mod(ServerHost, OldOpts, ?MODULE),
|
OldMod = gen_mod:db_mod(ServerHost, OldOpts, ?MODULE),
|
||||||
@ -290,18 +287,10 @@ handle_cast({reload, ServerHost, NewOpts, OldOpts}, #state{hosts = OldHosts}) ->
|
|||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
if (NewIQDisc /= OldIQDisc) ->
|
|
||||||
lists:foreach(
|
|
||||||
fun(NewHost) ->
|
|
||||||
register_iq_handlers(NewHost, NewIQDisc)
|
|
||||||
end, NewHosts -- (NewHosts -- OldHosts));
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end,
|
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(NewHost) ->
|
fun(NewHost) ->
|
||||||
ejabberd_router:register_route(NewHost, ServerHost),
|
ejabberd_router:register_route(NewHost, ServerHost),
|
||||||
register_iq_handlers(NewHost, NewIQDisc)
|
register_iq_handlers(NewHost)
|
||||||
end, NewHosts -- OldHosts),
|
end, NewHosts -- OldHosts),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(OldHost) ->
|
fun(OldHost) ->
|
||||||
@ -372,19 +361,19 @@ init_state(Host, Opts) ->
|
|||||||
max_rooms_discoitems = MaxRoomsDiscoItems,
|
max_rooms_discoitems = MaxRoomsDiscoItems,
|
||||||
room_shaper = RoomShaper}.
|
room_shaper = RoomShaper}.
|
||||||
|
|
||||||
register_iq_handlers(Host, IQDisc) ->
|
register_iq_handlers(Host) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_REGISTER,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_REGISTER,
|
||||||
?MODULE, process_register, IQDisc),
|
?MODULE, process_register),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
||||||
?MODULE, process_vcard, IQDisc),
|
?MODULE, process_vcard),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MUCSUB,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MUCSUB,
|
||||||
?MODULE, process_mucsub, IQDisc),
|
?MODULE, process_mucsub),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MUC_UNIQUE,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_MUC_UNIQUE,
|
||||||
?MODULE, process_muc_unique, IQDisc),
|
?MODULE, process_muc_unique),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO,
|
||||||
?MODULE, process_disco_info, IQDisc),
|
?MODULE, process_disco_info),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS,
|
||||||
?MODULE, process_disco_items, IQDisc).
|
?MODULE, process_disco_items).
|
||||||
|
|
||||||
unregister_iq_handlers(Host) ->
|
unregister_iq_handlers(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_REGISTER),
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_REGISTER),
|
||||||
@ -972,8 +961,7 @@ mod_opt_type({default_room_options, presence_broadcast}) ->
|
|||||||
(participant) -> participant;
|
(participant) -> participant;
|
||||||
(visitor) -> visitor
|
(visitor) -> visitor
|
||||||
end, L)
|
end, L)
|
||||||
end;
|
end.
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1.
|
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(Host) ->
|
||||||
[{access, all},
|
[{access, all},
|
||||||
@ -982,7 +970,6 @@ mod_options(Host) ->
|
|||||||
{access_persistent, all},
|
{access_persistent, all},
|
||||||
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||||
{ram_db_type, ejabberd_config:default_ram_db(Host, ?MODULE)},
|
{ram_db_type, ejabberd_config:default_ram_db(Host, ?MODULE)},
|
||||||
{iqdisc, gen_iq_handler:iqdisc(Host)},
|
|
||||||
{history_size, 20},
|
{history_size, 20},
|
||||||
{host, <<"conference.@HOST@">>},
|
{host, <<"conference.@HOST@">>},
|
||||||
{hosts, []},
|
{hosts, []},
|
||||||
|
@ -108,7 +108,6 @@ depends(_Host, _Opts) ->
|
|||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
ejabberd_hooks:add(offline_message_hook, Host, ?MODULE,
|
ejabberd_hooks:add(offline_message_hook, Host, ?MODULE,
|
||||||
store_packet, 50),
|
store_packet, 50),
|
||||||
ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE, c2s_self_presence, 50),
|
ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE, c2s_self_presence, 50),
|
||||||
@ -132,7 +131,7 @@ start(Host, Opts) ->
|
|||||||
ejabberd_hooks:add(webadmin_user_parse_query, Host,
|
ejabberd_hooks:add(webadmin_user_parse_query, Host,
|
||||||
?MODULE, webadmin_user_parse_query, 50),
|
?MODULE, webadmin_user_parse_query, 50),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_FLEX_OFFLINE,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_FLEX_OFFLINE,
|
||||||
?MODULE, handle_offline_query, IQDisc).
|
?MODULE, handle_offline_query).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
ejabberd_hooks:delete(offline_message_hook, Host,
|
ejabberd_hooks:delete(offline_message_hook, Host,
|
||||||
@ -162,13 +161,6 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
NewMod:init(Host, NewOpts);
|
NewMod:init(Host, NewOpts);
|
||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end,
|
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_FLEX_OFFLINE,
|
|
||||||
?MODULE, handle_offline_query, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec store_offline_msg(#offline_msg{}) -> ok | {error, full | any()}.
|
-spec store_offline_msg(#offline_msg{}) -> ok | {error, full | any()}.
|
||||||
@ -849,11 +841,9 @@ mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
|||||||
mod_opt_type(store_empty_body) ->
|
mod_opt_type(store_empty_body) ->
|
||||||
fun (V) when is_boolean(V) -> V;
|
fun (V) when is_boolean(V) -> V;
|
||||||
(unless_chat_state) -> unless_chat_state
|
(unless_chat_state) -> unless_chat_state
|
||||||
end;
|
end.
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1.
|
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(Host) ->
|
||||||
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||||
{iqdisc, gen_iq_handler:iqdisc(Host)},
|
|
||||||
{access_max_user_messages, max_user_offline_messages},
|
{access_max_user_messages, max_user_offline_messages},
|
||||||
{store_empty_body, unless_chat_state}].
|
{store_empty_body, unless_chat_state}].
|
||||||
|
@ -91,8 +91,7 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
init([Host, Opts]) ->
|
init([Host, Opts]) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
State = init_state(Host, Opts),
|
State = init_state(Host, Opts),
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
register_iq_handlers(Host),
|
||||||
register_iq_handlers(Host, IQDisc),
|
|
||||||
case State#state.send_pings of
|
case State#state.send_pings of
|
||||||
true -> register_hooks(Host);
|
true -> register_hooks(Host);
|
||||||
false -> ok
|
false -> ok
|
||||||
@ -108,12 +107,8 @@ handle_call(stop, _From, State) ->
|
|||||||
handle_call(_Req, _From, State) ->
|
handle_call(_Req, _From, State) ->
|
||||||
{reply, {error, badarg}, State}.
|
{reply, {error, badarg}, State}.
|
||||||
|
|
||||||
handle_cast({reload, Host, NewOpts, OldOpts},
|
handle_cast({reload, Host, NewOpts, _OldOpts},
|
||||||
#state{timers = Timers} = OldState) ->
|
#state{timers = Timers} = OldState) ->
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
|
||||||
{false, IQDisc, _} -> register_iq_handlers(Host, IQDisc);
|
|
||||||
true -> ok
|
|
||||||
end,
|
|
||||||
NewState = init_state(Host, NewOpts),
|
NewState = init_state(Host, NewOpts),
|
||||||
case {NewState#state.send_pings, OldState#state.send_pings} of
|
case {NewState#state.send_pings, OldState#state.send_pings} of
|
||||||
{true, false} -> register_hooks(Host);
|
{true, false} -> register_hooks(Host);
|
||||||
@ -219,11 +214,11 @@ unregister_hooks(Host) ->
|
|||||||
ejabberd_hooks:delete(user_send_packet, Host, ?MODULE,
|
ejabberd_hooks:delete(user_send_packet, Host, ?MODULE,
|
||||||
user_send, 100).
|
user_send, 100).
|
||||||
|
|
||||||
register_iq_handlers(Host, IQDisc) ->
|
register_iq_handlers(Host) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PING,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PING,
|
||||||
?MODULE, iq_ping, IQDisc),
|
?MODULE, iq_ping),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_PING,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_PING,
|
||||||
?MODULE, iq_ping, IQDisc).
|
?MODULE, iq_ping).
|
||||||
|
|
||||||
unregister_iq_handlers(Host) ->
|
unregister_iq_handlers(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_PING),
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_PING),
|
||||||
@ -263,7 +258,6 @@ cancel_timer(TRef) ->
|
|||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(ping_interval) ->
|
mod_opt_type(ping_interval) ->
|
||||||
fun (I) when is_integer(I), I > 0 -> I end;
|
fun (I) when is_integer(I), I > 0 -> I end;
|
||||||
mod_opt_type(ping_ack_timeout) ->
|
mod_opt_type(ping_ack_timeout) ->
|
||||||
@ -277,9 +271,8 @@ mod_opt_type(timeout_action) ->
|
|||||||
(kill) -> kill
|
(kill) -> kill
|
||||||
end.
|
end.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(_Host) ->
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)},
|
[{ping_interval, 60},
|
||||||
{ping_interval, 60},
|
|
||||||
{ping_ack_timeout, undefined},
|
{ping_ack_timeout, undefined},
|
||||||
{send_pings, false},
|
{send_pings, false},
|
||||||
{timeout_action, none}].
|
{timeout_action, none}].
|
||||||
|
@ -70,7 +70,6 @@
|
|||||||
-optional_callbacks([use_cache/1, cache_nodes/1]).
|
-optional_callbacks([use_cache/1, cache_nodes/1]).
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
@ -87,7 +86,7 @@ start(Host, Opts) ->
|
|||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
||||||
remove_user, 50),
|
remove_user, 50),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_PRIVACY, ?MODULE, process_iq, IQDisc).
|
?NS_PRIVACY, ?MODULE, process_iq).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE,
|
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE,
|
||||||
@ -113,14 +112,7 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
init_cache(NewMod, Host, NewOpts),
|
init_cache(NewMod, Host, NewOpts).
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVACY,
|
|
||||||
?MODULE, process_iq, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
-spec disco_features({error, stanza_error()} | {result, [binary()]} | empty,
|
-spec disco_features({error, stanza_error()} | {result, [binary()]} | empty,
|
||||||
jid(), jid(), binary(), binary()) ->
|
jid(), jid(), binary(), binary()) ->
|
||||||
@ -837,7 +829,6 @@ depends(_Host, _Opts) ->
|
|||||||
[].
|
[].
|
||||||
|
|
||||||
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(O) when O == cache_life_time; O == cache_size ->
|
mod_opt_type(O) when O == cache_life_time; O == cache_size ->
|
||||||
fun (I) when is_integer(I), I > 0 -> I;
|
fun (I) when is_integer(I), I > 0 -> I;
|
||||||
(infinity) -> infinity
|
(infinity) -> infinity
|
||||||
@ -846,8 +837,7 @@ mod_opt_type(O) when O == use_cache; O == cache_missed ->
|
|||||||
fun (B) when is_boolean(B) -> B end.
|
fun (B) when is_boolean(B) -> B end.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(Host) ->
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)},
|
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||||
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
|
||||||
{use_cache, ejabberd_config:use_cache(Host)},
|
{use_cache, ejabberd_config:use_cache(Host)},
|
||||||
{cache_size, ejabberd_config:cache_size(Host)},
|
{cache_size, ejabberd_config:cache_size(Host)},
|
||||||
{cache_missed, ejabberd_config:cache_missed(Host)},
|
{cache_missed, ejabberd_config:cache_missed(Host)},
|
||||||
|
@ -55,14 +55,13 @@
|
|||||||
-optional_callbacks([use_cache/1, cache_nodes/1]).
|
-optional_callbacks([use_cache/1, cache_nodes/1]).
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
||||||
remove_user, 50),
|
remove_user, 50),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_PRIVATE, ?MODULE, process_sm_iq, IQDisc).
|
?NS_PRIVATE, ?MODULE, process_sm_iq).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
||||||
@ -78,14 +77,7 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
init_cache(NewMod, Host, NewOpts),
|
init_cache(NewMod, Host, NewOpts).
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE,
|
|
||||||
?MODULE, process_sm_iq, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
-spec process_sm_iq(iq()) -> iq().
|
-spec process_sm_iq(iq()) -> iq().
|
||||||
process_sm_iq(#iq{type = Type, lang = Lang,
|
process_sm_iq(#iq{type = Type, lang = Lang,
|
||||||
@ -258,7 +250,6 @@ depends(_Host, _Opts) ->
|
|||||||
[].
|
[].
|
||||||
|
|
||||||
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(O) when O == cache_life_time; O == cache_size ->
|
mod_opt_type(O) when O == cache_life_time; O == cache_size ->
|
||||||
fun (I) when is_integer(I), I > 0 -> I;
|
fun (I) when is_integer(I), I > 0 -> I;
|
||||||
(infinity) -> infinity
|
(infinity) -> infinity
|
||||||
@ -267,8 +258,7 @@ mod_opt_type(O) when O == use_cache; O == cache_missed ->
|
|||||||
fun (B) when is_boolean(B) -> B end.
|
fun (B) when is_boolean(B) -> B end.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(Host) ->
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)},
|
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||||
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
|
||||||
{use_cache, ejabberd_config:use_cache(Host)},
|
{use_cache, ejabberd_config:use_cache(Host)},
|
||||||
{cache_size, ejabberd_config:cache_size(Host)},
|
{cache_size, ejabberd_config:cache_size(Host)},
|
||||||
{cache_missed, ejabberd_config:cache_missed(Host)},
|
{cache_missed, ejabberd_config:cache_missed(Host)},
|
||||||
|
@ -137,14 +137,11 @@ mod_opt_type(max_connections) ->
|
|||||||
end;
|
end;
|
||||||
mod_opt_type(ram_db_type) ->
|
mod_opt_type(ram_db_type) ->
|
||||||
fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
||||||
mod_opt_type(iqdisc) ->
|
|
||||||
fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(Opt) ->
|
mod_opt_type(Opt) ->
|
||||||
mod_proxy65_stream:listen_opt_type(Opt).
|
mod_proxy65_stream:listen_opt_type(Opt).
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(Host) ->
|
||||||
[{ram_db_type, ejabberd_config:default_ram_db(Host, ?MODULE)},
|
[{ram_db_type, ejabberd_config:default_ram_db(Host, ?MODULE)},
|
||||||
{iqdisc, gen_iq_handler:iqdisc(Host)},
|
|
||||||
{access, all},
|
{access, all},
|
||||||
{host, <<"proxy.@HOST@">>},
|
{host, <<"proxy.@HOST@">>},
|
||||||
{hosts, []},
|
{hosts, []},
|
||||||
|
@ -61,18 +61,17 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
|
|
||||||
init([Host, Opts]) ->
|
init([Host, Opts]) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
MyHosts = gen_mod:get_opt_hosts(Host, Opts),
|
MyHosts = gen_mod:get_opt_hosts(Host, Opts),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(MyHost) ->
|
fun(MyHost) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, MyHost, ?NS_DISCO_INFO,
|
gen_iq_handler:add_iq_handler(ejabberd_local, MyHost, ?NS_DISCO_INFO,
|
||||||
?MODULE, process_disco_info, IQDisc),
|
?MODULE, process_disco_info),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, MyHost, ?NS_DISCO_ITEMS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, MyHost, ?NS_DISCO_ITEMS,
|
||||||
?MODULE, process_disco_items, IQDisc),
|
?MODULE, process_disco_items),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, MyHost, ?NS_VCARD,
|
gen_iq_handler:add_iq_handler(ejabberd_local, MyHost, ?NS_VCARD,
|
||||||
?MODULE, process_vcard, IQDisc),
|
?MODULE, process_vcard),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, MyHost, ?NS_BYTESTREAMS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, MyHost, ?NS_BYTESTREAMS,
|
||||||
?MODULE, process_bytestreams, IQDisc),
|
?MODULE, process_bytestreams),
|
||||||
ejabberd_router:register_route(MyHost, Host)
|
ejabberd_router:register_route(MyHost, Host)
|
||||||
end, MyHosts),
|
end, MyHosts),
|
||||||
{ok, #state{myhosts = MyHosts}}.
|
{ok, #state{myhosts = MyHosts}}.
|
||||||
@ -95,20 +94,10 @@ handle_call(_Request, _From, State) ->
|
|||||||
handle_cast({reload, ServerHost, NewOpts, OldOpts}, State) ->
|
handle_cast({reload, ServerHost, NewOpts, OldOpts}, State) ->
|
||||||
NewHosts = gen_mod:get_opt_hosts(ServerHost, NewOpts),
|
NewHosts = gen_mod:get_opt_hosts(ServerHost, NewOpts),
|
||||||
OldHosts = gen_mod:get_opt_hosts(ServerHost, OldOpts),
|
OldHosts = gen_mod:get_opt_hosts(ServerHost, OldOpts),
|
||||||
NewIQDisc = gen_mod:get_opt(iqdisc, NewOpts),
|
|
||||||
OldIQDisc = gen_mod:get_opt(iqdisc, OldOpts),
|
|
||||||
if (NewIQDisc /= OldIQDisc) ->
|
|
||||||
lists:foreach(
|
|
||||||
fun(NewHost) ->
|
|
||||||
register_handlers(NewHost, NewIQDisc)
|
|
||||||
end, NewHosts -- (NewHosts -- OldHosts));
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end,
|
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(NewHost) ->
|
fun(NewHost) ->
|
||||||
ejabberd_router:register_route(NewHost, ServerHost),
|
ejabberd_router:register_route(NewHost, ServerHost),
|
||||||
register_handlers(NewHost, NewIQDisc)
|
register_handlers(NewHost)
|
||||||
end, NewHosts -- OldHosts),
|
end, NewHosts -- OldHosts),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(OldHost) ->
|
fun(OldHost) ->
|
||||||
@ -282,15 +271,15 @@ get_my_ip() ->
|
|||||||
max_connections(ServerHost) ->
|
max_connections(ServerHost) ->
|
||||||
gen_mod:get_module_opt(ServerHost, mod_proxy65, max_connections).
|
gen_mod:get_module_opt(ServerHost, mod_proxy65, max_connections).
|
||||||
|
|
||||||
register_handlers(Host, IQDisc) ->
|
register_handlers(Host) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO,
|
||||||
?MODULE, process_disco_info, IQDisc),
|
?MODULE, process_disco_info),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS,
|
||||||
?MODULE, process_disco_items, IQDisc),
|
?MODULE, process_disco_items),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
||||||
?MODULE, process_vcard, IQDisc),
|
?MODULE, process_vcard),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_BYTESTREAMS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_BYTESTREAMS,
|
||||||
?MODULE, process_bytestreams, IQDisc).
|
?MODULE, process_bytestreams).
|
||||||
|
|
||||||
unregister_handlers(Host) ->
|
unregister_handlers(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO),
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO),
|
||||||
|
@ -244,7 +244,6 @@ init([ServerHost, Opts]) ->
|
|||||||
Hosts = gen_mod:get_opt_hosts(ServerHost, Opts),
|
Hosts = gen_mod:get_opt_hosts(ServerHost, Opts),
|
||||||
Access = gen_mod:get_opt(access_createnode, Opts),
|
Access = gen_mod:get_opt(access_createnode, Opts),
|
||||||
PepOffline = gen_mod:get_opt(ignore_pep_from_offline, Opts),
|
PepOffline = gen_mod:get_opt(ignore_pep_from_offline, Opts),
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
LastItemCache = gen_mod:get_opt(last_item_cache, Opts),
|
LastItemCache = gen_mod:get_opt(last_item_cache, Opts),
|
||||||
MaxItemsNode = gen_mod:get_opt(max_items_node, Opts),
|
MaxItemsNode = gen_mod:get_opt(max_items_node, Opts),
|
||||||
MaxSubsNode = gen_mod:get_opt(max_subscriptions_node, Opts),
|
MaxSubsNode = gen_mod:get_opt(max_subscriptions_node, Opts),
|
||||||
@ -284,17 +283,17 @@ init([ServerHost, Opts]) ->
|
|||||||
end
|
end
|
||||||
end, [Host, ServerHost]),
|
end, [Host, ServerHost]),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO,
|
||||||
?MODULE, process_disco_info, IQDisc),
|
?MODULE, process_disco_info),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS,
|
||||||
?MODULE, process_disco_items, IQDisc),
|
?MODULE, process_disco_items),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_PUBSUB,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_PUBSUB,
|
||||||
?MODULE, process_pubsub, IQDisc),
|
?MODULE, process_pubsub),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_PUBSUB_OWNER,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_PUBSUB_OWNER,
|
||||||
?MODULE, process_pubsub_owner, IQDisc),
|
?MODULE, process_pubsub_owner),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
||||||
?MODULE, process_vcard, IQDisc),
|
?MODULE, process_vcard),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_COMMANDS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_COMMANDS,
|
||||||
?MODULE, process_commands, IQDisc),
|
?MODULE, process_commands),
|
||||||
Plugins
|
Plugins
|
||||||
end, Hosts),
|
end, Hosts),
|
||||||
ejabberd_hooks:add(c2s_self_presence, ServerHost,
|
ejabberd_hooks:add(c2s_self_presence, ServerHost,
|
||||||
@ -330,9 +329,9 @@ init([ServerHost, Opts]) ->
|
|||||||
ejabberd_hooks:add(disco_sm_items, ServerHost,
|
ejabberd_hooks:add(disco_sm_items, ServerHost,
|
||||||
?MODULE, disco_sm_items, 75),
|
?MODULE, disco_sm_items, 75),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, ServerHost,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, ServerHost,
|
||||||
?NS_PUBSUB, ?MODULE, iq_sm, IQDisc),
|
?NS_PUBSUB, ?MODULE, iq_sm),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, ServerHost,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, ServerHost,
|
||||||
?NS_PUBSUB_OWNER, ?MODULE, iq_sm, IQDisc);
|
?NS_PUBSUB_OWNER, ?MODULE, iq_sm);
|
||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
@ -3856,7 +3855,6 @@ mod_opt_type(hosts) ->
|
|||||||
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
|
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
|
||||||
mod_opt_type(ignore_pep_from_offline) ->
|
mod_opt_type(ignore_pep_from_offline) ->
|
||||||
fun (A) when is_boolean(A) -> A end;
|
fun (A) when is_boolean(A) -> A end;
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(last_item_cache) ->
|
mod_opt_type(last_item_cache) ->
|
||||||
fun (A) when is_boolean(A) -> A end;
|
fun (A) when is_boolean(A) -> A end;
|
||||||
mod_opt_type(max_items_node) ->
|
mod_opt_type(max_items_node) ->
|
||||||
@ -3881,7 +3879,6 @@ mod_options(Host) ->
|
|||||||
{hosts, []},
|
{hosts, []},
|
||||||
{name, ?T("Publish-Subscribe")},
|
{name, ?T("Publish-Subscribe")},
|
||||||
{ignore_pep_from_offline, true},
|
{ignore_pep_from_offline, true},
|
||||||
{iqdisc, gen_iq_handler:iqdisc(Host)},
|
|
||||||
{last_item_cache, false},
|
{last_item_cache, false},
|
||||||
{max_items_node, ?MAXITEMS},
|
{max_items_node, ?MAXITEMS},
|
||||||
{nodetree, ?STDTREE},
|
{nodetree, ?STDTREE},
|
||||||
|
@ -92,11 +92,10 @@
|
|||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-spec start(binary(), gen_mod:opts()) -> ok.
|
-spec start(binary(), gen_mod:opts()) -> ok.
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
register_iq_handlers(Host, IQDisc),
|
register_iq_handlers(Host),
|
||||||
register_hooks(Host),
|
register_hooks(Host),
|
||||||
ejabberd_commands:register_commands(get_commands_spec()).
|
ejabberd_commands:register_commands(get_commands_spec()).
|
||||||
|
|
||||||
@ -119,12 +118,6 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
NewMod:init(Host, NewOpts);
|
NewMod:init(Host, NewOpts);
|
||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end,
|
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
|
||||||
{false, IQDisc, _} ->
|
|
||||||
register_iq_handlers(Host, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec depends(binary(), gen_mod:opts()) -> [{module(), hard | soft}].
|
-spec depends(binary(), gen_mod:opts()) -> [{module(), hard | soft}].
|
||||||
@ -139,13 +132,10 @@ mod_opt_type(O) when O == cache_life_time; O == cache_size ->
|
|||||||
(infinity) -> infinity
|
(infinity) -> infinity
|
||||||
end;
|
end;
|
||||||
mod_opt_type(O) when O == use_cache; O == cache_missed ->
|
mod_opt_type(O) when O == use_cache; O == cache_missed ->
|
||||||
fun (B) when is_boolean(B) -> B end;
|
fun (B) when is_boolean(B) -> B end.
|
||||||
mod_opt_type(iqdisc) ->
|
|
||||||
fun gen_iq_handler:check_type/1.
|
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(Host) ->
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)},
|
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||||
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
|
||||||
{use_cache, ejabberd_config:use_cache(Host)},
|
{use_cache, ejabberd_config:use_cache(Host)},
|
||||||
{cache_size, ejabberd_config:cache_size(Host)},
|
{cache_size, ejabberd_config:cache_size(Host)},
|
||||||
{cache_missed, ejabberd_config:cache_missed(Host)},
|
{cache_missed, ejabberd_config:cache_missed(Host)},
|
||||||
@ -249,10 +239,10 @@ disco_sm_features(Acc, _From, _To, _Node, _Lang) ->
|
|||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% IQ handlers.
|
%% IQ handlers.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-spec register_iq_handlers(binary(), gen_iq_handler:type()) -> ok.
|
-spec register_iq_handlers(binary()) -> ok.
|
||||||
register_iq_handlers(Host, IQDisc) ->
|
register_iq_handlers(Host) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PUSH_0,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PUSH_0,
|
||||||
?MODULE, process_iq, IQDisc).
|
?MODULE, process_iq).
|
||||||
|
|
||||||
-spec unregister_iq_handlers(binary()) -> ok.
|
-spec unregister_iq_handlers(binary()) -> ok.
|
||||||
unregister_iq_handlers(Host) ->
|
unregister_iq_handlers(Host) ->
|
||||||
|
@ -43,12 +43,11 @@
|
|||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
-include("xmpp.hrl").
|
-include("xmpp.hrl").
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, _Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
||||||
?NS_REGISTER, ?MODULE, process_iq, IQDisc),
|
?NS_REGISTER, ?MODULE, process_iq),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_REGISTER, ?MODULE, process_iq, IQDisc),
|
?NS_REGISTER, ?MODULE, process_iq),
|
||||||
ejabberd_hooks:add(c2s_pre_auth_features, Host, ?MODULE,
|
ejabberd_hooks:add(c2s_pre_auth_features, Host, ?MODULE,
|
||||||
stream_feature_register, 50),
|
stream_feature_register, 50),
|
||||||
ejabberd_hooks:add(c2s_unauthenticated_packet, Host,
|
ejabberd_hooks:add(c2s_unauthenticated_packet, Host,
|
||||||
@ -68,16 +67,8 @@ stop(Host) ->
|
|||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_REGISTER).
|
?NS_REGISTER).
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
ok.
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_REGISTER,
|
|
||||||
?MODULE, process_iq, IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_REGISTER,
|
|
||||||
?MODULE, process_iq, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
@ -608,7 +599,6 @@ mod_opt_type(access_remove) -> fun acl:access_rules_validator/1;
|
|||||||
mod_opt_type(captcha_protected) ->
|
mod_opt_type(captcha_protected) ->
|
||||||
fun (B) when is_boolean(B) -> B end;
|
fun (B) when is_boolean(B) -> B end;
|
||||||
mod_opt_type(ip_access) -> fun acl:access_rules_validator/1;
|
mod_opt_type(ip_access) -> fun acl:access_rules_validator/1;
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(password_strength) ->
|
mod_opt_type(password_strength) ->
|
||||||
fun (N) when is_number(N), N >= 0 -> N end;
|
fun (N) when is_number(N), N >= 0 -> N end;
|
||||||
mod_opt_type(registration_watchers) ->
|
mod_opt_type(registration_watchers) ->
|
||||||
@ -627,13 +617,12 @@ mod_opt_type({welcome_message, body}) ->
|
|||||||
mod_opt_type(redirect_url) ->
|
mod_opt_type(redirect_url) ->
|
||||||
fun iolist_to_binary/1.
|
fun iolist_to_binary/1.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(_Host) ->
|
||||||
[{access, all},
|
[{access, all},
|
||||||
{access_from, none},
|
{access_from, none},
|
||||||
{access_remove, all},
|
{access_remove, all},
|
||||||
{captcha_protected, false},
|
{captcha_protected, false},
|
||||||
{ip_access, all},
|
{ip_access, all},
|
||||||
{iqdisc, gen_iq_handler:iqdisc(Host)},
|
|
||||||
{password_strength, 0},
|
{password_strength, 0},
|
||||||
{registration_watchers, []},
|
{registration_watchers, []},
|
||||||
{redirect_url, <<"">>},
|
{redirect_url, <<"">>},
|
||||||
|
@ -88,7 +88,6 @@
|
|||||||
-optional_callbacks([use_cache/2, cache_nodes/1]).
|
-optional_callbacks([use_cache/2, cache_nodes/1]).
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
@ -111,7 +110,7 @@ start(Host, Opts) ->
|
|||||||
ejabberd_hooks:add(webadmin_user, Host, ?MODULE,
|
ejabberd_hooks:add(webadmin_user, Host, ?MODULE,
|
||||||
webadmin_user, 50),
|
webadmin_user, 50),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_ROSTER, ?MODULE, process_iq, IQDisc).
|
?NS_ROSTER, ?MODULE, process_iq).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
ejabberd_hooks:delete(roster_get, Host, ?MODULE,
|
ejabberd_hooks:delete(roster_get, Host, ?MODULE,
|
||||||
@ -142,13 +141,6 @@ reload(Host, NewOpts, OldOpts) ->
|
|||||||
NewMod:init(Host, NewOpts);
|
NewMod:init(Host, NewOpts);
|
||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end,
|
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ROSTER,
|
|
||||||
?MODULE, process_iq, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
@ -1205,7 +1197,6 @@ import(LServer, {sql, _}, DBType, <<"roster_version">>, [LUser, Ver]) ->
|
|||||||
mod_opt_type(access) ->
|
mod_opt_type(access) ->
|
||||||
fun acl:access_rules_validator/1;
|
fun acl:access_rules_validator/1;
|
||||||
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(store_current_id) ->
|
mod_opt_type(store_current_id) ->
|
||||||
fun (B) when is_boolean(B) -> B end;
|
fun (B) when is_boolean(B) -> B end;
|
||||||
mod_opt_type(versioning) ->
|
mod_opt_type(versioning) ->
|
||||||
@ -1221,7 +1212,6 @@ mod_options(Host) ->
|
|||||||
[{access, all},
|
[{access, all},
|
||||||
{store_current_id, false},
|
{store_current_id, false},
|
||||||
{versioning, false},
|
{versioning, false},
|
||||||
{iqdisc, gen_iq_handler:iqdisc(Host)},
|
|
||||||
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||||
{use_cache, ejabberd_config:use_cache(Host)},
|
{use_cache, ejabberd_config:use_cache(Host)},
|
||||||
{cache_size, ejabberd_config:cache_size(Host)},
|
{cache_size, ejabberd_config:cache_size(Host)},
|
||||||
|
@ -32,22 +32,21 @@
|
|||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/2, stop/1, reload/3, process_local_iq/1,
|
-export([start/2, stop/1, reload/3, process_local_iq/1,
|
||||||
process_sm_iq/1, mod_opt_type/1, mod_options/1, depends/2]).
|
process_sm_iq/1, mod_options/1, depends/2]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
-include("xmpp.hrl").
|
-include("xmpp.hrl").
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, _Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_0,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_0,
|
||||||
?MODULE, process_local_iq, IQDisc),
|
?MODULE, process_local_iq),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_0,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_0,
|
||||||
?MODULE, process_sm_iq, IQDisc),
|
?MODULE, process_sm_iq),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_1,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_1,
|
||||||
?MODULE, process_local_iq, IQDisc),
|
?MODULE, process_local_iq),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_1,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_1,
|
||||||
?MODULE, process_sm_iq, IQDisc).
|
?MODULE, process_sm_iq).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_SIC_0),
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_SIC_0),
|
||||||
@ -55,20 +54,8 @@ stop(Host) ->
|
|||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_SIC_1),
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_SIC_1),
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_SIC_1).
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_SIC_1).
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
ok.
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_0,
|
|
||||||
?MODULE, process_local_iq, IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_0,
|
|
||||||
?MODULE, process_sm_iq, IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_1,
|
|
||||||
?MODULE, process_local_iq, IQDisc),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_1,
|
|
||||||
?MODULE, process_sm_iq, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
@ -107,7 +94,5 @@ get_ip({User, Server, Resource},
|
|||||||
xmpp:make_error(IQ, xmpp:err_item_not_found(Txt, Lang))
|
xmpp:make_error(IQ, xmpp:err_item_not_found(Txt, Lang))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1.
|
mod_options(_Host) ->
|
||||||
|
[].
|
||||||
mod_options(Host) ->
|
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)}].
|
|
||||||
|
@ -31,17 +31,16 @@
|
|||||||
|
|
||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/2, stop/1, reload/3, process_iq/1, mod_opt_type/1,
|
-export([start/2, stop/1, reload/3, process_iq/1,
|
||||||
mod_options/1, depends/2]).
|
mod_options/1, depends/2]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
-include("xmpp.hrl").
|
-include("xmpp.hrl").
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, _Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_STATS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_STATS,
|
||||||
?MODULE, process_iq, IQDisc).
|
?MODULE, process_iq).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_STATS).
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_STATS).
|
||||||
@ -234,7 +233,5 @@ search_running_node(SNode, [Node | Nodes]) ->
|
|||||||
_ -> search_running_node(SNode, Nodes)
|
_ -> search_running_node(SNode, Nodes)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1.
|
mod_options(_Host) ->
|
||||||
|
[].
|
||||||
mod_options(Host) ->
|
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)}].
|
|
||||||
|
@ -33,30 +33,23 @@
|
|||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/2, stop/1, reload/3, process_local_iq/1,
|
-export([start/2, stop/1, reload/3, process_local_iq/1,
|
||||||
mod_opt_type/1, mod_options/1, depends/2]).
|
mod_options/1, depends/2]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
|
||||||
-include("xmpp.hrl").
|
-include("xmpp.hrl").
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, _Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
||||||
?NS_TIME, ?MODULE, process_local_iq, IQDisc).
|
?NS_TIME, ?MODULE, process_local_iq).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
||||||
?NS_TIME).
|
?NS_TIME).
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
ok.
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_TIME,
|
|
||||||
?MODULE, process_local_iq, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
process_local_iq(#iq{type = set, lang = Lang} = IQ) ->
|
process_local_iq(#iq{type = set, lang = Lang} = IQ) ->
|
||||||
Txt = <<"Value 'set' of 'type' attribute is not allowed">>,
|
Txt = <<"Value 'set' of 'type' attribute is not allowed">>,
|
||||||
@ -74,7 +67,5 @@ process_local_iq(#iq{type = get} = IQ) ->
|
|||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1.
|
mod_options(_Host) ->
|
||||||
|
[].
|
||||||
mod_options(Host) ->
|
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)}].
|
|
||||||
|
@ -88,11 +88,10 @@ init([Host, Opts]) ->
|
|||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
||||||
remove_user, 50),
|
remove_user, 50),
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
||||||
?NS_VCARD, ?MODULE, process_local_iq, IQDisc),
|
?NS_VCARD, ?MODULE, process_local_iq),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
||||||
?NS_VCARD, ?MODULE, process_sm_iq, IQDisc),
|
?NS_VCARD, ?MODULE, process_sm_iq),
|
||||||
ejabberd_hooks:add(disco_sm_features, Host, ?MODULE,
|
ejabberd_hooks:add(disco_sm_features, Host, ?MODULE,
|
||||||
get_sm_features, 50),
|
get_sm_features, 50),
|
||||||
ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE, vcard_iq_set, 50),
|
ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE, vcard_iq_set, 50),
|
||||||
@ -108,15 +107,15 @@ init([Host, Opts]) ->
|
|||||||
ejabberd_hooks:add(
|
ejabberd_hooks:add(
|
||||||
disco_local_identity, MyHost, ?MODULE, disco_identity, 100),
|
disco_local_identity, MyHost, ?MODULE, disco_identity, 100),
|
||||||
gen_iq_handler:add_iq_handler(
|
gen_iq_handler:add_iq_handler(
|
||||||
ejabberd_local, MyHost, ?NS_SEARCH, ?MODULE, process_search, IQDisc),
|
ejabberd_local, MyHost, ?NS_SEARCH, ?MODULE, process_search),
|
||||||
gen_iq_handler:add_iq_handler(
|
gen_iq_handler:add_iq_handler(
|
||||||
ejabberd_local, MyHost, ?NS_VCARD, ?MODULE, process_vcard, IQDisc),
|
ejabberd_local, MyHost, ?NS_VCARD, ?MODULE, process_vcard),
|
||||||
gen_iq_handler:add_iq_handler(
|
gen_iq_handler:add_iq_handler(
|
||||||
ejabberd_local, MyHost, ?NS_DISCO_ITEMS, mod_disco,
|
ejabberd_local, MyHost, ?NS_DISCO_ITEMS, mod_disco,
|
||||||
process_local_iq_items, IQDisc),
|
process_local_iq_items),
|
||||||
gen_iq_handler:add_iq_handler(
|
gen_iq_handler:add_iq_handler(
|
||||||
ejabberd_local, MyHost, ?NS_DISCO_INFO, mod_disco,
|
ejabberd_local, MyHost, ?NS_DISCO_INFO, mod_disco,
|
||||||
process_local_iq_info, IQDisc),
|
process_local_iq_info),
|
||||||
case Mod:is_search_supported(Host) of
|
case Mod:is_search_supported(Host) of
|
||||||
false ->
|
false ->
|
||||||
?WARNING_MSG("vcard search functionality is "
|
?WARNING_MSG("vcard search functionality is "
|
||||||
@ -538,7 +537,6 @@ mod_opt_type(name) -> fun iolist_to_binary/1;
|
|||||||
mod_opt_type(host) -> fun iolist_to_binary/1;
|
mod_opt_type(host) -> fun iolist_to_binary/1;
|
||||||
mod_opt_type(hosts) ->
|
mod_opt_type(hosts) ->
|
||||||
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
|
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(matches) ->
|
mod_opt_type(matches) ->
|
||||||
fun (infinity) -> infinity;
|
fun (infinity) -> infinity;
|
||||||
(I) when is_integer(I), I > 0 -> I
|
(I) when is_integer(I), I > 0 -> I
|
||||||
@ -559,7 +557,6 @@ mod_options(Host) ->
|
|||||||
{matches, 30},
|
{matches, 30},
|
||||||
{search, false},
|
{search, false},
|
||||||
{name, ?T("vCard User Search")},
|
{name, ?T("vCard User Search")},
|
||||||
{iqdisc, gen_iq_handler:iqdisc(Host)},
|
|
||||||
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||||
{use_cache, ejabberd_config:use_cache(Host)},
|
{use_cache, ejabberd_config:use_cache(Host)},
|
||||||
{cache_size, ejabberd_config:cache_size(Host)},
|
{cache_size, ejabberd_config:cache_size(Host)},
|
||||||
|
@ -39,24 +39,16 @@
|
|||||||
|
|
||||||
-include("xmpp.hrl").
|
-include("xmpp.hrl").
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, _Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
||||||
?NS_VERSION, ?MODULE, process_local_iq,
|
?NS_VERSION, ?MODULE, process_local_iq).
|
||||||
IQDisc).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
||||||
?NS_VERSION).
|
?NS_VERSION).
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of
|
ok.
|
||||||
{false, IQDisc, _} ->
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VERSION,
|
|
||||||
?MODULE, process_local_iq, IQDisc);
|
|
||||||
true ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
process_local_iq(#iq{type = set, lang = Lang} = IQ) ->
|
process_local_iq(#iq{type = set, lang = Lang} = IQ) ->
|
||||||
Txt = <<"Value 'set' of 'type' attribute is not allowed">>,
|
Txt = <<"Value 'set' of 'type' attribute is not allowed">>,
|
||||||
@ -85,10 +77,8 @@ get_os() ->
|
|||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
|
|
||||||
mod_opt_type(show_os) ->
|
mod_opt_type(show_os) ->
|
||||||
fun (B) when is_boolean(B) -> B end.
|
fun (B) when is_boolean(B) -> B end.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(_Host) ->
|
||||||
[{iqdisc, gen_iq_handler:iqdisc(Host)},
|
[{show_os, true}].
|
||||||
{show_os, true}].
|
|
||||||
|
@ -31,10 +31,9 @@
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% API
|
%%% API
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
start(Host, Opts) ->
|
start(Host, _Opts) ->
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_EVENT,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_EVENT,
|
||||||
?MODULE, process_iq, IQDisc).
|
?MODULE, process_iq).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?MODULE).
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?MODULE).
|
||||||
@ -45,6 +44,9 @@ mod_opt_type(_) ->
|
|||||||
depends(_, _) ->
|
depends(_, _) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
|
mod_options(_) ->
|
||||||
|
[].
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
@ -62,7 +62,7 @@ defmodule ModRosterMock do
|
|||||||
|
|
||||||
roster_mock0 = :moka.start(:mod_roster)
|
roster_mock0 = :moka.start(:mod_roster)
|
||||||
:moka.replace(roster_mock0, :gen_iq_handler, :add_iq_handler,
|
:moka.replace(roster_mock0, :gen_iq_handler, :add_iq_handler,
|
||||||
fn (_module, _host, _ns, _m, _f, _iqdisc) ->
|
fn (_module, _host, _ns, _m, _f) ->
|
||||||
:ok
|
:ok
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ main([Dir]) ->
|
|||||||
{ejabberd_hooks, {add, N}}
|
{ejabberd_hooks, {add, N}}
|
||||||
when N == 4; N == 5 ->
|
when N == 4; N == 5 ->
|
||||||
analyze_run_fun(Form, Acc);
|
analyze_run_fun(Form, Acc);
|
||||||
{gen_iq_handler, {add_iq_handler, 6}} ->
|
{gen_iq_handler, {add_iq_handler, N}}
|
||||||
|
when N == 5; N == 6 ->
|
||||||
analyze_iq_handler(Form, Acc);
|
analyze_iq_handler(Form, Acc);
|
||||||
_ ->
|
_ ->
|
||||||
Acc
|
Acc
|
||||||
@ -136,7 +137,7 @@ analyze_run_fun(Form, State) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
analyze_iq_handler(Form, State) ->
|
analyze_iq_handler(Form, State) ->
|
||||||
[_Component, _Host, _NS, Module, Function, _IQDisc] =
|
[_Component, _Host, _NS, Module, Function|_] =
|
||||||
erl_syntax:application_arguments(Form),
|
erl_syntax:application_arguments(Form),
|
||||||
Mod = module_name(Module, State),
|
Mod = module_name(Module, State),
|
||||||
Fun = atom_value(Function, State),
|
Fun = atom_value(Function, State),
|
||||||
|
Loading…
Reference in New Issue
Block a user