mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
cosmetic cleanup
This commit is contained in:
parent
83dd79a6a7
commit
6aeb9dcb38
@ -19,7 +19,7 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-record(request,
|
-record(request,
|
||||||
{method, % :: method(),
|
{method :: method(),
|
||||||
path = [] :: [binary()],
|
path = [] :: [binary()],
|
||||||
q = [] :: [{binary() | nokey, binary()}],
|
q = [] :: [{binary() | nokey, binary()}],
|
||||||
us = {<<>>, <<>>} :: {binary(), binary()},
|
us = {<<>>, <<>>} :: {binary(), binary()},
|
||||||
@ -30,11 +30,10 @@
|
|||||||
ip :: {inet:ip_address(), inet:port_number()},
|
ip :: {inet:ip_address(), inet:port_number()},
|
||||||
host = <<"">> :: binary(),
|
host = <<"">> :: binary(),
|
||||||
port = 5280 :: inet:port_number(),
|
port = 5280 :: inet:port_number(),
|
||||||
tp = http, % :: protocol(),
|
|
||||||
opts = [] :: list(),
|
opts = [] :: list(),
|
||||||
|
tp = http :: protocol(),
|
||||||
headers = [] :: [{atom() | binary(), binary()}]}).
|
headers = [] :: [{atom() | binary(), binary()}]}).
|
||||||
|
|
||||||
|
|
||||||
-record(ws,
|
-record(ws,
|
||||||
{socket :: inet:socket() | p1_tls:tls_socket(),
|
{socket :: inet:socket() | p1_tls:tls_socket(),
|
||||||
sockmod = gen_tcp :: gen_tcp | p1_tls,
|
sockmod = gen_tcp :: gen_tcp | p1_tls,
|
||||||
@ -47,3 +46,7 @@
|
|||||||
q = [] :: [{binary() | nokey, binary()}],
|
q = [] :: [{binary() | nokey, binary()}],
|
||||||
buf :: binary(),
|
buf :: binary(),
|
||||||
http_opts = [] :: list()}).
|
http_opts = [] :: list()}).
|
||||||
|
|
||||||
|
-type method() :: 'GET' | 'HEAD' | 'DELETE' | 'OPTIONS' | 'PUT' | 'POST' | 'TRACE'.
|
||||||
|
-type protocol() :: http | https.
|
||||||
|
-type http_request() :: #request{}.
|
||||||
|
11
include/mod_offline.hrl
Normal file
11
include/mod_offline.hrl
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
-record(offline_msg,
|
||||||
|
{us = {<<"">>, <<"">>} :: {binary(), binary()},
|
||||||
|
timestamp = now() :: erlang:timestamp() | '_',
|
||||||
|
expire = now() :: erlang:timestamp() | never | '_',
|
||||||
|
from = #jid{} :: jid() | '_',
|
||||||
|
to = #jid{} :: jid() | '_',
|
||||||
|
packet = #xmlel{} :: xmlel() | '_'}).
|
||||||
|
|
||||||
|
-record(state,
|
||||||
|
{host = <<"">> :: binary(),
|
||||||
|
access_max_offline_messages}).
|
31
src/acl.erl
31
src/acl.erl
@ -98,7 +98,7 @@ to_record(Host, ACLName, ACLSpec) ->
|
|||||||
-spec add(binary(), aclname(), aclspec()) -> ok | {error, any()}.
|
-spec add(binary(), aclname(), aclspec()) -> ok | {error, any()}.
|
||||||
|
|
||||||
add(Host, ACLName, ACLSpec) ->
|
add(Host, ACLName, ACLSpec) ->
|
||||||
{ResL, BadNodes} = rpc:multicall(mnesia:system_info(running_db_nodes),
|
{ResL, BadNodes} = ejabberd_cluster:multicall(
|
||||||
?MODULE, add_local,
|
?MODULE, add_local,
|
||||||
[Host, ACLName, ACLSpec]),
|
[Host, ACLName, ACLSpec]),
|
||||||
case lists:keyfind(aborted, 1, ResL) of
|
case lists:keyfind(aborted, 1, ResL) of
|
||||||
@ -125,7 +125,7 @@ add_local(Host, ACLName, ACLSpec) ->
|
|||||||
-spec add_list(binary(), [acl()], boolean()) -> ok | {error, any()}.
|
-spec add_list(binary(), [acl()], boolean()) -> ok | {error, any()}.
|
||||||
|
|
||||||
add_list(Host, ACLs, Clear) ->
|
add_list(Host, ACLs, Clear) ->
|
||||||
{ResL, BadNodes} = rpc:multicall(mnesia:system_info(running_db_nodes),
|
{ResL, BadNodes} = ejabberd_cluster:multicall(
|
||||||
?MODULE, add_list_local,
|
?MODULE, add_list_local,
|
||||||
[Host, ACLs, Clear]),
|
[Host, ACLs, Clear]),
|
||||||
case lists:keyfind(aborted, 1, ResL) of
|
case lists:keyfind(aborted, 1, ResL) of
|
||||||
@ -167,12 +167,8 @@ add_list_local(Host, ACLs, Clear) ->
|
|||||||
access_name(), [access_rule()]) -> ok | {error, any()}.
|
access_name(), [access_rule()]) -> ok | {error, any()}.
|
||||||
|
|
||||||
add_access(Host, Access, Rules) ->
|
add_access(Host, Access, Rules) ->
|
||||||
case mnesia:transaction(
|
Obj = #access{name = {Access, Host}, rules = Rules},
|
||||||
fun() ->
|
case mnesia:transaction(fun() -> mnesia:write(Obj) end) of
|
||||||
mnesia:write(
|
|
||||||
#access{name = {Access, Host},
|
|
||||||
rules = Rules})
|
|
||||||
end) of
|
|
||||||
{atomic, ok} ->
|
{atomic, ok} ->
|
||||||
ok;
|
ok;
|
||||||
Err ->
|
Err ->
|
||||||
@ -239,8 +235,7 @@ normalize_spec(Spec) ->
|
|||||||
{server_regexp, SR} -> {server_regexp, b(SR)};
|
{server_regexp, SR} -> {server_regexp, b(SR)};
|
||||||
{server_glob, S} -> {server_glob, b(S)};
|
{server_glob, S} -> {server_glob, b(S)};
|
||||||
{resource_glob, R} -> {resource_glob, b(R)};
|
{resource_glob, R} -> {resource_glob, b(R)};
|
||||||
{ip, {Net, Mask}} ->
|
{ip, {Net, Mask}} -> {ip, {Net, Mask}};
|
||||||
{ip, {Net, Mask}};
|
|
||||||
{ip, S} ->
|
{ip, S} ->
|
||||||
case parse_ip_netmask(b(S)) of
|
case parse_ip_netmask(b(S)) of
|
||||||
{ok, Net, Mask} ->
|
{ok, Net, Mask} ->
|
||||||
@ -294,17 +289,15 @@ match_acl(none, _JID, _Host) ->
|
|||||||
match_acl(ACL, IP, Host) when tuple_size(IP) == 4;
|
match_acl(ACL, IP, Host) when tuple_size(IP) == 4;
|
||||||
tuple_size(IP) == 8 ->
|
tuple_size(IP) == 8 ->
|
||||||
lists:any(
|
lists:any(
|
||||||
fun(#acl{aclspec = {ip, {Net, Mask}}}) ->
|
fun({ip, {Net, Mask}}) ->
|
||||||
is_ip_match(IP, Net, Mask);
|
is_ip_match(IP, Net, Mask);
|
||||||
(_) ->
|
(_) ->
|
||||||
false
|
false
|
||||||
end,
|
end, get_aclspecs(ACL, Host));
|
||||||
ets:lookup(acl, {ACL, Host}) ++
|
|
||||||
ets:lookup(acl, {ACL, global}));
|
|
||||||
match_acl(ACL, JID, Host) ->
|
match_acl(ACL, JID, Host) ->
|
||||||
{User, Server, Resource} = jlib:jid_tolower(JID),
|
{User, Server, Resource} = jlib:jid_tolower(JID),
|
||||||
lists:any(
|
lists:any(
|
||||||
fun(#acl{aclspec = Spec}) ->
|
fun(Spec) ->
|
||||||
case Spec of
|
case Spec of
|
||||||
all -> true;
|
all -> true;
|
||||||
{user, {U, S}} -> U == User andalso S == Server;
|
{user, {U, S}} -> U == User andalso S == Server;
|
||||||
@ -350,7 +343,13 @@ match_acl(ACL, JID, Host) ->
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
ets:lookup(acl, {ACL, Host}) ++
|
get_aclspecs(ACL, Host)).
|
||||||
|
|
||||||
|
get_aclspecs(ACL, Host) ->
|
||||||
|
lists:flatmap(
|
||||||
|
fun(#acl{aclspec = Specs}) ->
|
||||||
|
Specs
|
||||||
|
end, ets:lookup(acl, {ACL, Host}) ++
|
||||||
ets:lookup(acl, {ACL, global})).
|
ets:lookup(acl, {ACL, global})).
|
||||||
|
|
||||||
is_regexp_match(String, RegExp) ->
|
is_regexp_match(String, RegExp) ->
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
-callback get_password_s(binary(), binary()) -> binary() | {binary(), binary(), binary(), integer()}.
|
-callback get_password_s(binary(), binary()) -> binary() | {binary(), binary(), binary(), integer()}.
|
||||||
|
|
||||||
start() ->
|
start() ->
|
||||||
%% This is only executed by ejabberd_c2s for non-SASL auth client
|
%% This is only executed by ejabberd_c2s for non-SASL auth client
|
||||||
lists:foreach(fun (Host) ->
|
lists:foreach(fun (Host) ->
|
||||||
lists:foreach(fun (M) -> M:start(Host) end,
|
lists:foreach(fun (M) -> M:start(Host) end,
|
||||||
auth_modules(Host))
|
auth_modules(Host))
|
||||||
@ -187,7 +187,8 @@ try_register(User, Server, Password) ->
|
|||||||
case is_user_exists(User, Server) of
|
case is_user_exists(User, Server) of
|
||||||
true -> {atomic, exists};
|
true -> {atomic, exists};
|
||||||
false ->
|
false ->
|
||||||
case lists:member(jlib:nameprep(Server), ?MYHOSTS) of
|
LServer = jlib:nameprep(Server),
|
||||||
|
case lists:member(LServer, ?MYHOSTS) of
|
||||||
true ->
|
true ->
|
||||||
Res = lists:foldl(fun (_M, {atomic, ok} = Res) -> Res;
|
Res = lists:foldl(fun (_M, {atomic, ok} = Res) -> Res;
|
||||||
(M, _) ->
|
(M, _) ->
|
||||||
|
@ -281,7 +281,6 @@ is_fresh_enough(TimeStampLast, CacheTime) ->
|
|||||||
get_last_access(User, Server) ->
|
get_last_access(User, Server) ->
|
||||||
case ejabberd_sm:get_user_resources(User, Server) of
|
case ejabberd_sm:get_user_resources(User, Server) of
|
||||||
[] ->
|
[] ->
|
||||||
%% _US = {User, Server},
|
|
||||||
case get_last_info(User, Server) of
|
case get_last_info(User, Server) of
|
||||||
mod_last_required -> mod_last_required;
|
mod_last_required -> mod_last_required;
|
||||||
not_found -> never;
|
not_found -> never;
|
||||||
|
@ -203,7 +203,8 @@ start(SockData, Opts) ->
|
|||||||
?SUPERVISOR_START.
|
?SUPERVISOR_START.
|
||||||
|
|
||||||
start_link(SockData, Opts) ->
|
start_link(SockData, Opts) ->
|
||||||
?GEN_FSM:start_link(ejabberd_c2s, [SockData, Opts],
|
(?GEN_FSM):start_link(ejabberd_c2s,
|
||||||
|
[SockData, Opts],
|
||||||
fsm_limit_opts(Opts) ++ ?FSMOPTS).
|
fsm_limit_opts(Opts) ++ ?FSMOPTS).
|
||||||
|
|
||||||
socket_type() -> xml_stream.
|
socket_type() -> xml_stream.
|
||||||
@ -256,13 +257,6 @@ stop(FsmRef) -> (?GEN_FSM):send_event(FsmRef, closed).
|
|||||||
%%% Callback functions from gen_fsm
|
%%% Callback functions from gen_fsm
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: init/1
|
|
||||||
%% Returns: {ok, StateName, StateData} |
|
|
||||||
%% {ok, StateName, StateData, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, StopReason}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
init([{SockMod, Socket}, Opts]) ->
|
init([{SockMod, Socket}, Opts]) ->
|
||||||
Access = case lists:keysearch(access, 1, Opts) of
|
Access = case lists:keysearch(access, 1, Opts) of
|
||||||
{value, {_, A}} -> A;
|
{value, {_, A}} -> A;
|
||||||
@ -350,13 +344,6 @@ get_subscribed(FsmRef) ->
|
|||||||
(?GEN_FSM):sync_send_all_state_event(FsmRef,
|
(?GEN_FSM):sync_send_all_state_event(FsmRef,
|
||||||
get_subscribed, 1000).
|
get_subscribed, 1000).
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: StateName/2
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
|
|
||||||
wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
||||||
DefaultLang = ?MYLANG,
|
DefaultLang = ?MYLANG,
|
||||||
case xml:get_attr_s(<<"xmlns:stream">>, Attrs) of
|
case xml:get_attr_s(<<"xmlns:stream">>, Attrs) of
|
||||||
@ -392,18 +379,17 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
|||||||
TLS = StateData#state.tls,
|
TLS = StateData#state.tls,
|
||||||
TLSEnabled = StateData#state.tls_enabled,
|
TLSEnabled = StateData#state.tls_enabled,
|
||||||
TLSRequired = StateData#state.tls_required,
|
TLSRequired = StateData#state.tls_required,
|
||||||
SASLState =
|
SASLState = cyrsasl:server_new(
|
||||||
cyrsasl:server_new(
|
|
||||||
<<"jabber">>, Server, <<"">>, [],
|
<<"jabber">>, Server, <<"">>, [],
|
||||||
fun(U) ->
|
fun (U) ->
|
||||||
ejabberd_auth:get_password_with_authmodule(
|
ejabberd_auth:get_password_with_authmodule(
|
||||||
U, Server)
|
U, Server)
|
||||||
end,
|
end,
|
||||||
fun(U, P) ->
|
fun (U, P) ->
|
||||||
ejabberd_auth:check_password_with_authmodule(
|
ejabberd_auth:check_password_with_authmodule(
|
||||||
U, Server, P)
|
U, Server, P)
|
||||||
end,
|
end,
|
||||||
fun(U, P, D, DG) ->
|
fun (U, P, D, DG) ->
|
||||||
ejabberd_auth:check_password_with_authmodule(
|
ejabberd_auth:check_password_with_authmodule(
|
||||||
U, Server, P, D, DG)
|
U, Server, P, D, DG)
|
||||||
end),
|
end),
|
||||||
@ -423,13 +409,10 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
|||||||
[]
|
[]
|
||||||
end,
|
end,
|
||||||
SockMod =
|
SockMod =
|
||||||
(StateData#state.sockmod):get_sockmod(
|
(StateData#state.sockmod):get_sockmod(StateData#state.socket),
|
||||||
StateData#state.socket),
|
|
||||||
Zlib = StateData#state.zlib,
|
Zlib = StateData#state.zlib,
|
||||||
CompressFeature =
|
CompressFeature = case Zlib andalso
|
||||||
case Zlib andalso
|
((SockMod == gen_tcp) orelse (SockMod == p1_tls)) of
|
||||||
((SockMod == gen_tcp) orelse
|
|
||||||
(SockMod == p1_tls)) of
|
|
||||||
true ->
|
true ->
|
||||||
[#xmlel{name = <<"compression">>,
|
[#xmlel{name = <<"compression">>,
|
||||||
attrs = [{<<"xmlns">>, ?NS_FEATURE_COMPRESS}],
|
attrs = [{<<"xmlns">>, ?NS_FEATURE_COMPRESS}],
|
||||||
@ -465,11 +448,9 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
|||||||
send_element(StateData,
|
send_element(StateData,
|
||||||
#xmlel{name = <<"stream:features">>,
|
#xmlel{name = <<"stream:features">>,
|
||||||
attrs = [],
|
attrs = [],
|
||||||
children =
|
children = StreamFeatures}),
|
||||||
StreamFeatures}),
|
|
||||||
fsm_next_state(wait_for_feature_request,
|
fsm_next_state(wait_for_feature_request,
|
||||||
StateData#state{
|
StateData#state{server = Server,
|
||||||
server = Server,
|
|
||||||
sasl_state = SASLState,
|
sasl_state = SASLState,
|
||||||
lang = Lang});
|
lang = Lang});
|
||||||
_ ->
|
_ ->
|
||||||
@ -579,8 +560,7 @@ wait_for_auth({xmlstreamelement, #xmlel{name = Name} = El}, StateData)
|
|||||||
wait_for_auth({xmlstreamelement, El}, StateData) ->
|
wait_for_auth({xmlstreamelement, El}, StateData) ->
|
||||||
case is_auth_packet(El) of
|
case is_auth_packet(El) of
|
||||||
{auth, _ID, get, {U, _, _, _}} ->
|
{auth, _ID, get, {U, _, _, _}} ->
|
||||||
#xmlel{name = Name, attrs = Attrs} =
|
#xmlel{name = Name, attrs = Attrs} = jlib:make_result_iq_reply(El),
|
||||||
jlib:make_result_iq_reply(El),
|
|
||||||
case U of
|
case U of
|
||||||
<<"">> -> UCdata = [];
|
<<"">> -> UCdata = [];
|
||||||
_ -> UCdata = [{xmlcdata, U}]
|
_ -> UCdata = [{xmlcdata, U}]
|
||||||
@ -663,10 +643,8 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
|||||||
ejabberd_hooks:run_fold(roster_get_subscription_lists,
|
ejabberd_hooks:run_fold(roster_get_subscription_lists,
|
||||||
StateData#state.server,
|
StateData#state.server,
|
||||||
{[], []},
|
{[], []},
|
||||||
[U,
|
[U, StateData#state.server]),
|
||||||
StateData#state.server]),
|
LJID = jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
||||||
LJID =
|
|
||||||
jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
|
||||||
Fs1 = [LJID | Fs],
|
Fs1 = [LJID | Fs],
|
||||||
Ts1 = [LJID | Ts],
|
Ts1 = [LJID | Ts],
|
||||||
PrivList = ejabberd_hooks:run_fold(privacy_get_user_list,
|
PrivList = ejabberd_hooks:run_fold(privacy_get_user_list,
|
||||||
@ -1124,8 +1102,7 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
|
|||||||
NewStateData#state.access, JID) of
|
NewStateData#state.access, JID) of
|
||||||
allow ->
|
allow ->
|
||||||
?INFO_MSG("(~w) Opened session for ~s",
|
?INFO_MSG("(~w) Opened session for ~s",
|
||||||
[NewStateData#state.socket,
|
[NewStateData#state.socket, jlib:jid_to_string(JID)]),
|
||||||
jlib:jid_to_string(JID)]),
|
|
||||||
Res = jlib:make_result_iq_reply(El#xmlel{children = []}),
|
Res = jlib:make_result_iq_reply(El#xmlel{children = []}),
|
||||||
NewState = send_stanza(NewStateData, Res),
|
NewState = send_stanza(NewStateData, Res),
|
||||||
change_shaper(NewState, JID),
|
change_shaper(NewState, JID),
|
||||||
@ -1139,7 +1116,8 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
|
|||||||
Ts1 = [LJID | Ts],
|
Ts1 = [LJID | Ts],
|
||||||
PrivList =
|
PrivList =
|
||||||
ejabberd_hooks:run_fold(
|
ejabberd_hooks:run_fold(
|
||||||
privacy_get_user_list, NewState#state.server,
|
privacy_get_user_list,
|
||||||
|
NewState#state.server,
|
||||||
#userlist{},
|
#userlist{},
|
||||||
[U, NewState#state.server]),
|
[U, NewState#state.server]),
|
||||||
Conn = get_conn_type(NewState),
|
Conn = get_conn_type(NewState),
|
||||||
@ -1159,8 +1137,7 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
|
|||||||
ejabberd_hooks:run(forbidden_session_hook,
|
ejabberd_hooks:run(forbidden_session_hook,
|
||||||
NewStateData#state.server, [JID]),
|
NewStateData#state.server, [JID]),
|
||||||
?INFO_MSG("(~w) Forbidden session for ~s",
|
?INFO_MSG("(~w) Forbidden session for ~s",
|
||||||
[NewStateData#state.socket,
|
[NewStateData#state.socket, jlib:jid_to_string(JID)]),
|
||||||
jlib:jid_to_string(JID)]),
|
|
||||||
Err = jlib:make_error_reply(El, ?ERR_NOT_ALLOWED),
|
Err = jlib:make_error_reply(El, ?ERR_NOT_ALLOWED),
|
||||||
send_element(NewStateData, Err),
|
send_element(NewStateData, Err),
|
||||||
fsm_next_state(wait_for_session, NewStateData)
|
fsm_next_state(wait_for_session, NewStateData)
|
||||||
@ -1168,7 +1145,6 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
|
|||||||
_ ->
|
_ ->
|
||||||
fsm_next_state(wait_for_session, NewStateData)
|
fsm_next_state(wait_for_session, NewStateData)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
wait_for_session(timeout, StateData) ->
|
wait_for_session(timeout, StateData) ->
|
||||||
{stop, normal, StateData};
|
{stop, normal, StateData};
|
||||||
wait_for_session({xmlstreamend, _Name}, StateData) ->
|
wait_for_session({xmlstreamend, _Name}, StateData) ->
|
||||||
@ -1230,8 +1206,7 @@ session_established(closed, #state{mgmt_state = active} = StateData) ->
|
|||||||
session_established(closed, StateData) ->
|
session_established(closed, StateData) ->
|
||||||
{stop, normal, StateData}.
|
{stop, normal, StateData}.
|
||||||
|
|
||||||
%% Process packets sent by user (coming from user on c2s XMPP
|
%% Process packets sent by user (coming from user on c2s XMPP connection)
|
||||||
%% connection)
|
|
||||||
session_established2(El, StateData) ->
|
session_established2(El, StateData) ->
|
||||||
#xmlel{name = Name, attrs = Attrs} = El,
|
#xmlel{name = Name, attrs = Attrs} = El,
|
||||||
NewStateData = update_num_stanzas_in(StateData, El),
|
NewStateData = update_num_stanzas_in(StateData, El),
|
||||||
@ -1323,37 +1298,9 @@ wait_for_resume(Event, StateData) ->
|
|||||||
?DEBUG("Ignoring event while waiting for resumption: ~p", [Event]),
|
?DEBUG("Ignoring event while waiting for resumption: ~p", [Event]),
|
||||||
fsm_next_state(wait_for_resume, StateData).
|
fsm_next_state(wait_for_resume, StateData).
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: StateName/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData} |
|
|
||||||
%% {stop, Reason, Reply, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%state_name(Event, From, StateData) ->
|
|
||||||
% Reply = ok,
|
|
||||||
% {reply, Reply, state_name, StateData}.
|
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_event/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_event(_Event, StateName, StateData) ->
|
handle_event(_Event, StateName, StateData) ->
|
||||||
fsm_next_state(StateName, StateData).
|
fsm_next_state(StateName, StateData).
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_sync_event/4
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData} |
|
|
||||||
%% {stop, Reason, Reply, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_sync_event({get_presence}, _From, StateName,
|
handle_sync_event({get_presence}, _From, StateName,
|
||||||
StateData) ->
|
StateData) ->
|
||||||
User = StateData#state.user,
|
User = StateData#state.user,
|
||||||
@ -1386,12 +1333,6 @@ handle_sync_event(_Event, _From, StateName,
|
|||||||
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
||||||
{ok, StateName, StateData}.
|
{ok, StateName, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_info/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_info({send_text, Text}, StateName, StateData) ->
|
handle_info({send_text, Text}, StateName, StateData) ->
|
||||||
send_text(StateData, Text),
|
send_text(StateData, Text),
|
||||||
ejabberd_hooks:run(c2s_loop_debug, [Text]),
|
ejabberd_hooks:run(c2s_loop_debug, [Text]),
|
||||||
@ -1446,7 +1387,8 @@ handle_info({route, _From, _To, {broadcast, Data}},
|
|||||||
jlib:jid_remove_resource(StateData#state.jid),
|
jlib:jid_remove_resource(StateData#state.jid),
|
||||||
StateData#state.jid,
|
StateData#state.jid,
|
||||||
jlib:iq_to_xml(PrivPushIQ)),
|
jlib:iq_to_xml(PrivPushIQ)),
|
||||||
NewState = send_stanza(StateData, PrivPushEl),
|
NewState = send_stanza(
|
||||||
|
StateData, PrivPushEl),
|
||||||
fsm_next_state(StateName,
|
fsm_next_state(StateName,
|
||||||
NewState#state{privacy_list = NewPL})
|
NewState#state{privacy_list = NewPL})
|
||||||
end;
|
end;
|
||||||
@ -1682,7 +1624,8 @@ handle_info({route, From, To,
|
|||||||
From, To,
|
From, To,
|
||||||
Packet, in)
|
Packet, in)
|
||||||
of
|
of
|
||||||
allow -> {true, Attrs, StateData};
|
allow ->
|
||||||
|
{true, Attrs, StateData};
|
||||||
deny ->
|
deny ->
|
||||||
case xml:get_attr_s(<<"type">>, Attrs) of
|
case xml:get_attr_s(<<"type">>, Attrs) of
|
||||||
<<"error">> -> ok;
|
<<"error">> -> ok;
|
||||||
@ -1798,23 +1741,11 @@ handle_info(Info, StateName, StateData) ->
|
|||||||
?ERROR_MSG("Unexpected info: ~p", [Info]),
|
?ERROR_MSG("Unexpected info: ~p", [Info]),
|
||||||
fsm_next_state(StateName, StateData).
|
fsm_next_state(StateName, StateData).
|
||||||
|
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: print_state/1
|
|
||||||
%% Purpose: Prepare the state to be printed on error log
|
|
||||||
%% Returns: State to print
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
print_state(State = #state{pres_t = T, pres_f = F, pres_a = A}) ->
|
print_state(State = #state{pres_t = T, pres_f = F, pres_a = A}) ->
|
||||||
State#state{pres_t = {pres_t, ?SETS:size(T)},
|
State#state{pres_t = {pres_t, (?SETS):size(T)},
|
||||||
pres_f = {pres_f, ?SETS:size(F)},
|
pres_f = {pres_f, (?SETS):size(F)},
|
||||||
pres_a = {pres_a, ?SETS:size(A)}
|
pres_a = {pres_a, (?SETS):size(A)}}.
|
||||||
}.
|
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: terminate/3
|
|
||||||
%% Purpose: Shutdown the fsm
|
|
||||||
%% Returns: any
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
terminate(_Reason, StateName, StateData) ->
|
terminate(_Reason, StateName, StateData) ->
|
||||||
case StateData#state.mgmt_state of
|
case StateData#state.mgmt_state of
|
||||||
resumed ->
|
resumed ->
|
||||||
@ -2042,12 +1973,11 @@ process_presence_probe(From, To, StateData) ->
|
|||||||
undefined ->
|
undefined ->
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
Cond = ?SETS:is_element(LFrom, StateData#state.pres_f)
|
Cond = ((?SETS):is_element(LFrom, StateData#state.pres_f)
|
||||||
orelse
|
orelse
|
||||||
((LFrom /= LBFrom) andalso
|
((LFrom /= LBFrom) andalso
|
||||||
?SETS:is_element(LBFrom, StateData#state.pres_f)),
|
(?SETS):is_element(LBFrom, StateData#state.pres_f))),
|
||||||
if
|
if Cond ->
|
||||||
Cond ->
|
|
||||||
%% To is the one sending the presence (the probe target)
|
%% To is the one sending the presence (the probe target)
|
||||||
Packet = jlib:add_delay_info(StateData#state.pres_last, To,
|
Packet = jlib:add_delay_info(StateData#state.pres_last, To,
|
||||||
StateData#state.pres_timestamp),
|
StateData#state.pres_timestamp),
|
||||||
@ -2283,11 +2213,11 @@ roster_change(IJID, ISubscription, StateData) ->
|
|||||||
OldIsFrom = (?SETS):is_element(LIJID, StateData#state.pres_f),
|
OldIsFrom = (?SETS):is_element(LIJID, StateData#state.pres_f),
|
||||||
FSet = if
|
FSet = if
|
||||||
IsFrom -> (?SETS):add_element(LIJID, StateData#state.pres_f);
|
IsFrom -> (?SETS):add_element(LIJID, StateData#state.pres_f);
|
||||||
not IsFrom -> remove_element(LIJID, StateData#state.pres_f)
|
true -> remove_element(LIJID, StateData#state.pres_f)
|
||||||
end,
|
end,
|
||||||
TSet = if
|
TSet = if
|
||||||
IsTo -> (?SETS):add_element(LIJID, StateData#state.pres_t);
|
IsTo -> (?SETS):add_element(LIJID, StateData#state.pres_t);
|
||||||
not IsTo -> remove_element(LIJID, StateData#state.pres_t)
|
true -> remove_element(LIJID, StateData#state.pres_t)
|
||||||
end,
|
end,
|
||||||
case StateData#state.pres_last of
|
case StateData#state.pres_last of
|
||||||
undefined ->
|
undefined ->
|
||||||
|
@ -75,13 +75,6 @@
|
|||||||
tref :: reference(),
|
tref :: reference(),
|
||||||
args :: any()}).
|
args :: any()}).
|
||||||
|
|
||||||
%%====================================================================
|
|
||||||
%% API
|
|
||||||
%%====================================================================
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
|
|
||||||
%% Description: Starts the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [],
|
gen_server:start_link({local, ?MODULE}, ?MODULE, [],
|
||||||
[]).
|
[]).
|
||||||
@ -276,12 +269,6 @@ create_captcha_x(SID, To, Lang, Limiter, HeadEls,
|
|||||||
Err -> Err
|
Err -> Err
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec (Id::string(), Lang::string()) -> {FormEl, {ImgEl, TextEl, IdEl, KeyEl}} | captcha_not_found
|
|
||||||
%% where FormEl = xmlelement()
|
|
||||||
%% ImgEl = xmlelement()
|
|
||||||
%% TextEl = xmlelement()
|
|
||||||
%% IdEl = xmlelement()
|
|
||||||
%% KeyEl = xmlelement()
|
|
||||||
-spec build_captcha_html(binary(), binary()) -> captcha_not_found |
|
-spec build_captcha_html(binary(), binary()) -> captcha_not_found |
|
||||||
{xmlel(),
|
{xmlel(),
|
||||||
{xmlel(), xmlel(),
|
{xmlel(), xmlel(),
|
||||||
@ -330,12 +317,6 @@ build_captcha_html(Id, Lang) ->
|
|||||||
_ -> captcha_not_found
|
_ -> captcha_not_found
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec (Id::string(), ProvidedKey::string()) -> captcha_valid | captcha_non_valid | captcha_not_found
|
|
||||||
-spec check_captcha(binary(), binary()) -> captcha_not_found |
|
|
||||||
captcha_valid |
|
|
||||||
captcha_non_valid.
|
|
||||||
|
|
||||||
|
|
||||||
-spec process_reply(xmlel()) -> ok | {error, bad_match | not_found | malformed}.
|
-spec process_reply(xmlel()) -> ok | {error, bad_match | not_found | malformed}.
|
||||||
|
|
||||||
process_reply(#xmlel{} = El) ->
|
process_reply(#xmlel{} = El) ->
|
||||||
@ -405,9 +386,6 @@ process(_Handlers,
|
|||||||
process(_Handlers, _Request) ->
|
process(_Handlers, _Request) ->
|
||||||
ejabberd_web:error(not_found).
|
ejabberd_web:error(not_found).
|
||||||
|
|
||||||
%%====================================================================
|
|
||||||
%% gen_server callbacks
|
|
||||||
%%====================================================================
|
|
||||||
init([]) ->
|
init([]) ->
|
||||||
mnesia:delete_table(captcha),
|
mnesia:delete_table(captcha),
|
||||||
ets:new(captcha,
|
ets:new(captcha,
|
||||||
@ -454,16 +432,6 @@ terminate(_Reason, _State) -> ok.
|
|||||||
|
|
||||||
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%%% Internal functions
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: create_image() -> {ok, Type, Key, Image} | {error, Reason}
|
|
||||||
%% Type = "image/png" | "image/jpeg" | "image/gif"
|
|
||||||
%% Key = string()
|
|
||||||
%% Image = binary()
|
|
||||||
%% Reason = atom()
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
create_image() -> create_image(undefined).
|
create_image() -> create_image(undefined).
|
||||||
|
|
||||||
create_image(Limiter) ->
|
create_image(Limiter) ->
|
||||||
@ -596,12 +564,6 @@ is_limited(Limiter) ->
|
|||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: cmd(Cmd) -> Data | {error, Reason}
|
|
||||||
%% Cmd = string()
|
|
||||||
%% Data = binary()
|
|
||||||
%% Description: os:cmd/1 replacement
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
-define(CMD_TIMEOUT, 5000).
|
-define(CMD_TIMEOUT, 5000).
|
||||||
|
|
||||||
-define(MAX_FILE_SIZE, 64 * 1024).
|
-define(MAX_FILE_SIZE, 64 * 1024).
|
||||||
@ -663,6 +625,10 @@ lookup_captcha(Id) ->
|
|||||||
_ -> {error, enoent}
|
_ -> {error, enoent}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec check_captcha(binary(), binary()) -> captcha_not_found |
|
||||||
|
captcha_valid |
|
||||||
|
captcha_non_valid.
|
||||||
|
|
||||||
check_captcha(Id, ProvidedKey) ->
|
check_captcha(Id, ProvidedKey) ->
|
||||||
case ets:lookup(captcha, Id) of
|
case ets:lookup(captcha, Id) of
|
||||||
[#captcha{pid = Pid, args = Args, key = ValidKey,
|
[#captcha{pid = Pid, args = Args, key = ValidKey,
|
||||||
|
53
src/ejabberd_cluster.erl
Normal file
53
src/ejabberd_cluster.erl
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
%%%----------------------------------------------------------------------
|
||||||
|
%%% File : ejabberd_cluster.erl
|
||||||
|
%%% Author : Christophe Romain <christophe.romain@process-one.net>
|
||||||
|
%%% Purpose : Ejabberd clustering management
|
||||||
|
%%% Created : 7 Oct 2015 by Christophe Romain <christophe.romain@process-one.net>
|
||||||
|
%%%
|
||||||
|
%%%
|
||||||
|
%%% ejabberd, Copyright (C) 2002-2015 ProcessOne
|
||||||
|
%%%
|
||||||
|
%%% This program is free software; you can redistribute it and/or
|
||||||
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
%%% published by the Free Software Foundation; either version 2 of the
|
||||||
|
%%% License, or (at your option) any later version.
|
||||||
|
%%%
|
||||||
|
%%% This program is distributed in the hope that it will be useful,
|
||||||
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
%%% General Public License for more details.
|
||||||
|
%%%
|
||||||
|
%%% You should have received a copy of the GNU General Public License along
|
||||||
|
%%% with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
%%%
|
||||||
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
|
-module(ejabberd_cluster).
|
||||||
|
|
||||||
|
%% API
|
||||||
|
-export([get_nodes/0, call/4, multicall/3, multicall/4]).
|
||||||
|
|
||||||
|
-include("ejabberd.hrl").
|
||||||
|
-include("logger.hrl").
|
||||||
|
|
||||||
|
-spec get_nodes() -> [node()].
|
||||||
|
|
||||||
|
get_nodes() ->
|
||||||
|
mnesia:system_info(running_db_nodes).
|
||||||
|
|
||||||
|
-spec call(node(), module(), atom(), [any()]) -> any().
|
||||||
|
|
||||||
|
call(Node, Module, Function, Args) ->
|
||||||
|
rpc:call(Node, Module, Function, Args, 5000).
|
||||||
|
|
||||||
|
-spec multicall(module(), atom(), [any()]) -> {list(), [node()]}.
|
||||||
|
|
||||||
|
multicall(Module, Function, Args) ->
|
||||||
|
multicall(get_nodes(), Module, Function, Args).
|
||||||
|
|
||||||
|
-spec multicall([node()], module(), atom(), list()) -> {list(), [node()]}.
|
||||||
|
|
||||||
|
multicall(Nodes, Module, Function, Args) ->
|
||||||
|
rpc:multicall(Nodes, Module, Function, Args, 5000).
|
||||||
|
|
@ -192,7 +192,6 @@ env_binary_to_list(Application, Parameter) ->
|
|||||||
%% Returns a list of plain terms,
|
%% Returns a list of plain terms,
|
||||||
%% in which the options 'include_config_file' were parsed
|
%% in which the options 'include_config_file' were parsed
|
||||||
%% and the terms in those files were included.
|
%% and the terms in those files were included.
|
||||||
%% @spec(string()) -> [term()]
|
|
||||||
%% @spec(iolist()) -> [term()]
|
%% @spec(iolist()) -> [term()]
|
||||||
get_plain_terms_file(File) ->
|
get_plain_terms_file(File) ->
|
||||||
get_plain_terms_file(File, [{include_files, true}]).
|
get_plain_terms_file(File, [{include_files, true}]).
|
||||||
@ -844,6 +843,7 @@ replace_module(mod_roster_odbc) -> {mod_roster, odbc};
|
|||||||
replace_module(mod_shared_roster_odbc) -> {mod_shared_roster, odbc};
|
replace_module(mod_shared_roster_odbc) -> {mod_shared_roster, odbc};
|
||||||
replace_module(mod_vcard_odbc) -> {mod_vcard, odbc};
|
replace_module(mod_vcard_odbc) -> {mod_vcard, odbc};
|
||||||
replace_module(mod_vcard_xupdate_odbc) -> {mod_vcard_xupdate, odbc};
|
replace_module(mod_vcard_xupdate_odbc) -> {mod_vcard_xupdate, odbc};
|
||||||
|
replace_module(mod_pubsub_odbc) -> {mod_pubsub, odbc};
|
||||||
replace_module(Module) ->
|
replace_module(Module) ->
|
||||||
case is_elixir_module(Module) of
|
case is_elixir_module(Module) of
|
||||||
true -> expand_elixir_module(Module);
|
true -> expand_elixir_module(Module);
|
||||||
|
@ -80,7 +80,7 @@ start() ->
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
Node = list_to_atom(SNode1),
|
Node = list_to_atom(SNode1),
|
||||||
Status = case rpc:call(Node, ?MODULE, process, [Args]) of
|
Status = case ejabberd_cluster:call(Node, ?MODULE, process, [Args]) of
|
||||||
{badrpc, Reason} ->
|
{badrpc, Reason} ->
|
||||||
print("Failed RPC connection to the node ~p: ~p~n",
|
print("Failed RPC connection to the node ~p: ~p~n",
|
||||||
[Node, Reason]),
|
[Node, Reason]),
|
||||||
@ -392,7 +392,10 @@ format_result(ElementsTuple, {_Name, {tuple, ElementsDef}}) ->
|
|||||||
fun({Element, ElementDef}) ->
|
fun({Element, ElementDef}) ->
|
||||||
["\t" | format_result(Element, ElementDef)]
|
["\t" | format_result(Element, ElementDef)]
|
||||||
end,
|
end,
|
||||||
ElementsAndDef)].
|
ElementsAndDef)];
|
||||||
|
|
||||||
|
format_result(404, {_Name, _}) ->
|
||||||
|
make_status(not_found).
|
||||||
|
|
||||||
make_status(ok) -> ?STATUS_SUCCESS;
|
make_status(ok) -> ?STATUS_SUCCESS;
|
||||||
make_status(true) -> ?STATUS_SUCCESS;
|
make_status(true) -> ?STATUS_SUCCESS;
|
||||||
|
@ -58,10 +58,6 @@
|
|||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
|
|
||||||
%% Description: Starts the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
start_link(Module, SockMod, Socket, Opts, Receiver) ->
|
start_link(Module, SockMod, Socket, Opts, Receiver) ->
|
||||||
gen_server:start_link(?MODULE,
|
gen_server:start_link(?MODULE,
|
||||||
[Module, SockMod, Socket, Opts, Receiver], []).
|
[Module, SockMod, Socket, Opts, Receiver], []).
|
||||||
@ -137,18 +133,10 @@ peername(_FsmRef) ->
|
|||||||
%%gen_server:call(FsmRef, peername).
|
%%gen_server:call(FsmRef, peername).
|
||||||
{ok, {{0, 0, 0, 0}, 0}}.
|
{ok, {{0, 0, 0, 0}, 0}}.
|
||||||
|
|
||||||
|
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: init(Args) -> {ok, State} |
|
|
||||||
%% {ok, State, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, Reason}
|
|
||||||
%% Description: Initiates the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
init([Module, SockMod, Socket, Opts, Receiver]) ->
|
init([Module, SockMod, Socket, Opts, Receiver]) ->
|
||||||
Node = ejabberd_node_groups:get_closest_node(backend),
|
Node = ejabberd_node_groups:get_closest_node(backend),
|
||||||
{SockMod2, Socket2} = check_starttls(SockMod, Socket, Receiver, Opts),
|
{SockMod2, Socket2} = check_starttls(SockMod, Socket, Receiver, Opts),
|
||||||
@ -159,15 +147,6 @@ init([Module, SockMod, Socket, Opts, Receiver]) ->
|
|||||||
socket = Socket2,
|
socket = Socket2,
|
||||||
receiver = Receiver}}.
|
receiver = Receiver}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
|
|
||||||
%% {reply, Reply, State, Timeout} |
|
|
||||||
%% {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, Reply, State} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling call messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_call({starttls, TLSOpts}, _From, State) ->
|
handle_call({starttls, TLSOpts}, _From, State) ->
|
||||||
{ok, TLSSocket} = p1_tls:tcp_to_tls(State#state.socket, TLSOpts),
|
{ok, TLSSocket} = p1_tls:tcp_to_tls(State#state.socket, TLSOpts),
|
||||||
ejabberd_receiver:starttls(State#state.receiver, TLSSocket),
|
ejabberd_receiver:starttls(State#state.receiver, TLSSocket),
|
||||||
@ -184,7 +163,6 @@ handle_call({starttls, TLSOpts, Data}, _From, State) ->
|
|||||||
{reply, Reply,
|
{reply, Reply,
|
||||||
State#state{socket = TLSSocket, sockmod = p1_tls},
|
State#state{socket = TLSSocket, sockmod = p1_tls},
|
||||||
?HIBERNATE_TIMEOUT};
|
?HIBERNATE_TIMEOUT};
|
||||||
|
|
||||||
handle_call({compress, Data}, _From, State) ->
|
handle_call({compress, Data}, _From, State) ->
|
||||||
{ok, ZlibSocket} =
|
{ok, ZlibSocket} =
|
||||||
ejabberd_receiver:compress(State#state.receiver, Data),
|
ejabberd_receiver:compress(State#state.receiver, Data),
|
||||||
@ -238,21 +216,9 @@ handle_call(peername, _From, State) ->
|
|||||||
handle_call(_Request, _From, State) ->
|
handle_call(_Request, _From, State) ->
|
||||||
Reply = ok, {reply, Reply, State, ?HIBERNATE_TIMEOUT}.
|
Reply = ok, {reply, Reply, State, ?HIBERNATE_TIMEOUT}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_cast(Msg, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_cast(_Msg, State) ->
|
handle_cast(_Msg, State) ->
|
||||||
{noreply, State, ?HIBERNATE_TIMEOUT}.
|
{noreply, State, ?HIBERNATE_TIMEOUT}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_info(Info, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling all non call/cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_info(timeout, State) ->
|
handle_info(timeout, State) ->
|
||||||
proc_lib:hibernate(gen_server, enter_loop,
|
proc_lib:hibernate(gen_server, enter_loop,
|
||||||
[?MODULE, [], State]),
|
[?MODULE, [], State]),
|
||||||
@ -260,31 +226,16 @@ handle_info(timeout, State) ->
|
|||||||
handle_info(_Info, State) ->
|
handle_info(_Info, State) ->
|
||||||
{noreply, State, ?HIBERNATE_TIMEOUT}.
|
{noreply, State, ?HIBERNATE_TIMEOUT}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: terminate(Reason, State) -> void()
|
|
||||||
%% Description: This function is called by a gen_server when it is about to
|
|
||||||
%% terminate. It should be the opposite of Module:init/1 and do any necessary
|
|
||||||
%% cleaning up. When it returns, the gen_server terminates with Reason.
|
|
||||||
%% The return value is ignored.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
terminate(_Reason, _State) -> ok.
|
terminate(_Reason, _State) -> ok.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
|
|
||||||
%% Description: Convert process state when code is changed
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%%% Internal functions
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
check_starttls(SockMod, Socket, Receiver, Opts) ->
|
check_starttls(SockMod, Socket, Receiver, Opts) ->
|
||||||
TLSEnabled = proplists:get_bool(tls, Opts),
|
TLSEnabled = proplists:get_bool(tls, Opts),
|
||||||
TLSOpts = lists:filter(fun({certfile, _}) -> true;
|
TLSOpts = lists:filter(fun({certfile, _}) -> true;
|
||||||
(_) -> false
|
(_) -> false
|
||||||
end, Opts),
|
end, Opts),
|
||||||
if
|
if TLSEnabled ->
|
||||||
TLSEnabled ->
|
|
||||||
{ok, TLSSocket} = p1_tls:tcp_to_tls(Socket, TLSOpts),
|
{ok, TLSSocket} = p1_tls:tcp_to_tls(Socket, TLSOpts),
|
||||||
ejabberd_receiver:starttls(Receiver, TLSSocket),
|
ejabberd_receiver:starttls(Receiver, TLSSocket),
|
||||||
{p1_tls, TLSSocket};
|
{p1_tls, TLSSocket};
|
||||||
|
@ -58,9 +58,6 @@
|
|||||||
|
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
|
||||||
%% Timeout of 5 seconds in calls to distributed hooks
|
|
||||||
-define(TIMEOUT_DISTRIBUTED_HOOK, 5000).
|
|
||||||
|
|
||||||
-record(state, {}).
|
-record(state, {}).
|
||||||
-type local_hook() :: { Seq :: integer(), Module :: atom(), Function :: atom()}.
|
-type local_hook() :: { Seq :: integer(), Module :: atom(), Function :: atom()}.
|
||||||
-type distributed_hook() :: { Seq :: integer(), Node :: atom(), Module :: atom(), Function :: atom()}.
|
-type distributed_hook() :: { Seq :: integer(), Node :: atom(), Module :: atom(), Function :: atom()}.
|
||||||
@ -310,7 +307,7 @@ run1([], _Hook, _Args) ->
|
|||||||
%% It is not attempted again in case of failure. Next hook will be executed
|
%% It is not attempted again in case of failure. Next hook will be executed
|
||||||
run1([{_Seq, Node, Module, Function} | Ls], Hook, Args) ->
|
run1([{_Seq, Node, Module, Function} | Ls], Hook, Args) ->
|
||||||
%% MR: Should we have a safe rpc, like we have a safe apply or is bad_rpc enough ?
|
%% MR: Should we have a safe rpc, like we have a safe apply or is bad_rpc enough ?
|
||||||
case rpc:call(Node, Module, Function, Args, ?TIMEOUT_DISTRIBUTED_HOOK) of
|
case ejabberd_cluster:call(Node, Module, Function, Args) of
|
||||||
timeout ->
|
timeout ->
|
||||||
?ERROR_MSG("Timeout on RPC to ~p~nrunning hook: ~p",
|
?ERROR_MSG("Timeout on RPC to ~p~nrunning hook: ~p",
|
||||||
[Node, {Hook, Args}]),
|
[Node, {Hook, Args}]),
|
||||||
@ -344,7 +341,7 @@ run1([{_Seq, Module, Function} | Ls], Hook, Args) ->
|
|||||||
run_fold1([], _Hook, Val, _Args) ->
|
run_fold1([], _Hook, Val, _Args) ->
|
||||||
Val;
|
Val;
|
||||||
run_fold1([{_Seq, Node, Module, Function} | Ls], Hook, Val, Args) ->
|
run_fold1([{_Seq, Node, Module, Function} | Ls], Hook, Val, Args) ->
|
||||||
case rpc:call(Node, Module, Function, [Val | Args], ?TIMEOUT_DISTRIBUTED_HOOK) of
|
case ejabberd_cluster:call(Node, Module, Function, [Val | Args]) of
|
||||||
{badrpc, Reason} ->
|
{badrpc, Reason} ->
|
||||||
?ERROR_MSG("Bad RPC error to ~p: ~p~nrunning hook: ~p",
|
?ERROR_MSG("Bad RPC error to ~p: ~p~nrunning hook: ~p",
|
||||||
[Node, Reason, {Hook, Args}]),
|
[Node, Reason, {Hook, Args}]),
|
||||||
|
@ -166,7 +166,8 @@ init({SockMod, Socket}, Opts) ->
|
|||||||
{error, _} -> State
|
{error, _} -> State
|
||||||
end.
|
end.
|
||||||
|
|
||||||
become_controller(_Pid) -> ok.
|
become_controller(_Pid) ->
|
||||||
|
ok.
|
||||||
|
|
||||||
socket_type() ->
|
socket_type() ->
|
||||||
raw.
|
raw.
|
||||||
@ -208,10 +209,8 @@ parse_headers(#state{request_method = Method,
|
|||||||
{ok, Pkt, Rest} ->
|
{ok, Pkt, Rest} ->
|
||||||
NewState = process_header(State#state{trail = Rest}, {ok, Pkt}),
|
NewState = process_header(State#state{trail = Rest}, {ok, Pkt}),
|
||||||
case NewState#state.end_of_request of
|
case NewState#state.end_of_request of
|
||||||
true ->
|
true -> ok;
|
||||||
ok;
|
_ -> parse_headers(NewState)
|
||||||
_ ->
|
|
||||||
parse_headers(NewState)
|
|
||||||
end;
|
end;
|
||||||
{more, _} ->
|
{more, _} ->
|
||||||
receive_headers(State#state{trail = Data});
|
receive_headers(State#state{trail = Data});
|
||||||
@ -267,9 +266,7 @@ process_header(State, Data) ->
|
|||||||
request_headers = add_header(Name, Host, State)};
|
request_headers = add_header(Name, Host, State)};
|
||||||
{ok, {http_header, _, Name, _, Value}} when is_binary(Name) ->
|
{ok, {http_header, _, Name, _, Value}} when is_binary(Name) ->
|
||||||
State#state{request_headers =
|
State#state{request_headers =
|
||||||
add_header(normalize_header_name(Name),
|
add_header(normalize_header_name(Name), Value, State)};
|
||||||
Value,
|
|
||||||
State)};
|
|
||||||
{ok, {http_header, _, Name, _, Value}} ->
|
{ok, {http_header, _, Name, _, Value}} ->
|
||||||
State#state{request_headers =
|
State#state{request_headers =
|
||||||
add_header(Name, Value, State)};
|
add_header(Name, Value, State)};
|
||||||
@ -322,14 +319,6 @@ get_host_really_served(Default, Provided) ->
|
|||||||
false -> Default
|
false -> Default
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec (SockMod, HostPort) -> {Host::string(), Port::integer(), TP}
|
|
||||||
%% where
|
|
||||||
%% SockMod = gen_tcp | tls
|
|
||||||
%% HostPort = string()
|
|
||||||
%% TP = http | https
|
|
||||||
%% @doc Given a socket and hostport header, return data of transfer protocol.
|
|
||||||
%% Note that HostPort can be a string of a host like "example.org",
|
|
||||||
%% or a string of a host and port like "example.org:5280".
|
|
||||||
get_transfer_protocol(SockMod, HostPort) ->
|
get_transfer_protocol(SockMod, HostPort) ->
|
||||||
[Host | PortList] = str:tokens(HostPort, <<":">>),
|
[Host | PortList] = str:tokens(HostPort, <<":">>),
|
||||||
case {SockMod, PortList} of
|
case {SockMod, PortList} of
|
||||||
@ -476,7 +465,6 @@ process_request(#state{request_method = Method,
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
make_bad_request(State) ->
|
make_bad_request(State) ->
|
||||||
%% Support for X-Forwarded-From
|
|
||||||
make_xhtml_output(State, 400, [],
|
make_xhtml_output(State, 400, [],
|
||||||
ejabberd_web:make_xhtml([#xmlel{name = <<"h1">>,
|
ejabberd_web:make_xhtml([#xmlel{name = <<"h1">>,
|
||||||
attrs = [],
|
attrs = [],
|
||||||
|
@ -1,11 +1,27 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : ejabberd_http_bind.erl
|
%%% File : ejabberd_http_bind.erl
|
||||||
%%% Author : Stefan Strigler <steve@zeank.in-berlin.de>
|
%%% Author : Stefan Strigler <steve@zeank.in-berlin.de>
|
||||||
%%% Purpose : Implements XMPP over BOSH (XEP-0206) (formerly known as
|
%%% Purpose : Implements XMPP over BOSH (XEP-0206)
|
||||||
%%% HTTP Binding)
|
|
||||||
%%% Created : 21 Sep 2005 by Stefan Strigler <steve@zeank.in-berlin.de>
|
%%% Created : 21 Sep 2005 by Stefan Strigler <steve@zeank.in-berlin.de>
|
||||||
%%% Modified: may 2009 by Mickael Remond, Alexey Schepin
|
%%% Modified: may 2009 by Mickael Remond, Alexey Schepin
|
||||||
%%% Id : $Id: ejabberd_http_bind.erl 953 2009-05-07 10:40:40Z alexey $
|
%%%
|
||||||
|
%%%
|
||||||
|
%%% ejabberd, Copyright (C) 2002-2015 ProcessOne
|
||||||
|
%%%
|
||||||
|
%%% This program is free software; you can redistribute it and/or
|
||||||
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
%%% published by the Free Software Foundation; either version 2 of the
|
||||||
|
%%% License, or (at your option) any later version.
|
||||||
|
%%%
|
||||||
|
%%% This program is distributed in the hope that it will be useful,
|
||||||
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
%%% General Public License for more details.
|
||||||
|
%%%
|
||||||
|
%%% You should have received a copy of the GNU General Public License along
|
||||||
|
%%% with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(ejabberd_http_bind).
|
-module(ejabberd_http_bind).
|
||||||
@ -78,7 +94,7 @@
|
|||||||
wait_timer,
|
wait_timer,
|
||||||
ctime = 0,
|
ctime = 0,
|
||||||
timer,
|
timer,
|
||||||
pause=0,
|
pause = 0,
|
||||||
unprocessed_req_list = [], % list of request that have been delayed for proper reordering: {Request, PID}
|
unprocessed_req_list = [], % list of request that have been delayed for proper reordering: {Request, PID}
|
||||||
req_list = [], % list of requests (cache)
|
req_list = [], % list of requests (cache)
|
||||||
max_inactivity,
|
max_inactivity,
|
||||||
@ -132,18 +148,14 @@
|
|||||||
|
|
||||||
-define(PROCESS_DELAY_MAX, 1000).
|
-define(PROCESS_DELAY_MAX, 1000).
|
||||||
|
|
||||||
%% Line copied from mod_http_bind.erl
|
|
||||||
-define(PROCNAME_MHB, ejabberd_mod_http_bind).
|
-define(PROCNAME_MHB, ejabberd_mod_http_bind).
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
|
||||||
%%% API
|
|
||||||
%%%----------------------------------------------------------------------
|
|
||||||
%% TODO: If compile with no supervisor option, start the session without
|
|
||||||
%% supervisor
|
|
||||||
start(XMPPDomain, Sid, Key, IP, HOpts) ->
|
start(XMPPDomain, Sid, Key, IP, HOpts) ->
|
||||||
?DEBUG("Starting session", []),
|
?DEBUG("Starting session", []),
|
||||||
SupervisorProc = gen_mod:get_module_proc(XMPPDomain, ?PROCNAME_MHB),
|
SupervisorProc = gen_mod:get_module_proc(XMPPDomain, ?PROCNAME_MHB),
|
||||||
case catch supervisor:start_child(SupervisorProc, [Sid, Key, IP, HOpts]) of
|
case catch supervisor:start_child(SupervisorProc,
|
||||||
|
[Sid, Key, IP, HOpts])
|
||||||
|
of
|
||||||
{ok, Pid} -> {ok, Pid};
|
{ok, Pid} -> {ok, Pid};
|
||||||
_ -> check_bind_module(XMPPDomain),
|
_ -> check_bind_module(XMPPDomain),
|
||||||
{error, "Cannot start HTTP bind session"}
|
{error, "Cannot start HTTP bind session"}
|
||||||
@ -323,13 +335,6 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs,
|
|||||||
%%% Callback functions from gen_fsm
|
%%% Callback functions from gen_fsm
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: init/1
|
|
||||||
%% Returns: {ok, StateName, StateData} |
|
|
||||||
%% {ok, StateName, StateData, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, StopReason}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
init([Sid, Key, IP, HOpts]) ->
|
init([Sid, Key, IP, HOpts]) ->
|
||||||
?DEBUG("started: ~p", [{Sid, Key, IP}]),
|
?DEBUG("started: ~p", [{Sid, Key, IP}]),
|
||||||
Opts1 = ejabberd_c2s_config:get_c2s_limits(),
|
Opts1 = ejabberd_c2s_config:get_c2s_limits(),
|
||||||
@ -355,12 +360,6 @@ init([Sid, Key, IP, HOpts]) ->
|
|||||||
max_pause = ?MAX_PAUSE,
|
max_pause = ?MAX_PAUSE,
|
||||||
timer = Timer}}.
|
timer = Timer}}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_event/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_event({become_controller, C2SPid}, StateName, StateData) ->
|
handle_event({become_controller, C2SPid}, StateName, StateData) ->
|
||||||
case StateData#state.input of
|
case StateData#state.input of
|
||||||
cancel ->
|
cancel ->
|
||||||
@ -381,15 +380,6 @@ handle_event({change_shaper, Shaper}, StateName,
|
|||||||
handle_event(_Event, StateName, StateData) ->
|
handle_event(_Event, StateName, StateData) ->
|
||||||
{next_state, StateName, StateData}.
|
{next_state, StateName, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_sync_event/4
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData} |
|
|
||||||
%% {stop, Reason, Reply, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_sync_event({send_xml, Packet}, _From, StateName,
|
handle_sync_event({send_xml, Packet}, _From, StateName,
|
||||||
#state{http_receiver = undefined} = StateData) ->
|
#state{http_receiver = undefined} = StateData) ->
|
||||||
Output = [Packet | StateData#state.output],
|
Output = [Packet | StateData#state.output],
|
||||||
@ -458,10 +448,8 @@ handle_sync_event(#http_put{payload_size =
|
|||||||
shaper_timer = NewShaperTimer});
|
shaper_timer = NewShaperTimer});
|
||||||
%% HTTP GET: send packets to the client
|
%% HTTP GET: send packets to the client
|
||||||
handle_sync_event({http_get, Rid, Wait, Hold}, From, StateName, StateData) ->
|
handle_sync_event({http_get, Rid, Wait, Hold}, From, StateName, StateData) ->
|
||||||
%% setup timer
|
|
||||||
TNow = tnow(),
|
TNow = tnow(),
|
||||||
if
|
if (Hold > 0) and
|
||||||
(Hold > 0) and
|
|
||||||
((StateData#state.output == []) or (StateData#state.rid < Rid)) and
|
((StateData#state.output == []) or (StateData#state.rid < Rid)) and
|
||||||
((TNow - StateData#state.ctime) < (Wait*1000*1000)) and
|
((TNow - StateData#state.ctime) < (Wait*1000*1000)) and
|
||||||
(StateData#state.rid =< Rid) and
|
(StateData#state.rid =< Rid) and
|
||||||
@ -469,7 +457,6 @@ handle_sync_event({http_get, Rid, Wait, Hold}, From, StateName, StateData) ->
|
|||||||
send_receiver_reply(StateData#state.http_receiver, {ok, empty}),
|
send_receiver_reply(StateData#state.http_receiver, {ok, empty}),
|
||||||
cancel_timer(StateData#state.wait_timer),
|
cancel_timer(StateData#state.wait_timer),
|
||||||
WaitTimer = erlang:start_timer(Wait * 1000, self(), []),
|
WaitTimer = erlang:start_timer(Wait * 1000, self(), []),
|
||||||
%% MR: Not sure we should cancel the state timer here.
|
|
||||||
cancel_timer(StateData#state.timer),
|
cancel_timer(StateData#state.timer),
|
||||||
{next_state, StateName, StateData#state{
|
{next_state, StateName, StateData#state{
|
||||||
http_receiver = From,
|
http_receiver = From,
|
||||||
@ -479,20 +466,16 @@ handle_sync_event({http_get, Rid, Wait, Hold}, From, StateName, StateData) ->
|
|||||||
true ->
|
true ->
|
||||||
cancel_timer(StateData#state.timer),
|
cancel_timer(StateData#state.timer),
|
||||||
Reply = {ok, StateData#state.output},
|
Reply = {ok, StateData#state.output},
|
||||||
%% save request
|
|
||||||
ReqList = [#hbr{rid = Rid,
|
ReqList = [#hbr{rid = Rid,
|
||||||
key = StateData#state.key,
|
key = StateData#state.key,
|
||||||
out = StateData#state.output
|
out = StateData#state.output}
|
||||||
} |
|
| [El
|
||||||
[El || El <- StateData#state.req_list,
|
|| El <- StateData#state.req_list,
|
||||||
El#hbr.rid /= Rid ]
|
El#hbr.rid /= Rid]],
|
||||||
],
|
if (StateData#state.http_receiver /= undefined) and
|
||||||
if
|
|
||||||
(StateData#state.http_receiver /= undefined) and
|
|
||||||
StateData#state.out_of_order_receiver ->
|
StateData#state.out_of_order_receiver ->
|
||||||
{reply, Reply, StateName, StateData#state{
|
{reply, Reply, StateName,
|
||||||
output = [],
|
StateData#state{output = [], timer = undefined,
|
||||||
timer = undefined,
|
|
||||||
req_list = ReqList,
|
req_list = ReqList,
|
||||||
out_of_order_receiver = false}};
|
out_of_order_receiver = false}};
|
||||||
true ->
|
true ->
|
||||||
@ -519,13 +502,6 @@ handle_sync_event(_Event, _From, StateName,
|
|||||||
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
||||||
{ok, StateName, StateData}.
|
{ok, StateName, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_info/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% We reached the max_inactivity timeout:
|
|
||||||
handle_info({timeout, Timer, _}, _StateName,
|
handle_info({timeout, Timer, _}, _StateName,
|
||||||
#state{id = SID, timer = Timer} = StateData) ->
|
#state{id = SID, timer = Timer} = StateData) ->
|
||||||
?INFO_MSG("Session timeout. Closing the HTTP bind "
|
?INFO_MSG("Session timeout. Closing the HTTP bind "
|
||||||
@ -558,11 +534,6 @@ handle_info({timeout, ShaperTimer, _}, StateName,
|
|||||||
handle_info(_, StateName, StateData) ->
|
handle_info(_, StateName, StateData) ->
|
||||||
{next_state, StateName, StateData}.
|
{next_state, StateName, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: terminate/3
|
|
||||||
%% Purpose: Shutdown the fsm
|
|
||||||
%% Returns: any
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
terminate(_Reason, _StateName, StateData) ->
|
terminate(_Reason, _StateName, StateData) ->
|
||||||
?DEBUG("terminate: Deleting session ~s",
|
?DEBUG("terminate: Deleting session ~s",
|
||||||
[StateData#state.id]),
|
[StateData#state.id]),
|
||||||
@ -805,18 +776,21 @@ http_put(Sid, Rid, Attrs, Payload, PayloadSize,
|
|||||||
case mnesia:dirty_read({http_bind, Sid}) of
|
case mnesia:dirty_read({http_bind, Sid}) of
|
||||||
[] ->
|
[] ->
|
||||||
{error, not_exists};
|
{error, not_exists};
|
||||||
[#http_bind{pid = FsmRef, hold=Hold, to={To, StreamVersion}}=Sess] ->
|
[#http_bind{pid = FsmRef, hold=Hold,
|
||||||
NewStream =
|
to= {To, StreamVersion}} = Sess] ->
|
||||||
case StreamStart of
|
NewStream = case StreamStart of
|
||||||
true ->
|
true -> {To, StreamVersion};
|
||||||
{To, StreamVersion};
|
_ -> <<"">>
|
||||||
_ ->
|
|
||||||
<<"">>
|
|
||||||
end,
|
end,
|
||||||
{gen_fsm:sync_send_all_state_event(
|
{gen_fsm:sync_send_all_state_event(
|
||||||
FsmRef, #http_put{rid = Rid, attrs = Attrs, payload = Payload,
|
FsmRef, #http_put{rid = Rid,
|
||||||
payload_size = PayloadSize, hold = Hold,
|
attrs = Attrs,
|
||||||
stream = NewStream, ip = IP}, 30000), Sess}
|
payload = Payload,
|
||||||
|
payload_size = PayloadSize,
|
||||||
|
hold = Hold,
|
||||||
|
stream = NewStream,
|
||||||
|
ip = IP},
|
||||||
|
30000), Sess}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
handle_http_put_error(Reason,
|
handle_http_put_error(Reason,
|
||||||
@ -1189,7 +1163,6 @@ set_inactivity_timer(Pause, _MaxInactivity)
|
|||||||
set_inactivity_timer(_Pause, MaxInactivity) ->
|
set_inactivity_timer(_Pause, MaxInactivity) ->
|
||||||
erlang:start_timer(MaxInactivity, self(), []).
|
erlang:start_timer(MaxInactivity, self(), []).
|
||||||
|
|
||||||
%% TODO: Use tail recursion and list reverse ?
|
|
||||||
elements_to_string([]) -> [];
|
elements_to_string([]) -> [];
|
||||||
elements_to_string([El | Els]) ->
|
elements_to_string([El | Els]) ->
|
||||||
[xml:element_to_binary(El) | elements_to_string(Els)].
|
[xml:element_to_binary(El) | elements_to_string(Els)].
|
||||||
|
@ -175,13 +175,6 @@ bounce_resource_packet(From, To, Packet) ->
|
|||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: init(Args) -> {ok, State} |
|
|
||||||
%% {ok, State, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, Reason}
|
|
||||||
%% Description: Initiates the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
init([]) ->
|
init([]) ->
|
||||||
lists:foreach(fun (Host) ->
|
lists:foreach(fun (Host) ->
|
||||||
ejabberd_router:register_route(Host,
|
ejabberd_router:register_route(Host,
|
||||||
@ -200,28 +193,7 @@ init([]) ->
|
|||||||
mnesia:add_table_copy(iq_response, node(), ram_copies),
|
mnesia:add_table_copy(iq_response, node(), ram_copies),
|
||||||
{ok, #state{}}.
|
{ok, #state{}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
|
|
||||||
%% {reply, Reply, State, Timeout} |
|
|
||||||
%% {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, Reply, State} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling call messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_call(_Request, _From, State) ->
|
handle_call(_Request, _From, State) ->
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_cast(Msg, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_info(Info, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling all non call/cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
Reply = ok, {reply, Reply, State}.
|
Reply = ok, {reply, Reply, State}.
|
||||||
|
|
||||||
handle_cast(_Msg, State) -> {noreply, State}.
|
handle_cast(_Msg, State) -> {noreply, State}.
|
||||||
@ -272,26 +244,18 @@ handle_info(refresh_iq_handlers, State) ->
|
|||||||
handle_info({timeout, _TRef, ID}, State) ->
|
handle_info({timeout, _TRef, ID}, State) ->
|
||||||
process_iq_timeout(ID),
|
process_iq_timeout(ID),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
%%--------------------------------------------------------------------
|
handle_info(_Info, State) ->
|
||||||
%% Function: terminate(Reason, State) -> void()
|
{noreply, State}.
|
||||||
%% Description: This function is called by a gen_server when it is about to
|
|
||||||
%% terminate. It should be the opposite of Module:init/1 and do any necessary
|
terminate(_Reason, _State) ->
|
||||||
%% cleaning up. When it returns, the gen_server terminates with Reason.
|
ok.
|
||||||
%% The return value is ignored.
|
|
||||||
%%--------------------------------------------------------------------
|
code_change(_OldVsn, State, _Extra) ->
|
||||||
%%--------------------------------------------------------------------
|
{ok, State}.
|
||||||
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
|
|
||||||
%% Description: Convert process state when code is changed
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
handle_info(_Info, State) -> {noreply, State}.
|
|
||||||
|
|
||||||
terminate(_Reason, _State) -> ok.
|
|
||||||
|
|
||||||
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
|
||||||
|
|
||||||
do_route(From, To, Packet) ->
|
do_route(From, To, Packet) ->
|
||||||
?DEBUG("local route~n\tfrom ~p~n\tto ~p~n\tpacket "
|
?DEBUG("local route~n\tfrom ~p~n\tto ~p~n\tpacket "
|
||||||
"~P~n",
|
"~P~n",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%% @copyright (C) 2013, Evgeniy Khramtsov
|
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%%
|
%%%
|
||||||
%%% @end
|
%%% @end
|
||||||
|
@ -477,10 +477,6 @@ sql_query_internal(Query) ->
|
|||||||
pgsql ->
|
pgsql ->
|
||||||
pgsql_to_odbc(pgsql:squery(State#state.db_ref, Query));
|
pgsql_to_odbc(pgsql:squery(State#state.db_ref, Query));
|
||||||
mysql ->
|
mysql ->
|
||||||
?DEBUG("MySQL, Send query~n~p~n", [Query]),
|
|
||||||
%%squery to be able to specify result_type = binary
|
|
||||||
%%[Query] because p1_mysql_conn expect query to be a list (elements can be binaries, or iolist)
|
|
||||||
%% but doesn't accept just a binary
|
|
||||||
R = mysql_to_odbc(p1_mysql_conn:squery(State#state.db_ref,
|
R = mysql_to_odbc(p1_mysql_conn:squery(State#state.db_ref,
|
||||||
[Query], self(),
|
[Query], self(),
|
||||||
[{timeout, (?TRANSACTION_TIMEOUT) - 1000},
|
[{timeout, (?TRANSACTION_TIMEOUT) - 1000},
|
||||||
@ -614,12 +610,13 @@ pgsql_item_to_odbc(_) -> {updated, undefined}.
|
|||||||
%% Open a database connection to MySQL
|
%% Open a database connection to MySQL
|
||||||
mysql_connect(Server, Port, DB, Username, Password) ->
|
mysql_connect(Server, Port, DB, Username, Password) ->
|
||||||
case p1_mysql_conn:start(binary_to_list(Server), Port,
|
case p1_mysql_conn:start(binary_to_list(Server), Port,
|
||||||
binary_to_list(Username), binary_to_list(Password),
|
binary_to_list(Username),
|
||||||
|
binary_to_list(Password),
|
||||||
binary_to_list(DB), fun log/3)
|
binary_to_list(DB), fun log/3)
|
||||||
of
|
of
|
||||||
{ok, Ref} ->
|
{ok, Ref} ->
|
||||||
p1_mysql_conn:fetch(Ref, [<<"set names 'utf8';">>],
|
p1_mysql_conn:fetch(
|
||||||
self()),
|
Ref, [<<"set names 'utf8';">>], self()),
|
||||||
{ok, Ref};
|
{ok, Ref};
|
||||||
Err -> Err
|
Err -> Err
|
||||||
end.
|
end.
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
%%% Created : 17 Jul 2008 by Pablo Polvorin <pablo.polvorin@process-one.net>
|
%%% Created : 17 Jul 2008 by Pablo Polvorin <pablo.polvorin@process-one.net>
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%% @copyright (C) 2012, Evgeniy Khramtsov
|
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%%
|
%%%
|
||||||
%%%
|
%%%
|
||||||
@ -714,31 +713,9 @@ make_xinclude(Fn) ->
|
|||||||
Base = filename:basename(Fn),
|
Base = filename:basename(Fn),
|
||||||
io_lib:format("<xi:include href='~s'/>", [Base]).
|
io_lib:format("<xi:include href='~s'/>", [Base]).
|
||||||
|
|
||||||
%%%==================================
|
|
||||||
%%%% Export user
|
|
||||||
%% @spec (Fd, Username::string(), Host::string()) -> ok
|
|
||||||
%% @doc Extract user information and print it.
|
|
||||||
%% @spec (Username::string(), Host::string()) -> string()
|
|
||||||
%% @spec (InfoName::atom(), Username::string(), Host::string()) -> string()
|
|
||||||
%%%==================================
|
|
||||||
%%%% Interface with ejabberd offline storage
|
|
||||||
%% Copied from mod_offline.erl and customized
|
|
||||||
%%%==================================
|
|
||||||
%%%% Interface with ejabberd private storage
|
|
||||||
%%%==================================
|
|
||||||
%%%% Disk file access
|
|
||||||
%% @spec () -> string()
|
|
||||||
%% @spec (Dir::string(), FnT::string()) -> string()
|
|
||||||
%% @spec (FnT::string(), Host::string()) -> FnH::string()
|
|
||||||
%% @doc Make the filename for the host.
|
|
||||||
%% Example: ``("20080804-231550", "jabber.example.org") -> "20080804-231550_jabber_example_org.xml"''
|
|
||||||
%% @spec (Fn::string()) -> {ok, Fd}
|
|
||||||
%% @spec (Fd) -> ok
|
|
||||||
%% @spec (Fd, String::string()) -> ok
|
|
||||||
print(Fd, String) ->
|
print(Fd, String) ->
|
||||||
%%%==================================
|
|
||||||
%%% vim: set filetype=erlang tabstop=8 foldmarker=%%%%,%%%= foldmethod=marker:
|
|
||||||
file:write(Fd, String).
|
file:write(Fd, String).
|
||||||
|
|
||||||
opt_type(auth_password_format) -> fun (X) -> X end;
|
opt_type(auth_password_format) -> fun (X) -> X end;
|
||||||
opt_type(_) -> [auth_password_format].
|
opt_type(_) -> [auth_password_format].
|
||||||
|
|
||||||
|
@ -58,13 +58,6 @@
|
|||||||
|
|
||||||
-define(HIBERNATE_TIMEOUT, 90000).
|
-define(HIBERNATE_TIMEOUT, 90000).
|
||||||
|
|
||||||
%%====================================================================
|
|
||||||
%% API
|
|
||||||
%%====================================================================
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
|
|
||||||
%% Description: Starts the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
-spec start_link(inet:socket(), atom(), shaper:shaper(),
|
-spec start_link(inet:socket(), atom(), shaper:shaper(),
|
||||||
non_neg_integer() | infinity) -> ignore |
|
non_neg_integer() | infinity) -> ignore |
|
||||||
{error, any()} |
|
{error, any()} |
|
||||||
@ -76,10 +69,6 @@ start_link(Socket, SockMod, Shaper, MaxStanzaSize) ->
|
|||||||
|
|
||||||
-spec start(inet:socket(), atom(), shaper:shaper()) -> undefined | pid().
|
-spec start(inet:socket(), atom(), shaper:shaper()) -> undefined | pid().
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: start() -> {ok,Pid} | ignore | {error,Error}
|
|
||||||
%% Description: Starts the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
start(Socket, SockMod, Shaper) ->
|
start(Socket, SockMod, Shaper) ->
|
||||||
start(Socket, SockMod, Shaper, infinity).
|
start(Socket, SockMod, Shaper, infinity).
|
||||||
|
|
||||||
@ -127,13 +116,6 @@ close(Pid) ->
|
|||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: init(Args) -> {ok, State} |
|
|
||||||
%% {ok, State, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, Reason}
|
|
||||||
%% Description: Initiates the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
init([Socket, SockMod, Shaper, MaxStanzaSize]) ->
|
init([Socket, SockMod, Shaper, MaxStanzaSize]) ->
|
||||||
ShaperState = shaper:new(Shaper),
|
ShaperState = shaper:new(Shaper),
|
||||||
Timeout = case SockMod of
|
Timeout = case SockMod of
|
||||||
@ -145,15 +127,6 @@ init([Socket, SockMod, Shaper, MaxStanzaSize]) ->
|
|||||||
shaper_state = ShaperState,
|
shaper_state = ShaperState,
|
||||||
max_stanza_size = MaxStanzaSize, timeout = Timeout}}.
|
max_stanza_size = MaxStanzaSize, timeout = Timeout}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
|
|
||||||
%% {reply, Reply, State, Timeout} |
|
|
||||||
%% {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, Reply, State} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling call messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_call({starttls, TLSSocket}, _From,
|
handle_call({starttls, TLSSocket}, _From,
|
||||||
#state{xml_stream_state = XMLStreamState,
|
#state{xml_stream_state = XMLStreamState,
|
||||||
c2s_pid = C2SPid,
|
c2s_pid = C2SPid,
|
||||||
@ -163,15 +136,15 @@ handle_call({starttls, TLSSocket}, _From,
|
|||||||
undefined ->
|
undefined ->
|
||||||
XMLStreamState;
|
XMLStreamState;
|
||||||
_ ->
|
_ ->
|
||||||
xml_stream:new(C2SPid,
|
xml_stream:new(C2SPid, MaxStanzaSize)
|
||||||
MaxStanzaSize)
|
|
||||||
end,
|
end,
|
||||||
NewState = State#state{socket = TLSSocket,
|
NewState = State#state{socket = TLSSocket,
|
||||||
sock_mod = p1_tls,
|
sock_mod = p1_tls,
|
||||||
xml_stream_state = NewXMLStreamState},
|
xml_stream_state = NewXMLStreamState},
|
||||||
case p1_tls:recv_data(TLSSocket, <<"">>) of
|
case p1_tls:recv_data(TLSSocket, <<"">>) of
|
||||||
{ok, TLSData} ->
|
{ok, TLSData} ->
|
||||||
{reply, ok, process_data(TLSData, NewState), ?HIBERNATE_TIMEOUT};
|
{reply, ok,
|
||||||
|
process_data(TLSData, NewState), ?HIBERNATE_TIMEOUT};
|
||||||
{error, _Reason} ->
|
{error, _Reason} ->
|
||||||
{stop, normal, ok, NewState}
|
{stop, normal, ok, NewState}
|
||||||
end;
|
end;
|
||||||
@ -186,8 +159,7 @@ handle_call({compress, Data}, _From,
|
|||||||
true -> ok
|
true -> ok
|
||||||
end,
|
end,
|
||||||
close_stream(XMLStreamState),
|
close_stream(XMLStreamState),
|
||||||
NewXMLStreamState = xml_stream:new(C2SPid,
|
NewXMLStreamState = xml_stream:new(C2SPid, MaxStanzaSize),
|
||||||
MaxStanzaSize),
|
|
||||||
NewState = State#state{socket = ZlibSocket,
|
NewState = State#state{socket = ZlibSocket,
|
||||||
sock_mod = ezlib,
|
sock_mod = ezlib,
|
||||||
xml_stream_state = NewXMLStreamState},
|
xml_stream_state = NewXMLStreamState},
|
||||||
@ -195,15 +167,15 @@ handle_call({compress, Data}, _From,
|
|||||||
{ok, ZlibData} ->
|
{ok, ZlibData} ->
|
||||||
{reply, {ok, ZlibSocket},
|
{reply, {ok, ZlibSocket},
|
||||||
process_data(ZlibData, NewState), ?HIBERNATE_TIMEOUT};
|
process_data(ZlibData, NewState), ?HIBERNATE_TIMEOUT};
|
||||||
{error, _Reason} -> {stop, normal, ok, NewState}
|
{error, _Reason} ->
|
||||||
|
{stop, normal, ok, NewState}
|
||||||
end;
|
end;
|
||||||
handle_call(reset_stream, _From,
|
handle_call(reset_stream, _From,
|
||||||
#state{xml_stream_state = XMLStreamState,
|
#state{xml_stream_state = XMLStreamState,
|
||||||
c2s_pid = C2SPid, max_stanza_size = MaxStanzaSize} =
|
c2s_pid = C2SPid, max_stanza_size = MaxStanzaSize} =
|
||||||
State) ->
|
State) ->
|
||||||
close_stream(XMLStreamState),
|
close_stream(XMLStreamState),
|
||||||
NewXMLStreamState = xml_stream:new(C2SPid,
|
NewXMLStreamState = xml_stream:new(C2SPid, MaxStanzaSize),
|
||||||
MaxStanzaSize),
|
|
||||||
Reply = ok,
|
Reply = ok,
|
||||||
{reply, Reply,
|
{reply, Reply,
|
||||||
State#state{xml_stream_state = NewXMLStreamState},
|
State#state{xml_stream_state = NewXMLStreamState},
|
||||||
@ -218,12 +190,6 @@ handle_call({become_controller, C2SPid}, _From, State) ->
|
|||||||
handle_call(_Request, _From, State) ->
|
handle_call(_Request, _From, State) ->
|
||||||
Reply = ok, {reply, Reply, State, ?HIBERNATE_TIMEOUT}.
|
Reply = ok, {reply, Reply, State, ?HIBERNATE_TIMEOUT}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_cast(Msg, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_cast({change_shaper, Shaper}, State) ->
|
handle_cast({change_shaper, Shaper}, State) ->
|
||||||
NewShaperState = shaper:new(Shaper),
|
NewShaperState = shaper:new(Shaper),
|
||||||
{noreply, State#state{shaper_state = NewShaperState},
|
{noreply, State#state{shaper_state = NewShaperState},
|
||||||
@ -232,12 +198,6 @@ handle_cast(close, State) -> {stop, normal, State};
|
|||||||
handle_cast(_Msg, State) ->
|
handle_cast(_Msg, State) ->
|
||||||
{noreply, State, ?HIBERNATE_TIMEOUT}.
|
{noreply, State, ?HIBERNATE_TIMEOUT}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_info(Info, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling all non call/cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_info({Tag, _TCPSocket, Data},
|
handle_info({Tag, _TCPSocket, Data},
|
||||||
#state{socket = Socket, sock_mod = SockMod} = State)
|
#state{socket = Socket, sock_mod = SockMod} = State)
|
||||||
when (Tag == tcp) or (Tag == ssl) or
|
when (Tag == tcp) or (Tag == ssl) or
|
||||||
@ -285,13 +245,6 @@ handle_info(timeout, State) ->
|
|||||||
handle_info(_Info, State) ->
|
handle_info(_Info, State) ->
|
||||||
{noreply, State, ?HIBERNATE_TIMEOUT}.
|
{noreply, State, ?HIBERNATE_TIMEOUT}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: terminate(Reason, State) -> void()
|
|
||||||
%% Description: This function is called by a gen_server when it is about to
|
|
||||||
%% terminate. It should be the opposite of Module:init/1 and do any necessary
|
|
||||||
%% cleaning up. When it returns, the gen_server terminates with Reason.
|
|
||||||
%% The return value is ignored.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
terminate(_Reason,
|
terminate(_Reason,
|
||||||
#state{xml_stream_state = XMLStreamState,
|
#state{xml_stream_state = XMLStreamState,
|
||||||
c2s_pid = C2SPid} =
|
c2s_pid = C2SPid} =
|
||||||
@ -304,10 +257,6 @@ terminate(_Reason,
|
|||||||
catch (State#state.sock_mod):close(State#state.socket),
|
catch (State#state.sock_mod):close(State#state.socket),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
|
|
||||||
%% Description: Convert process state when code is changed
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
%%% Created : 29 Dec 2011 by Alexey Shchepin <alexey@process-one.net>
|
%%% Created : 29 Dec 2011 by Alexey Shchepin <alexey@process-one.net>
|
||||||
%%% @copyright (C) 2002-2015 ProcessOne
|
%%% @copyright (C) 2002-2015 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
|
%%% ejabberd, Copyright (C) 2002-2015 ProcessOne
|
||||||
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
%%% published by the Free Software Foundation; either version 2 of the
|
%%% published by the Free Software Foundation; either version 2 of the
|
||||||
|
@ -226,7 +226,8 @@ dirty_get_all_domains() ->
|
|||||||
init([]) ->
|
init([]) ->
|
||||||
update_tables(),
|
update_tables(),
|
||||||
mnesia:create_table(route,
|
mnesia:create_table(route,
|
||||||
[{ram_copies, [node()]}, {type, bag},
|
[{ram_copies, [node()]},
|
||||||
|
{type, bag},
|
||||||
{attributes, record_info(fields, route)}]),
|
{attributes, record_info(fields, route)}]),
|
||||||
mnesia:add_table_copy(route, node(), ram_copies),
|
mnesia:add_table_copy(route, node(), ram_copies),
|
||||||
mnesia:subscribe({table, route, simple}),
|
mnesia:subscribe({table, route, simple}),
|
||||||
|
@ -3,6 +3,24 @@
|
|||||||
%%% Author : Badlop <badlop@process-one.net>
|
%%% Author : Badlop <badlop@process-one.net>
|
||||||
%%% Purpose : Multicast router
|
%%% Purpose : Multicast router
|
||||||
%%% Created : 11 Aug 2007 by Badlop <badlop@process-one.net>
|
%%% Created : 11 Aug 2007 by Badlop <badlop@process-one.net>
|
||||||
|
%%%
|
||||||
|
%%%
|
||||||
|
%%% ejabberd, Copyright (C) 2002-2015 ProcessOne
|
||||||
|
%%%
|
||||||
|
%%% This program is free software; you can redistribute it and/or
|
||||||
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
%%% published by the Free Software Foundation; either version 2 of the
|
||||||
|
%%% License, or (at your option) any later version.
|
||||||
|
%%%
|
||||||
|
%%% This program is distributed in the hope that it will be useful,
|
||||||
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
%%% General Public License for more details.
|
||||||
|
%%%
|
||||||
|
%%% You should have received a copy of the GNU General Public License along
|
||||||
|
%%% with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(ejabberd_router_multicast).
|
-module(ejabberd_router_multicast).
|
||||||
|
@ -85,13 +85,6 @@
|
|||||||
|
|
||||||
-type temporarily_blocked() :: #temporarily_blocked{}.
|
-type temporarily_blocked() :: #temporarily_blocked{}.
|
||||||
|
|
||||||
%%====================================================================
|
|
||||||
%% API
|
|
||||||
%%====================================================================
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
|
|
||||||
%% Description: Starts the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [],
|
gen_server:start_link({local, ?MODULE}, ?MODULE, [],
|
||||||
[]).
|
[]).
|
||||||
@ -251,51 +244,26 @@ check_peer_certificate(SockMod, Sock, Peer) ->
|
|||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: init(Args) -> {ok, State} |
|
|
||||||
%% {ok, State, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, Reason}
|
|
||||||
%% Description: Initiates the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
init([]) ->
|
init([]) ->
|
||||||
update_tables(),
|
update_tables(),
|
||||||
mnesia:create_table(s2s, [{ram_copies, [node()]}, {type, bag},
|
mnesia:create_table(s2s,
|
||||||
|
[{ram_copies, [node()]},
|
||||||
|
{type, bag},
|
||||||
{attributes, record_info(fields, s2s)}]),
|
{attributes, record_info(fields, s2s)}]),
|
||||||
mnesia:add_table_copy(s2s, node(), ram_copies),
|
mnesia:add_table_copy(s2s, node(), ram_copies),
|
||||||
mnesia:subscribe(system),
|
mnesia:subscribe(system),
|
||||||
ejabberd_commands:register_commands(commands()),
|
ejabberd_commands:register_commands(commands()),
|
||||||
mnesia:create_table(temporarily_blocked, [{ram_copies, [node()]}, {attributes, record_info(fields, temporarily_blocked)}]),
|
mnesia:create_table(temporarily_blocked,
|
||||||
|
[{ram_copies, [node()]},
|
||||||
|
{attributes, record_info(fields, temporarily_blocked)}]),
|
||||||
{ok, #state{}}.
|
{ok, #state{}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
|
|
||||||
%% {reply, Reply, State, Timeout} |
|
|
||||||
%% {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, Reply, State} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling call messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_call(_Request, _From, State) ->
|
handle_call(_Request, _From, State) ->
|
||||||
Reply = ok,
|
{reply, ok, State}.
|
||||||
{reply, Reply, State}.
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_cast(Msg, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_cast(_Msg, State) ->
|
handle_cast(_Msg, State) ->
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_info(Info, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling all non call/cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
|
handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
|
||||||
clean_table_from_bad_node(Node),
|
clean_table_from_bad_node(Node),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
@ -309,27 +277,17 @@ handle_info({route, From, To, Packet}, State) ->
|
|||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_info(_Info, State) -> {noreply, State}.
|
handle_info(_Info, State) -> {noreply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: terminate(Reason, State) -> void()
|
|
||||||
%% Description: This function is called by a gen_server when it is about to
|
|
||||||
%% terminate. It should be the opposite of Module:init/1 and do any necessary
|
|
||||||
%% cleaning up. When it returns, the gen_server terminates with Reason.
|
|
||||||
%% The return value is ignored.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
terminate(_Reason, _State) ->
|
terminate(_Reason, _State) ->
|
||||||
ejabberd_commands:unregister_commands(commands()),
|
ejabberd_commands:unregister_commands(commands()),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
|
|
||||||
%% Description: Convert process state when code is changed
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
code_change(_OldVsn, State, _Extra) ->
|
code_change(_OldVsn, State, _Extra) ->
|
||||||
{ok, State}.
|
{ok, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
clean_table_from_bad_node(Node) ->
|
clean_table_from_bad_node(Node) ->
|
||||||
F = fun() ->
|
F = fun() ->
|
||||||
Es = mnesia:select(
|
Es = mnesia:select(
|
||||||
@ -520,7 +478,8 @@ parent_domains(Domain) ->
|
|||||||
end,
|
end,
|
||||||
[], lists:reverse(str:tokens(Domain, <<".">>))).
|
[], lists:reverse(str:tokens(Domain, <<".">>))).
|
||||||
|
|
||||||
send_element(Pid, El) -> Pid ! {send_element, El}.
|
send_element(Pid, El) ->
|
||||||
|
Pid ! {send_element, El}.
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% ejabberd commands
|
%%% ejabberd commands
|
||||||
@ -566,10 +525,8 @@ update_tables() ->
|
|||||||
{'EXIT', _} -> ok
|
{'EXIT', _} -> ok
|
||||||
end,
|
end,
|
||||||
case lists:member(local_s2s, mnesia:system_info(tables)) of
|
case lists:member(local_s2s, mnesia:system_info(tables)) of
|
||||||
true ->
|
true -> mnesia:delete_table(local_s2s);
|
||||||
mnesia:delete_table(local_s2s);
|
false -> ok
|
||||||
false ->
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% Check if host is in blacklist or white list
|
%% Check if host is in blacklist or white list
|
||||||
|
@ -111,9 +111,6 @@
|
|||||||
-define(INVALID_XML_ERR,
|
-define(INVALID_XML_ERR,
|
||||||
xml:element_to_binary(?SERR_XML_NOT_WELL_FORMED)).
|
xml:element_to_binary(?SERR_XML_NOT_WELL_FORMED)).
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
|
||||||
%%% API
|
|
||||||
%%%----------------------------------------------------------------------
|
|
||||||
start(SockData, Opts) -> ?SUPERVISOR_START.
|
start(SockData, Opts) -> ?SUPERVISOR_START.
|
||||||
|
|
||||||
start_link(SockData, Opts) ->
|
start_link(SockData, Opts) ->
|
||||||
@ -126,13 +123,6 @@ socket_type() -> xml_stream.
|
|||||||
%%% Callback functions from gen_fsm
|
%%% Callback functions from gen_fsm
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: init/1
|
|
||||||
%% Returns: {ok, StateName, StateData} |
|
|
||||||
%% {ok, StateName, StateData, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, StopReason}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
init([{SockMod, Socket}, Opts]) ->
|
init([{SockMod, Socket}, Opts]) ->
|
||||||
?DEBUG("started: ~p", [{SockMod, Socket}]),
|
?DEBUG("started: ~p", [{SockMod, Socket}]),
|
||||||
Shaper = case lists:keysearch(shaper, 1, Opts) of
|
Shaper = case lists:keysearch(shaper, 1, Opts) of
|
||||||
@ -567,20 +557,8 @@ stream_established(closed, StateData) ->
|
|||||||
% Reply = ok,
|
% Reply = ok,
|
||||||
% {reply, Reply, state_name, StateData}.
|
% {reply, Reply, state_name, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_event/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_event(_Event, StateName, StateData) ->
|
handle_event(_Event, StateName, StateData) ->
|
||||||
{next_state, StateName, StateData}.
|
{next_state, StateName, StateData}.
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_sync_event/4
|
|
||||||
%% Returns: The associated StateData for this connection
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData}
|
|
||||||
%% Reply = {state_infos, [{InfoName::atom(), InfoValue::any()]
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
|
|
||||||
handle_sync_event(get_state_infos, _From, StateName,
|
handle_sync_event(get_state_infos, _From, StateName,
|
||||||
StateData) ->
|
StateData) ->
|
||||||
@ -621,12 +599,6 @@ handle_sync_event(_Event, _From, StateName,
|
|||||||
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
||||||
{ok, StateName, StateData}.
|
{ok, StateName, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_info/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_info({send_text, Text}, StateName, StateData) ->
|
handle_info({send_text, Text}, StateName, StateData) ->
|
||||||
send_text(StateData, Text),
|
send_text(StateData, Text),
|
||||||
{next_state, StateName, StateData};
|
{next_state, StateName, StateData};
|
||||||
@ -636,11 +608,6 @@ handle_info({timeout, Timer, _}, _StateName,
|
|||||||
handle_info(_, StateName, StateData) ->
|
handle_info(_, StateName, StateData) ->
|
||||||
{next_state, StateName, StateData}.
|
{next_state, StateName, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: terminate/3
|
|
||||||
%% Purpose: Shutdown the fsm
|
|
||||||
%% Returns: any
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
terminate(Reason, _StateName, StateData) ->
|
terminate(Reason, _StateName, StateData) ->
|
||||||
?DEBUG("terminated: ~p", [Reason]),
|
?DEBUG("terminated: ~p", [Reason]),
|
||||||
case Reason of
|
case Reason of
|
||||||
@ -661,11 +628,6 @@ get_external_hosts(StateData) ->
|
|||||||
|| {{D, _}, established} <- dict:to_list(Connections)]
|
|| {{D, _}, established} <- dict:to_list(Connections)]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: print_state/1
|
|
||||||
%% Purpose: Prepare the state to be printed on error log
|
|
||||||
%% Returns: State to print
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
print_state(State) -> State.
|
print_state(State) -> State.
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
@ -141,13 +141,6 @@ stop_connection(Pid) -> p1_fsm:send_event(Pid, closed).
|
|||||||
%%% Callback functions from p1_fsm
|
%%% Callback functions from p1_fsm
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: init/1
|
|
||||||
%% Returns: {ok, StateName, StateData} |
|
|
||||||
%% {ok, StateName, StateData, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, StopReason}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
init([From, Server, Type]) ->
|
init([From, Server, Type]) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
?DEBUG("started: ~p", [{From, Server, Type}]),
|
?DEBUG("started: ~p", [{From, Server, Type}]),
|
||||||
@ -222,12 +215,6 @@ init([From, Server, Type]) ->
|
|||||||
tls_options = TLSOpts, queue = queue:new(), myname = From,
|
tls_options = TLSOpts, queue = queue:new(), myname = From,
|
||||||
server = Server, new = New, verify = Verify, timer = Timer}}.
|
server = Server, new = New, verify = Verify, timer = Timer}}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: StateName/2
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
open_socket(init, StateData) ->
|
open_socket(init, StateData) ->
|
||||||
log_s2s_out(StateData#state.new, StateData#state.myname,
|
log_s2s_out(StateData#state.new, StateData#state.myname,
|
||||||
StateData#state.server, StateData#state.tls),
|
StateData#state.server, StateData#state.tls),
|
||||||
@ -292,8 +279,6 @@ open_socket(timeout, StateData) ->
|
|||||||
open_socket(_, StateData) ->
|
open_socket(_, StateData) ->
|
||||||
{next_state, open_socket, StateData}.
|
{next_state, open_socket, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% IPv4
|
|
||||||
open_socket1({_, _, _, _} = Addr, Port) ->
|
open_socket1({_, _, _, _} = Addr, Port) ->
|
||||||
open_socket2(inet, Addr, Port);
|
open_socket2(inet, Addr, Port);
|
||||||
%% IPv6
|
%% IPv6
|
||||||
@ -872,19 +857,7 @@ stream_established(closed, StateData) ->
|
|||||||
%% Reply = ok,
|
%% Reply = ok,
|
||||||
%% {reply, Reply, state_name, StateData}.
|
%% {reply, Reply, state_name, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_event/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_event(_Event, StateName, StateData) ->
|
handle_event(_Event, StateName, StateData) ->
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_sync_event/4
|
|
||||||
%% Returns: The associated StateData for this connection
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData}
|
|
||||||
%% Reply = {state_infos, [{InfoName::atom(), InfoValue::any()]
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
{next_state, StateName, StateData,
|
{next_state, StateName, StateData,
|
||||||
get_timeout_interval(StateName)}.
|
get_timeout_interval(StateName)}.
|
||||||
|
|
||||||
@ -933,12 +906,6 @@ handle_sync_event(_Event, _From, StateName,
|
|||||||
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
||||||
{ok, StateName, StateData}.
|
{ok, StateName, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_info/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_info({send_text, Text}, StateName, StateData) ->
|
handle_info({send_text, Text}, StateName, StateData) ->
|
||||||
send_text(StateData, Text),
|
send_text(StateData, Text),
|
||||||
cancel_timer(StateData#state.timer),
|
cancel_timer(StateData#state.timer),
|
||||||
@ -995,11 +962,6 @@ handle_info(_, StateName, StateData) ->
|
|||||||
{next_state, StateName, StateData,
|
{next_state, StateName, StateData,
|
||||||
get_timeout_interval(StateName)}.
|
get_timeout_interval(StateName)}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: terminate/3
|
|
||||||
%% Purpose: Shutdown the fsm
|
|
||||||
%% Returns: any
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
terminate(Reason, StateName, StateData) ->
|
terminate(Reason, StateName, StateData) ->
|
||||||
?DEBUG("terminated: ~p", [{Reason, StateName}]),
|
?DEBUG("terminated: ~p", [{Reason, StateName}]),
|
||||||
case StateData#state.new of
|
case StateData#state.new of
|
||||||
@ -1018,11 +980,6 @@ terminate(Reason, StateName, StateData) ->
|
|||||||
end,
|
end,
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: print_state/1
|
|
||||||
%% Purpose: Prepare the state to be printed on error log
|
|
||||||
%% Returns: State to print
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
print_state(State) -> State.
|
print_state(State) -> State.
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
@ -1328,10 +1285,6 @@ wait_before_reconnect(StateData) ->
|
|||||||
D1 -> lists:min([D1 * 2, get_max_retry_delay()])
|
D1 -> lists:min([D1 * 2, get_max_retry_delay()])
|
||||||
end,
|
end,
|
||||||
Timer = erlang:start_timer(Delay, self(), []),
|
Timer = erlang:start_timer(Delay, self(), []),
|
||||||
%% @doc Get the maximum allowed delay for retry to reconnect (in miliseconds).
|
|
||||||
%% The default value is 5 minutes.
|
|
||||||
%% The option {s2s_max_retry_delay, Seconds} can be used (in seconds).
|
|
||||||
%% @spec () -> integer()
|
|
||||||
{next_state, wait_before_retry,
|
{next_state, wait_before_retry,
|
||||||
StateData#state{timer = Timer, delay_to_retry = Delay,
|
StateData#state{timer = Timer, delay_to_retry = Delay,
|
||||||
queue = queue:new()}}.
|
queue = queue:new()}}.
|
||||||
|
@ -95,10 +95,6 @@
|
|||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
|
|
||||||
%% Description: Starts the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
-export_type([sid/0]).
|
-export_type([sid/0]).
|
||||||
|
|
||||||
start() ->
|
start() ->
|
||||||
@ -107,8 +103,7 @@ start() ->
|
|||||||
supervisor:start_child(ejabberd_sup, ChildSpec).
|
supervisor:start_child(ejabberd_sup, ChildSpec).
|
||||||
|
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [],
|
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||||
[]).
|
|
||||||
|
|
||||||
-spec route(jid(), jid(), xmlel() | broadcast()) -> ok.
|
-spec route(jid(), jid(), xmlel() | broadcast()) -> ok.
|
||||||
|
|
||||||
@ -149,6 +144,9 @@ close_session(SID, User, Server, Resource) ->
|
|||||||
ejabberd_hooks:run(sm_remove_connection_hook,
|
ejabberd_hooks:run(sm_remove_connection_hook,
|
||||||
JID#jid.lserver, [SID, JID, Info]).
|
JID#jid.lserver, [SID, JID, Info]).
|
||||||
|
|
||||||
|
-spec check_in_subscription(any(), binary(), binary(),
|
||||||
|
any(), any(), any()) -> any().
|
||||||
|
|
||||||
check_in_subscription(Acc, User, Server, _JID, _Type, _Reason) ->
|
check_in_subscription(Acc, User, Server, _JID, _Type, _Reason) ->
|
||||||
case ejabberd_auth:is_user_exists(User, Server) of
|
case ejabberd_auth:is_user_exists(User, Server) of
|
||||||
true -> Acc;
|
true -> Acc;
|
||||||
@ -268,6 +266,8 @@ dirty_get_sessions_list() ->
|
|||||||
Mod = get_sm_backend(),
|
Mod = get_sm_backend(),
|
||||||
[S#session.usr || S <- Mod:get_sessions()].
|
[S#session.usr || S <- Mod:get_sessions()].
|
||||||
|
|
||||||
|
-spec dirty_get_my_sessions_list() -> [#session{}].
|
||||||
|
|
||||||
dirty_get_my_sessions_list() ->
|
dirty_get_my_sessions_list() ->
|
||||||
Mod = get_sm_backend(),
|
Mod = get_sm_backend(),
|
||||||
[S || S <- Mod:get_sessions(), node(element(2, S#session.sid)) == node()].
|
[S || S <- Mod:get_sessions(), node(element(2, S#session.sid)) == node()].
|
||||||
@ -285,20 +285,20 @@ get_all_pids() ->
|
|||||||
Mod = get_sm_backend(),
|
Mod = get_sm_backend(),
|
||||||
[element(2, S#session.sid) || S <- Mod:get_sessions()].
|
[element(2, S#session.sid) || S <- Mod:get_sessions()].
|
||||||
|
|
||||||
|
-spec get_vh_session_number(binary()) -> non_neg_integer().
|
||||||
|
|
||||||
get_vh_session_number(Server) ->
|
get_vh_session_number(Server) ->
|
||||||
LServer = jlib:nameprep(Server),
|
LServer = jlib:nameprep(Server),
|
||||||
Mod = get_sm_backend(),
|
Mod = get_sm_backend(),
|
||||||
length(Mod:get_sessions(LServer)).
|
length(Mod:get_sessions(LServer)).
|
||||||
|
|
||||||
register_iq_handler(Host, XMLNS, Module, Fun) ->
|
register_iq_handler(Host, XMLNS, Module, Fun) ->
|
||||||
ejabberd_sm !
|
ejabberd_sm ! {register_iq_handler, Host, XMLNS, Module, Fun}.
|
||||||
{register_iq_handler, Host, XMLNS, Module, Fun}.
|
|
||||||
|
|
||||||
-spec register_iq_handler(binary(), binary(), atom(), atom(), list()) -> any().
|
-spec register_iq_handler(binary(), binary(), atom(), atom(), list()) -> any().
|
||||||
|
|
||||||
register_iq_handler(Host, XMLNS, Module, Fun, Opts) ->
|
register_iq_handler(Host, XMLNS, Module, Fun, Opts) ->
|
||||||
ejabberd_sm !
|
ejabberd_sm ! {register_iq_handler, Host, XMLNS, Module, Fun, Opts}.
|
||||||
{register_iq_handler, Host, XMLNS, Module, Fun, Opts}.
|
|
||||||
|
|
||||||
-spec unregister_iq_handler(binary(), binary()) -> any().
|
-spec unregister_iq_handler(binary(), binary()) -> any().
|
||||||
|
|
||||||
@ -310,13 +310,6 @@ unregister_iq_handler(Host, XMLNS) ->
|
|||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: init(Args) -> {ok, State} |
|
|
||||||
%% {ok, State, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, Reason}
|
|
||||||
%% Description: Initiates the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
init([]) ->
|
init([]) ->
|
||||||
Mod = get_sm_backend(),
|
Mod = get_sm_backend(),
|
||||||
Mod:init(),
|
Mod:init(),
|
||||||
@ -333,32 +326,11 @@ init([]) ->
|
|||||||
ejabberd_commands:register_commands(commands()),
|
ejabberd_commands:register_commands(commands()),
|
||||||
{ok, #state{}}.
|
{ok, #state{}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
|
|
||||||
%% {reply, Reply, State, Timeout} |
|
|
||||||
%% {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, Reply, State} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling call messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_call(_Request, _From, State) ->
|
handle_call(_Request, _From, State) ->
|
||||||
Reply = ok, {reply, Reply, State}.
|
Reply = ok, {reply, Reply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_cast(Msg, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_cast(_Msg, State) -> {noreply, State}.
|
handle_cast(_Msg, State) -> {noreply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_info(Info, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling all non call/cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_info({route, From, To, Packet}, State) ->
|
handle_info({route, From, To, Packet}, State) ->
|
||||||
case catch do_route(From, To, Packet) of
|
case catch do_route(From, To, Packet) of
|
||||||
{'EXIT', Reason} ->
|
{'EXIT', Reason} ->
|
||||||
@ -388,27 +360,19 @@ handle_info({unregister_iq_handler, Host, XMLNS},
|
|||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_info(_Info, State) -> {noreply, State}.
|
handle_info(_Info, State) -> {noreply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: terminate(Reason, State) -> void()
|
|
||||||
%% Description: This function is called by a gen_server when it is about to
|
|
||||||
%% terminate. It should be the opposite of Module:init/1 and do any necessary
|
|
||||||
%% cleaning up. When it returns, the gen_server terminates with Reason.
|
|
||||||
%% The return value is ignored.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
terminate(_Reason, _State) ->
|
terminate(_Reason, _State) ->
|
||||||
ejabberd_commands:unregister_commands(commands()),
|
ejabberd_commands:unregister_commands(commands()),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
|
|
||||||
%% Description: Convert process state when code is changed
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
-spec set_session(sid(), binary(), binary(), binary(),
|
||||||
|
prio(), info()) -> ok.
|
||||||
|
|
||||||
set_session(SID, User, Server, Resource, Priority, Info) ->
|
set_session(SID, User, Server, Resource, Priority, Info) ->
|
||||||
LUser = jlib:nodeprep(User),
|
LUser = jlib:nodeprep(User),
|
||||||
LServer = jlib:nameprep(Server),
|
LServer = jlib:nameprep(Server),
|
||||||
|
@ -131,7 +131,8 @@ get_sessions(LUser, LServer) ->
|
|||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec get_sessions(binary(), binary(), binary()) -> [#session{}].
|
-spec get_sessions(binary(), binary(), binary()) ->
|
||||||
|
[#session{}].
|
||||||
get_sessions(LUser, LServer, LResource) ->
|
get_sessions(LUser, LServer, LResource) ->
|
||||||
USKey = us_to_key({LUser, LServer}),
|
USKey = us_to_key({LUser, LServer}),
|
||||||
case eredis:q(?PROCNAME, ["HGETALL", USKey]) of
|
case eredis:q(?PROCNAME, ["HGETALL", USKey]) of
|
||||||
|
@ -67,15 +67,12 @@
|
|||||||
|
|
||||||
-export_type([socket_state/0, sockmod/0]).
|
-export_type([socket_state/0, sockmod/0]).
|
||||||
|
|
||||||
-spec start(atom(), sockmod(), socket(), [{atom(), any()}]) -> any().
|
|
||||||
|
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%%--------------------------------------------------------------------
|
-spec start(atom(), sockmod(), socket(), [{atom(), any()}]) -> any().
|
||||||
%% Function:
|
|
||||||
%% Description:
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
start(Module, SockMod, Socket, Opts) ->
|
start(Module, SockMod, Socket, Opts) ->
|
||||||
case Module:socket_type() of
|
case Module:socket_type() of
|
||||||
xml_stream ->
|
xml_stream ->
|
||||||
@ -241,7 +238,3 @@ peername(#socket_state{sockmod = SockMod,
|
|||||||
_ -> SockMod:peername(Socket)
|
_ -> SockMod:peername(Socket)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%====================================================================
|
|
||||||
%% Internal functions
|
|
||||||
%%====================================================================
|
|
||||||
%====================================================================
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
-behaviour(gen_server).
|
-behaviour(gen_server).
|
||||||
|
|
||||||
%% API
|
%% API
|
||||||
-export([start_link/0, process_command/3,
|
-export([start_link/0, process_command/3, register_hook/1,
|
||||||
process_remote_command/1]).
|
process_remote_command/1]).
|
||||||
|
|
||||||
-export([init/1, handle_call/3, handle_cast/2,
|
-export([init/1, handle_call/3, handle_cast/2,
|
||||||
@ -85,6 +85,10 @@ process_command(From, To, Packet) ->
|
|||||||
_ -> ok
|
_ -> ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
register_hook(Host) ->
|
||||||
|
ejabberd_hooks:add(local_send_to_resource_hook, Host,
|
||||||
|
?MODULE, process_command, 50).
|
||||||
|
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
@ -100,11 +104,7 @@ init(Opts) ->
|
|||||||
LH = proplists:get_value(large_heap, Opts),
|
LH = proplists:get_value(large_heap, Opts),
|
||||||
process_flag(priority, high),
|
process_flag(priority, high),
|
||||||
erlang:system_monitor(self(), [{large_heap, LH}]),
|
erlang:system_monitor(self(), [{large_heap, LH}]),
|
||||||
lists:foreach(fun (Host) ->
|
lists:foreach(fun register_hook/1, ?MYHOSTS),
|
||||||
ejabberd_hooks:add(local_send_to_resource_hook, Host,
|
|
||||||
?MODULE, process_command, 50)
|
|
||||||
end,
|
|
||||||
?MYHOSTS),
|
|
||||||
{ok, #state{}}.
|
{ok, #state{}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
@ -245,8 +245,9 @@ s2s_out_info(Pid) ->
|
|||||||
[<<"Process type: s2s_out">>,
|
[<<"Process type: s2s_out">>,
|
||||||
case FromTo of
|
case FromTo of
|
||||||
[{From, To}] ->
|
[{From, To}] ->
|
||||||
list_to_binary(io_lib:format("\nS2S connection: from ~s to ~s",
|
<<"\n",
|
||||||
[From, To]));
|
(io_lib:format("S2S connection: from ~s to ~s",
|
||||||
|
[From, To]))/binary>>;
|
||||||
_ -> <<"">>
|
_ -> <<"">>
|
||||||
end,
|
end,
|
||||||
check_send_queue(Pid), <<"\n">>,
|
check_send_queue(Pid), <<"\n">>,
|
||||||
@ -310,7 +311,7 @@ help() ->
|
|||||||
"<node>\n setlh <node> <integer>">>.
|
"<node>\n setlh <node> <integer>">>.
|
||||||
|
|
||||||
remote_command(Node, Args, From, To) ->
|
remote_command(Node, Args, From, To) ->
|
||||||
Message = case rpc:call(Node, ?MODULE,
|
Message = case ejabberd_cluster:call(Node, ?MODULE,
|
||||||
process_remote_command, [Args])
|
process_remote_command, [Args])
|
||||||
of
|
of
|
||||||
{badrpc, Reason} ->
|
{badrpc, Reason} ->
|
||||||
|
@ -67,9 +67,6 @@ update(ModulesToUpdate) ->
|
|||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% OTP R14B03 and older provided release_handler_1:eval_script/3
|
|
||||||
%% But OTP R14B04 and newer provide release_handler_1:eval_script/5
|
|
||||||
%% Dialyzer reports a call to missing function; don't worry.
|
|
||||||
eval_script(Script, Apps, LibDirs) ->
|
eval_script(Script, Apps, LibDirs) ->
|
||||||
release_handler_1:eval_script(Script, Apps, LibDirs, [], []).
|
release_handler_1:eval_script(Script, Apps, LibDirs, [], []).
|
||||||
|
|
||||||
|
@ -1062,8 +1062,9 @@ term_to_string(T) ->
|
|||||||
|
|
||||||
%% @spec (T::any(), Cols::integer()) -> {NumLines::integer(), Paragraph::string()}
|
%% @spec (T::any(), Cols::integer()) -> {NumLines::integer(), Paragraph::string()}
|
||||||
term_to_paragraph(T, Cols) ->
|
term_to_paragraph(T, Cols) ->
|
||||||
Paragraph = list_to_binary(erl_prettypr:format(erl_syntax:abstract(T),
|
P1 = erl_syntax:abstract(T),
|
||||||
[{paper, Cols}])),
|
P2 = erl_prettypr:format(P1, [{paper, Cols}]),
|
||||||
|
Paragraph = list_to_binary(P2),
|
||||||
FieldList = ejabberd_regexp:split(Paragraph, <<"\n">>),
|
FieldList = ejabberd_regexp:split(Paragraph, <<"\n">>),
|
||||||
NumLines = length(FieldList),
|
NumLines = length(FieldList),
|
||||||
{NumLines, Paragraph}.
|
{NumLines, Paragraph}.
|
||||||
@ -1799,7 +1800,7 @@ get_node(Host, Node, [], _Query, Lang) ->
|
|||||||
<<"Modules">>)])]
|
<<"Modules">>)])]
|
||||||
++ MenuItems2))];
|
++ MenuItems2))];
|
||||||
get_node(global, Node, [<<"db">>], Query, Lang) ->
|
get_node(global, Node, [<<"db">>], Query, Lang) ->
|
||||||
case rpc:call(Node, mnesia, system_info, [tables]) of
|
case ejabberd_cluster:call(Node, mnesia, system_info, [tables]) of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
[?XCT(<<"h1">>, <<"RPC Call Error">>)];
|
[?XCT(<<"h1">>, <<"RPC Call Error">>)];
|
||||||
Tables ->
|
Tables ->
|
||||||
@ -1811,7 +1812,7 @@ get_node(global, Node, [<<"db">>], Query, Lang) ->
|
|||||||
Rows = lists:map(fun (Table) ->
|
Rows = lists:map(fun (Table) ->
|
||||||
STable =
|
STable =
|
||||||
iolist_to_binary(atom_to_list(Table)),
|
iolist_to_binary(atom_to_list(Table)),
|
||||||
TInfo = case rpc:call(Node, mnesia,
|
TInfo = case ejabberd_cluster:call(Node, mnesia,
|
||||||
table_info,
|
table_info,
|
||||||
[Table, all])
|
[Table, all])
|
||||||
of
|
of
|
||||||
@ -2031,7 +2032,7 @@ get_node(global, Node, [<<"backup">>], Query, Lang) ->
|
|||||||
[?INPUTT(<<"submit">>, <<"import_dir">>,
|
[?INPUTT(<<"submit">>, <<"import_dir">>,
|
||||||
<<"OK">>)])])])])])];
|
<<"OK">>)])])])])])];
|
||||||
get_node(global, Node, [<<"ports">>], Query, Lang) ->
|
get_node(global, Node, [<<"ports">>], Query, Lang) ->
|
||||||
Ports = rpc:call(Node, ejabberd_config,
|
Ports = ejabberd_cluster:call(Node, ejabberd_config,
|
||||||
get_local_option, [listen,
|
get_local_option, [listen,
|
||||||
{ejabberd_listener, validate_cfg},
|
{ejabberd_listener, validate_cfg},
|
||||||
[]]),
|
[]]),
|
||||||
@ -2045,7 +2046,7 @@ get_node(global, Node, [<<"ports">>], Query, Lang) ->
|
|||||||
{error, iolist_to_binary(io_lib:format("~p", [Reason]))};
|
{error, iolist_to_binary(io_lib:format("~p", [Reason]))};
|
||||||
_ -> nothing
|
_ -> nothing
|
||||||
end,
|
end,
|
||||||
NewPorts = lists:sort(rpc:call(Node, ejabberd_config,
|
NewPorts = lists:sort(ejabberd_cluster:call(Node, ejabberd_config,
|
||||||
get_local_option,
|
get_local_option,
|
||||||
[listen,
|
[listen,
|
||||||
{ejabberd_listener, validate_cfg},
|
{ejabberd_listener, validate_cfg},
|
||||||
@ -2068,7 +2069,7 @@ get_node(global, Node, [<<"ports">>], Query, Lang) ->
|
|||||||
[node_ports_to_xhtml(NewPorts, Lang)])];
|
[node_ports_to_xhtml(NewPorts, Lang)])];
|
||||||
get_node(Host, Node, [<<"modules">>], Query, Lang)
|
get_node(Host, Node, [<<"modules">>], Query, Lang)
|
||||||
when is_binary(Host) ->
|
when is_binary(Host) ->
|
||||||
Modules = rpc:call(Node, gen_mod,
|
Modules = ejabberd_cluster:call(Node, gen_mod,
|
||||||
loaded_modules_with_opts, [Host]),
|
loaded_modules_with_opts, [Host]),
|
||||||
Res = case catch node_modules_parse_query(Host, Node,
|
Res = case catch node_modules_parse_query(Host, Node,
|
||||||
Modules, Query)
|
Modules, Query)
|
||||||
@ -2077,7 +2078,7 @@ get_node(Host, Node, [<<"modules">>], Query, Lang)
|
|||||||
{'EXIT', Reason} -> ?INFO_MSG("~p~n", [Reason]), error;
|
{'EXIT', Reason} -> ?INFO_MSG("~p~n", [Reason]), error;
|
||||||
_ -> nothing
|
_ -> nothing
|
||||||
end,
|
end,
|
||||||
NewModules = lists:sort(rpc:call(Node, gen_mod,
|
NewModules = lists:sort(ejabberd_cluster:call(Node, gen_mod,
|
||||||
loaded_modules_with_opts, [Host])),
|
loaded_modules_with_opts, [Host])),
|
||||||
H1String = list_to_binary(io_lib:format(?T(<<"Modules at ~p">>), [Node])),
|
H1String = list_to_binary(io_lib:format(?T(<<"Modules at ~p">>), [Node])),
|
||||||
(?H1GL(H1String, <<"modules-overview">>,
|
(?H1GL(H1String, <<"modules-overview">>,
|
||||||
@ -2093,21 +2094,21 @@ get_node(Host, Node, [<<"modules">>], Query, Lang)
|
|||||||
[{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}],
|
[{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}],
|
||||||
[node_modules_to_xhtml(NewModules, Lang)])];
|
[node_modules_to_xhtml(NewModules, Lang)])];
|
||||||
get_node(global, Node, [<<"stats">>], _Query, Lang) ->
|
get_node(global, Node, [<<"stats">>], _Query, Lang) ->
|
||||||
UpTime = rpc:call(Node, erlang, statistics,
|
UpTime = ejabberd_cluster:call(Node, erlang, statistics,
|
||||||
[wall_clock]),
|
[wall_clock]),
|
||||||
UpTimeS = list_to_binary(io_lib:format("~.3f",
|
UpTimeS = list_to_binary(io_lib:format("~.3f",
|
||||||
[element(1, UpTime) / 1000])),
|
[element(1, UpTime) / 1000])),
|
||||||
CPUTime = rpc:call(Node, erlang, statistics, [runtime]),
|
CPUTime = ejabberd_cluster:call(Node, erlang, statistics, [runtime]),
|
||||||
CPUTimeS = list_to_binary(io_lib:format("~.3f",
|
CPUTimeS = list_to_binary(io_lib:format("~.3f",
|
||||||
[element(1, CPUTime) / 1000])),
|
[element(1, CPUTime) / 1000])),
|
||||||
OnlineUsers = mnesia:table_info(session, size),
|
OnlineUsers = mnesia:table_info(session, size),
|
||||||
TransactionsCommitted = rpc:call(Node, mnesia,
|
TransactionsCommitted = ejabberd_cluster:call(Node, mnesia,
|
||||||
system_info, [transaction_commits]),
|
system_info, [transaction_commits]),
|
||||||
TransactionsAborted = rpc:call(Node, mnesia,
|
TransactionsAborted = ejabberd_cluster:call(Node, mnesia,
|
||||||
system_info, [transaction_failures]),
|
system_info, [transaction_failures]),
|
||||||
TransactionsRestarted = rpc:call(Node, mnesia,
|
TransactionsRestarted = ejabberd_cluster:call(Node, mnesia,
|
||||||
system_info, [transaction_restarts]),
|
system_info, [transaction_restarts]),
|
||||||
TransactionsLogged = rpc:call(Node, mnesia, system_info,
|
TransactionsLogged = ejabberd_cluster:call(Node, mnesia, system_info,
|
||||||
[transaction_log_writes]),
|
[transaction_log_writes]),
|
||||||
[?XC(<<"h1">>,
|
[?XC(<<"h1">>,
|
||||||
list_to_binary(io_lib:format(?T(<<"Statistics of ~p">>), [Node]))),
|
list_to_binary(io_lib:format(?T(<<"Statistics of ~p">>), [Node]))),
|
||||||
@ -2142,12 +2143,12 @@ get_node(global, Node, [<<"stats">>], _Query, Lang) ->
|
|||||||
?XAC(<<"td">>, [{<<"class">>, <<"alignright">>}],
|
?XAC(<<"td">>, [{<<"class">>, <<"alignright">>}],
|
||||||
(pretty_string_int(TransactionsLogged)))])])])];
|
(pretty_string_int(TransactionsLogged)))])])])];
|
||||||
get_node(global, Node, [<<"update">>], Query, Lang) ->
|
get_node(global, Node, [<<"update">>], Query, Lang) ->
|
||||||
rpc:call(Node, code, purge, [ejabberd_update]),
|
ejabberd_cluster:call(Node, code, purge, [ejabberd_update]),
|
||||||
Res = node_update_parse_query(Node, Query),
|
Res = node_update_parse_query(Node, Query),
|
||||||
rpc:call(Node, code, load_file, [ejabberd_update]),
|
ejabberd_cluster:call(Node, code, load_file, [ejabberd_update]),
|
||||||
{ok, _Dir, UpdatedBeams, Script, LowLevelScript,
|
{ok, _Dir, UpdatedBeams, Script, LowLevelScript,
|
||||||
Check} =
|
Check} =
|
||||||
rpc:call(Node, ejabberd_update, update_info, []),
|
ejabberd_cluster:call(Node, ejabberd_update, update_info, []),
|
||||||
Mods = case UpdatedBeams of
|
Mods = case UpdatedBeams of
|
||||||
[] -> ?CT(<<"None">>);
|
[] -> ?CT(<<"None">>);
|
||||||
_ ->
|
_ ->
|
||||||
@ -2216,14 +2217,14 @@ get_node(Host, Node, NPath, Query, Lang) ->
|
|||||||
node_parse_query(Node, Query) ->
|
node_parse_query(Node, Query) ->
|
||||||
case lists:keysearch(<<"restart">>, 1, Query) of
|
case lists:keysearch(<<"restart">>, 1, Query) of
|
||||||
{value, _} ->
|
{value, _} ->
|
||||||
case rpc:call(Node, init, restart, []) of
|
case ejabberd_cluster:call(Node, init, restart, []) of
|
||||||
{badrpc, _Reason} -> error;
|
{badrpc, _Reason} -> error;
|
||||||
_ -> ok
|
_ -> ok
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
case lists:keysearch(<<"stop">>, 1, Query) of
|
case lists:keysearch(<<"stop">>, 1, Query) of
|
||||||
{value, _} ->
|
{value, _} ->
|
||||||
case rpc:call(Node, init, stop, []) of
|
case ejabberd_cluster:call(Node, init, stop, []) of
|
||||||
{badrpc, _Reason} -> error;
|
{badrpc, _Reason} -> error;
|
||||||
_ -> ok
|
_ -> ok
|
||||||
end;
|
end;
|
||||||
@ -2307,35 +2308,35 @@ node_backup_parse_query(Node, Query) ->
|
|||||||
{value, {_, Path}} ->
|
{value, {_, Path}} ->
|
||||||
Res = case Action of
|
Res = case Action of
|
||||||
<<"store">> ->
|
<<"store">> ->
|
||||||
rpc:call(Node, mnesia, backup,
|
ejabberd_cluster:call(Node, mnesia, backup,
|
||||||
[binary_to_list(Path)]);
|
[binary_to_list(Path)]);
|
||||||
<<"restore">> ->
|
<<"restore">> ->
|
||||||
rpc:call(Node, ejabberd_admin,
|
ejabberd_cluster:call(Node, ejabberd_admin,
|
||||||
restore, [Path]);
|
restore, [Path]);
|
||||||
<<"fallback">> ->
|
<<"fallback">> ->
|
||||||
rpc:call(Node, mnesia,
|
ejabberd_cluster:call(Node, mnesia,
|
||||||
install_fallback,
|
install_fallback,
|
||||||
[binary_to_list(Path)]);
|
[binary_to_list(Path)]);
|
||||||
<<"dump">> ->
|
<<"dump">> ->
|
||||||
rpc:call(Node, ejabberd_admin,
|
ejabberd_cluster:call(Node, ejabberd_admin,
|
||||||
dump_to_textfile,
|
dump_to_textfile,
|
||||||
[Path]);
|
[Path]);
|
||||||
<<"load">> ->
|
<<"load">> ->
|
||||||
rpc:call(Node, mnesia,
|
ejabberd_cluster:call(Node, mnesia,
|
||||||
load_textfile,
|
load_textfile,
|
||||||
[binary_to_list(Path)]);
|
[binary_to_list(Path)]);
|
||||||
<<"import_piefxis_file">> ->
|
<<"import_piefxis_file">> ->
|
||||||
rpc:call(Node, ejabberd_piefxis,
|
ejabberd_cluster:call(Node, ejabberd_piefxis,
|
||||||
import_file, [Path]);
|
import_file, [Path]);
|
||||||
<<"export_piefxis_dir">> ->
|
<<"export_piefxis_dir">> ->
|
||||||
rpc:call(Node, ejabberd_piefxis,
|
ejabberd_cluster:call(Node, ejabberd_piefxis,
|
||||||
export_server, [Path]);
|
export_server, [Path]);
|
||||||
<<"export_piefxis_host_dir">> ->
|
<<"export_piefxis_host_dir">> ->
|
||||||
{value, {_, Host}} =
|
{value, {_, Host}} =
|
||||||
lists:keysearch(<<Action/binary,
|
lists:keysearch(<<Action/binary,
|
||||||
"host">>,
|
"host">>,
|
||||||
1, Query),
|
1, Query),
|
||||||
rpc:call(Node, ejabberd_piefxis,
|
ejabberd_cluster:call(Node, ejabberd_piefxis,
|
||||||
export_host,
|
export_host,
|
||||||
[Path, Host]);
|
[Path, Host]);
|
||||||
<<"export_sql_file">> ->
|
<<"export_sql_file">> ->
|
||||||
@ -2343,13 +2344,13 @@ node_backup_parse_query(Node, Query) ->
|
|||||||
lists:keysearch(<<Action/binary,
|
lists:keysearch(<<Action/binary,
|
||||||
"host">>,
|
"host">>,
|
||||||
1, Query),
|
1, Query),
|
||||||
rpc:call(Node, ejd2odbc,
|
ejabberd_cluster:call(Node, ejd2odbc,
|
||||||
export, [Host, Path]);
|
export, [Host, Path]);
|
||||||
<<"import_file">> ->
|
<<"import_file">> ->
|
||||||
rpc:call(Node, ejabberd_admin,
|
ejabberd_cluster:call(Node, ejabberd_admin,
|
||||||
import_file, [Path]);
|
import_file, [Path]);
|
||||||
<<"import_dir">> ->
|
<<"import_dir">> ->
|
||||||
rpc:call(Node, ejabberd_admin,
|
ejabberd_cluster:call(Node, ejabberd_admin,
|
||||||
import_dir, [Path])
|
import_dir, [Path])
|
||||||
end,
|
end,
|
||||||
case Res of
|
case Res of
|
||||||
@ -2474,10 +2475,10 @@ node_ports_parse_query(Node, Ports, Query) ->
|
|||||||
{ok, Tokens, _} =
|
{ok, Tokens, _} =
|
||||||
erl_scan:string(binary_to_list(SOpts) ++ "."),
|
erl_scan:string(binary_to_list(SOpts) ++ "."),
|
||||||
{ok, Opts} = erl_parse:parse_term(Tokens),
|
{ok, Opts} = erl_parse:parse_term(Tokens),
|
||||||
rpc:call(Node, ejabberd_listener,
|
ejabberd_cluster:call(Node, ejabberd_listener,
|
||||||
delete_listener,
|
delete_listener,
|
||||||
[PortIpNetp2, Module1]),
|
[PortIpNetp2, Module1]),
|
||||||
R = rpc:call(Node, ejabberd_listener,
|
R = ejabberd_cluster:call(Node, ejabberd_listener,
|
||||||
add_listener,
|
add_listener,
|
||||||
[PortIpNetp2, Module, Opts]),
|
[PortIpNetp2, Module, Opts]),
|
||||||
throw({is_added, R});
|
throw({is_added, R});
|
||||||
@ -2487,7 +2488,7 @@ node_ports_parse_query(Node, Ports, Query) ->
|
|||||||
1, Query)
|
1, Query)
|
||||||
of
|
of
|
||||||
{value, _} ->
|
{value, _} ->
|
||||||
rpc:call(Node, ejabberd_listener,
|
ejabberd_cluster:call(Node, ejabberd_listener,
|
||||||
delete_listener,
|
delete_listener,
|
||||||
[PortIpNetp, Module1]),
|
[PortIpNetp, Module1]),
|
||||||
throw(submitted);
|
throw(submitted);
|
||||||
@ -2520,7 +2521,7 @@ node_ports_parse_query(Node, Ports, Query) ->
|
|||||||
{Port2, _SPort, IP2, _SIP, _SSPort, NetProt2,
|
{Port2, _SPort, IP2, _SIP, _SSPort, NetProt2,
|
||||||
OptsClean} =
|
OptsClean} =
|
||||||
get_port_data({Port2, STIP2, NetProt2}, Opts),
|
get_port_data({Port2, STIP2, NetProt2}, Opts),
|
||||||
R = rpc:call(Node, ejabberd_listener, add_listener,
|
R = ejabberd_cluster:call(Node, ejabberd_listener, add_listener,
|
||||||
[{Port2, IP2, NetProt2}, Module, OptsClean]),
|
[{Port2, IP2, NetProt2}, Module, OptsClean]),
|
||||||
throw({is_added, R});
|
throw({is_added, R});
|
||||||
_ -> ok
|
_ -> ok
|
||||||
@ -2579,9 +2580,9 @@ node_modules_parse_query(Host, Node, Modules, Query) ->
|
|||||||
{ok, Tokens, _} =
|
{ok, Tokens, _} =
|
||||||
erl_scan:string(binary_to_list(<<SOpts/binary, ".">>)),
|
erl_scan:string(binary_to_list(<<SOpts/binary, ".">>)),
|
||||||
{ok, Opts} = erl_parse:parse_term(Tokens),
|
{ok, Opts} = erl_parse:parse_term(Tokens),
|
||||||
rpc:call(Node, gen_mod, stop_module,
|
ejabberd_cluster:call(Node, gen_mod, stop_module,
|
||||||
[Host, Module]),
|
[Host, Module]),
|
||||||
rpc:call(Node, gen_mod, start_module,
|
ejabberd_cluster:call(Node, gen_mod, start_module,
|
||||||
[Host, Module, Opts]),
|
[Host, Module, Opts]),
|
||||||
throw(submitted);
|
throw(submitted);
|
||||||
_ ->
|
_ ->
|
||||||
@ -2589,7 +2590,7 @@ node_modules_parse_query(Host, Node, Modules, Query) ->
|
|||||||
1, Query)
|
1, Query)
|
||||||
of
|
of
|
||||||
{value, _} ->
|
{value, _} ->
|
||||||
rpc:call(Node, gen_mod, stop_module,
|
ejabberd_cluster:call(Node, gen_mod, stop_module,
|
||||||
[Host, Module]),
|
[Host, Module]),
|
||||||
throw(submitted);
|
throw(submitted);
|
||||||
_ -> ok
|
_ -> ok
|
||||||
@ -2605,7 +2606,7 @@ node_modules_parse_query(Host, Node, Modules, Query) ->
|
|||||||
Module = jlib:binary_to_atom(SModule),
|
Module = jlib:binary_to_atom(SModule),
|
||||||
{ok, Tokens, _} = erl_scan:string(binary_to_list(<<SOpts/binary, ".">>)),
|
{ok, Tokens, _} = erl_scan:string(binary_to_list(<<SOpts/binary, ".">>)),
|
||||||
{ok, Opts} = erl_parse:parse_term(Tokens),
|
{ok, Opts} = erl_parse:parse_term(Tokens),
|
||||||
rpc:call(Node, gen_mod, start_module,
|
ejabberd_cluster:call(Node, gen_mod, start_module,
|
||||||
[Host, Module, Opts]),
|
[Host, Module, Opts]),
|
||||||
throw(submitted);
|
throw(submitted);
|
||||||
_ -> ok
|
_ -> ok
|
||||||
@ -2618,7 +2619,7 @@ node_update_parse_query(Node, Query) ->
|
|||||||
proplists:get_all_values(<<"selected">>, Query),
|
proplists:get_all_values(<<"selected">>, Query),
|
||||||
ModulesToUpdate = [jlib:binary_to_atom(M)
|
ModulesToUpdate = [jlib:binary_to_atom(M)
|
||||||
|| M <- ModulesToUpdateStrings],
|
|| M <- ModulesToUpdateStrings],
|
||||||
case rpc:call(Node, ejabberd_update, update,
|
case ejabberd_cluster:call(Node, ejabberd_update, update,
|
||||||
[ModulesToUpdate])
|
[ModulesToUpdate])
|
||||||
of
|
of
|
||||||
{ok, _} -> ok;
|
{ok, _} -> ok;
|
||||||
@ -2893,7 +2894,8 @@ make_menu_item(item, 3, URI, Name, Lang) ->
|
|||||||
|
|
||||||
%%%==================================
|
%%%==================================
|
||||||
|
|
||||||
%%% vim: set foldmethod=marker foldmarker=%%%%,%%%=:
|
|
||||||
|
|
||||||
opt_type(access) -> fun (V) -> V end;
|
opt_type(access) -> fun (V) -> V end;
|
||||||
opt_type(_) -> [access].
|
opt_type(_) -> [access].
|
||||||
|
|
||||||
|
%%% vim: set foldmethod=marker foldmarker=%%%%,%%%=:
|
||||||
|
@ -629,27 +629,10 @@ init([Hosts, Port, Rootdn, Passwd, Opts]) ->
|
|||||||
id = 0, dict = dict:new(), req_q = queue:new()},
|
id = 0, dict = dict:new(), req_q = queue:new()},
|
||||||
0}.
|
0}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: StateName/2
|
|
||||||
%% Called when gen_fsm:send_event/2,3 is invoked (async)
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
connecting(timeout, S) ->
|
connecting(timeout, S) ->
|
||||||
{ok, NextState, NewS} = connect_bind(S),
|
{ok, NextState, NewS} = connect_bind(S),
|
||||||
{next_state, NextState, NewS}.
|
{next_state, NextState, NewS}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: StateName/3
|
|
||||||
%% Called when gen_fsm:sync_send_event/2,3 is invoked.
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData} |
|
|
||||||
%% {stop, Reason, Reply, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
connecting(Event, From, S) ->
|
connecting(Event, From, S) ->
|
||||||
Q = queue:in({Event, From}, S#eldap.req_q),
|
Q = queue:in({Event, From}, S#eldap.req_q),
|
||||||
{next_state, connecting, S#eldap{req_q = Q}}.
|
{next_state, connecting, S#eldap{req_q = Q}}.
|
||||||
@ -678,34 +661,15 @@ handle_event(close, _StateName, S) ->
|
|||||||
handle_event(_Event, StateName, S) ->
|
handle_event(_Event, StateName, S) ->
|
||||||
{next_state, StateName, S}.
|
{next_state, StateName, S}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_sync_event/4
|
|
||||||
%% Called when gen_fsm:sync_send_all_state_event/2,3 is invoked
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData} |
|
|
||||||
%% {stop, Reason, Reply, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_sync_event(_Event, _From, StateName, S) ->
|
handle_sync_event(_Event, _From, StateName, S) ->
|
||||||
{reply, {StateName, S}, StateName, S}.
|
{reply, {StateName, S}, StateName, S}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_info/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
%% Packets arriving in various states
|
%% Packets arriving in various states
|
||||||
%%
|
%%
|
||||||
handle_info({Tag, _Socket, Data}, connecting, S)
|
handle_info({Tag, _Socket, Data}, connecting, S)
|
||||||
when Tag == tcp; Tag == ssl ->
|
when Tag == tcp; Tag == ssl ->
|
||||||
?DEBUG("tcp packet received when disconnected!~n~p",
|
?DEBUG("tcp packet received when disconnected!~n~p", [Data]),
|
||||||
[Data]),
|
|
||||||
{next_state, connecting, S};
|
{next_state, connecting, S};
|
||||||
handle_info({Tag, _Socket, Data}, wait_bind_response, S)
|
handle_info({Tag, _Socket, Data}, wait_bind_response, S)
|
||||||
when Tag == tcp; Tag == ssl ->
|
when Tag == tcp; Tag == ssl ->
|
||||||
@ -724,8 +688,7 @@ handle_info({Tag, _Socket, Data}, wait_bind_response, S)
|
|||||||
{next_state, connecting, close_and_retry(S)}
|
{next_state, connecting, close_and_retry(S)}
|
||||||
end;
|
end;
|
||||||
handle_info({Tag, _Socket, Data}, StateName, S)
|
handle_info({Tag, _Socket, Data}, StateName, S)
|
||||||
when (StateName == active orelse
|
when (StateName == active orelse StateName == active_bind)
|
||||||
StateName == active_bind)
|
|
||||||
andalso (Tag == tcp orelse Tag == ssl) ->
|
andalso (Tag == tcp orelse Tag == ssl) ->
|
||||||
case catch recvd_packet(Data, S) of
|
case catch recvd_packet(Data, S) of
|
||||||
{response, Response, RequestType} ->
|
{response, Response, RequestType} ->
|
||||||
@ -766,8 +729,7 @@ handle_info({timeout, Timer, {cmd_timeout, Id}},
|
|||||||
handle_info({timeout, retry_connect}, connecting, S) ->
|
handle_info({timeout, retry_connect}, connecting, S) ->
|
||||||
{ok, NextState, NewS} = connect_bind(S),
|
{ok, NextState, NewS} = connect_bind(S),
|
||||||
{next_state, NextState, NewS};
|
{next_state, NextState, NewS};
|
||||||
handle_info({timeout, _Timer, bind_timeout},
|
handle_info({timeout, _Timer, bind_timeout}, wait_bind_response, S) ->
|
||||||
wait_bind_response, S) ->
|
|
||||||
{next_state, connecting, close_and_retry(S)};
|
{next_state, connecting, close_and_retry(S)};
|
||||||
%%
|
%%
|
||||||
%% Make sure we don't fill the message queue with rubbish
|
%% Make sure we don't fill the message queue with rubbish
|
||||||
@ -825,16 +787,14 @@ send_command(Command, From, S) ->
|
|||||||
Message = #'LDAPMessage'{messageID = Id,
|
Message = #'LDAPMessage'{messageID = Id,
|
||||||
protocolOp = {Name, Request}},
|
protocolOp = {Name, Request}},
|
||||||
?DEBUG("~p~n", [{Name, ejabberd_config:may_hide_data(Request)}]),
|
?DEBUG("~p~n", [{Name, ejabberd_config:may_hide_data(Request)}]),
|
||||||
{ok, Bytes} = 'ELDAPv3':encode('LDAPMessage',
|
{ok, Bytes} = 'ELDAPv3':encode('LDAPMessage', Message),
|
||||||
Message),
|
|
||||||
case (S#eldap.sockmod):send(S#eldap.fd, Bytes) of
|
case (S#eldap.sockmod):send(S#eldap.fd, Bytes) of
|
||||||
ok ->
|
ok ->
|
||||||
Timer = erlang:start_timer(?CMD_TIMEOUT, self(),
|
Timer = erlang:start_timer(?CMD_TIMEOUT, self(), {cmd_timeout, Id}),
|
||||||
{cmd_timeout, Id}),
|
New_dict = dict:store(Id, [{Timer, Command, From, Name}], S#eldap.dict),
|
||||||
New_dict = dict:store(Id,
|
|
||||||
[{Timer, Command, From, Name}], S#eldap.dict),
|
|
||||||
{ok, S#eldap{id = Id, dict = New_dict}};
|
{ok, S#eldap{id = Id, dict = New_dict}};
|
||||||
Error -> Error
|
Error ->
|
||||||
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
gen_req({search, A}) ->
|
gen_req({search, A}) ->
|
||||||
@ -1148,8 +1108,7 @@ bind_request(Socket, S) ->
|
|||||||
Message = #'LDAPMessage'{messageID = Id,
|
Message = #'LDAPMessage'{messageID = Id,
|
||||||
protocolOp = {bindRequest, Req}},
|
protocolOp = {bindRequest, Req}},
|
||||||
?DEBUG("Bind Request Message:~p~n", [ejabberd_config:may_hide_data(Message)]),
|
?DEBUG("Bind Request Message:~p~n", [ejabberd_config:may_hide_data(Message)]),
|
||||||
{ok, Bytes} = 'ELDAPv3':encode('LDAPMessage',
|
{ok, Bytes} = 'ELDAPv3':encode('LDAPMessage', Message),
|
||||||
Message),
|
|
||||||
case (S#eldap.sockmod):send(Socket, Bytes) of
|
case (S#eldap.sockmod):send(Socket, Bytes) of
|
||||||
ok -> {ok, S#eldap{id = Id}};
|
ok -> {ok, S#eldap{id = Id}};
|
||||||
Error -> Error
|
Error -> Error
|
||||||
@ -1162,24 +1121,6 @@ next_host(Host,
|
|||||||
Hosts) -> % Find next in turn
|
Hosts) -> % Find next in turn
|
||||||
next_host(Host, Hosts, Hosts).
|
next_host(Host, Hosts, Hosts).
|
||||||
|
|
||||||
%%% --------------------------------------------------------------------
|
|
||||||
%%% Verify the input data
|
|
||||||
%%% --------------------------------------------------------------------
|
|
||||||
%%% --------------------------------------------------------------------
|
|
||||||
%%% Get and Validate the initial configuration
|
|
||||||
%%% --------------------------------------------------------------------
|
|
||||||
%% get_atom(Key, List) ->
|
|
||||||
%% case lists:keysearch(Key, 1, List) of
|
|
||||||
%% {value, {Key, Value}} when is_atom(Value) ->
|
|
||||||
%% Value;
|
|
||||||
%% {value, {Key, _Value}} ->
|
|
||||||
%% throw({error, "Bad Value in Config for " ++ atom_to_list(Key)});
|
|
||||||
%% false ->
|
|
||||||
%% throw({error, "No Entry in Config for " ++ atom_to_list(Key)})
|
|
||||||
%% end.
|
|
||||||
%%% --------------------------------------------------------------------
|
|
||||||
%%% Other Stuff
|
|
||||||
%%% --------------------------------------------------------------------
|
|
||||||
next_host(Host, [Host], Hosts) ->
|
next_host(Host, [Host], Hosts) ->
|
||||||
hd(Hosts); % Wrap back to first
|
hd(Hosts); % Wrap back to first
|
||||||
next_host(Host, [Host | Tail], _Hosts) ->
|
next_host(Host, [Host | Tail], _Hosts) ->
|
||||||
|
@ -44,9 +44,9 @@
|
|||||||
|
|
||||||
-record(state, {host, module, function}).
|
-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 type() :: no_queue | one_queue | pos_integer() | parallel.
|
||||||
%%-type opts() :: no_queue | {one_queue, pid()} | {queues, [pid()]} | parallel.
|
-type opts() :: no_queue | {one_queue, pid()} | {queues, [pid()]} | parallel.
|
||||||
|
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
@ -86,9 +86,13 @@ add_iq_handler(Component, Host, NS, Module, Function,
|
|||||||
Function, parallel)
|
Function, parallel)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec remove_iq_handler(component(), binary(), binary()) -> any().
|
||||||
|
|
||||||
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().
|
||||||
|
|
||||||
stop_iq_handler(_Module, _Function, Opts) ->
|
stop_iq_handler(_Module, _Function, Opts) ->
|
||||||
case Opts of
|
case Opts of
|
||||||
{one_queue, Pid} -> gen_server:call(Pid, stop);
|
{one_queue, Pid} -> gen_server:call(Pid, stop);
|
||||||
@ -100,14 +104,16 @@ stop_iq_handler(_Module, _Function, Opts) ->
|
|||||||
_ -> ok
|
_ -> ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec handle(binary(), atom(), atom(), opts(), jid(), jid(), iq()) -> any().
|
||||||
|
|
||||||
handle(Host, Module, Function, Opts, From, To, IQ) ->
|
handle(Host, Module, Function, Opts, From, To, IQ) ->
|
||||||
case Opts of
|
case Opts of
|
||||||
no_queue ->
|
no_queue ->
|
||||||
process_iq(Host, Module, Function, From, To, IQ);
|
process_iq(Host, Module, Function, From, To, IQ);
|
||||||
{one_queue, Pid} -> Pid ! {process_iq, From, To, IQ};
|
{one_queue, Pid} ->
|
||||||
|
Pid ! {process_iq, From, To, IQ};
|
||||||
{queues, Pids} ->
|
{queues, Pids} ->
|
||||||
Pid = lists:nth(erlang:phash(now(), length(Pids)),
|
Pid = lists:nth(erlang:phash(now(), length(Pids)), Pids),
|
||||||
Pids),
|
|
||||||
Pid ! {process_iq, From, To, IQ};
|
Pid ! {process_iq, From, To, IQ};
|
||||||
parallel ->
|
parallel ->
|
||||||
spawn(?MODULE, process_iq,
|
spawn(?MODULE, process_iq,
|
||||||
@ -115,6 +121,8 @@ handle(Host, Module, Function, Opts, From, To, IQ) ->
|
|||||||
_ -> todo
|
_ -> todo
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec process_iq(binary(), atom(), atom(), jid(), jid(), iq()) -> any().
|
||||||
|
|
||||||
process_iq(_Host, Module, Function, From, To, IQ) ->
|
process_iq(_Host, Module, Function, From, To, IQ) ->
|
||||||
case catch Module:Function(From, To, IQ) of
|
case catch Module:Function(From, To, IQ) of
|
||||||
{'EXIT', Reason} -> ?ERROR_MSG("~p", [Reason]);
|
{'EXIT', Reason} -> ?ERROR_MSG("~p", [Reason]);
|
||||||
@ -146,44 +154,16 @@ transform_module_options(Opts) ->
|
|||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: init(Args) -> {ok, State} |
|
|
||||||
%% {ok, State, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, Reason}
|
|
||||||
%% Description: Initiates the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
init([Host, Module, Function]) ->
|
init([Host, Module, Function]) ->
|
||||||
{ok,
|
{ok,
|
||||||
#state{host = Host, module = Module,
|
#state{host = Host, module = Module,
|
||||||
function = Function}}.
|
function = Function}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
|
|
||||||
%% {reply, Reply, State, Timeout} |
|
|
||||||
%% {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, Reply, State} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling call messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_call(stop, _From, State) ->
|
handle_call(stop, _From, State) ->
|
||||||
Reply = ok, {stop, normal, Reply, State}.
|
Reply = ok, {stop, normal, Reply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_cast(Msg, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_cast(_Msg, State) -> {noreply, State}.
|
handle_cast(_Msg, State) -> {noreply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_info(Info, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling all non call/cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_info({process_iq, From, To, IQ},
|
handle_info({process_iq, From, To, IQ},
|
||||||
#state{host = Host, module = Module,
|
#state{host = Host, module = Module,
|
||||||
function = Function} =
|
function = Function} =
|
||||||
@ -192,19 +172,8 @@ handle_info({process_iq, From, To, IQ},
|
|||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_info(_Info, State) -> {noreply, State}.
|
handle_info(_Info, State) -> {noreply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: terminate(Reason, State) -> void()
|
|
||||||
%% Description: This function is called by a gen_server when it is about to
|
|
||||||
%% terminate. It should be the opposite of Module:init/1 and do any necessary
|
|
||||||
%% cleaning up. When it returns, the gen_server terminates with Reason.
|
|
||||||
%% The return value is ignored.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
terminate(_Reason, _State) -> ok.
|
terminate(_Reason, _State) -> ok.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
|
|
||||||
%% Description: Convert process state when code is changed
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
-module (mod_carboncopy).
|
-module (mod_carboncopy).
|
||||||
|
|
||||||
-author ('ecestari@process-one.net').
|
-author ('ecestari@process-one.net').
|
||||||
-protocol({xep, 280, '0.8'}).
|
-protocol({xep, 280, '0.8'}).
|
||||||
|
|
||||||
@ -130,7 +131,6 @@ user_send_packet(Packet, _C2SState, From, To) ->
|
|||||||
user_receive_packet(Packet, _C2SState, JID, _From, To) ->
|
user_receive_packet(Packet, _C2SState, JID, _From, To) ->
|
||||||
check_and_forward(JID, To, Packet, received).
|
check_and_forward(JID, To, Packet, received).
|
||||||
|
|
||||||
% verifier si le trafic est local
|
|
||||||
% Modified from original version:
|
% Modified from original version:
|
||||||
% - registered to the user_send_packet hook, to be called only once even for multicast
|
% - registered to the user_send_packet hook, to be called only once even for multicast
|
||||||
% - do not support "private" message mode, and do not modify the original packet in any way
|
% - do not support "private" message mode, and do not modify the original packet in any way
|
||||||
@ -145,8 +145,8 @@ check_and_forward(JID, To, Packet, Direction)->
|
|||||||
send_copies(JID, To, Packet, Direction),
|
send_copies(JID, To, Packet, Direction),
|
||||||
Packet;
|
Packet;
|
||||||
true ->
|
true ->
|
||||||
%% stop the hook chain, we don't want mod_logdb to register
|
%% stop the hook chain, we don't want logging modules to duplicates
|
||||||
%% this message (duplicate)
|
%% this message
|
||||||
{stop, Packet}
|
{stop, Packet}
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
@ -285,7 +285,7 @@ has_non_empty_body(Packet) ->
|
|||||||
xml:get_subtag_cdata(Packet, <<"body">>) =/= <<"">>.
|
xml:get_subtag_cdata(Packet, <<"body">>) =/= <<"">>.
|
||||||
|
|
||||||
%% list {resource, cc_version} with carbons enabled for given user and host
|
%% list {resource, cc_version} with carbons enabled for given user and host
|
||||||
list(User, Server)->
|
list(User, Server) ->
|
||||||
mnesia:dirty_select(?TABLE, [{#carboncopy{us = {User, Server}, resource = '$2', version = '$3'}, [], [{{'$2','$3'}}]}]).
|
mnesia:dirty_select(?TABLE, [{#carboncopy{us = {User, Server}, resource = '$2', version = '$3'}, [], [{{'$2','$3'}}]}]).
|
||||||
|
|
||||||
|
|
||||||
|
@ -985,7 +985,7 @@ get_form(_Host, [<<"running nodes">>, ENode, <<"DB">>],
|
|||||||
case search_running_node(ENode) of
|
case search_running_node(ENode) of
|
||||||
false -> {error, ?ERR_ITEM_NOT_FOUND};
|
false -> {error, ?ERR_ITEM_NOT_FOUND};
|
||||||
Node ->
|
Node ->
|
||||||
case rpc:call(Node, mnesia, system_info, [tables]) of
|
case ejabberd_cluster:call(Node, mnesia, system_info, [tables]) of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||||
Tables ->
|
Tables ->
|
||||||
@ -1007,7 +1007,7 @@ get_form(_Host, [<<"running nodes">>, ENode, <<"DB">>],
|
|||||||
?T(Lang,
|
?T(Lang,
|
||||||
<<"Choose storage type of tables">>)}]}
|
<<"Choose storage type of tables">>)}]}
|
||||||
| lists:map(fun (Table) ->
|
| lists:map(fun (Table) ->
|
||||||
case rpc:call(Node, mnesia,
|
case ejabberd_cluster:call(Node, mnesia,
|
||||||
table_info,
|
table_info,
|
||||||
[Table,
|
[Table,
|
||||||
storage_type])
|
storage_type])
|
||||||
@ -1028,7 +1028,7 @@ get_form(Host,
|
|||||||
case search_running_node(ENode) of
|
case search_running_node(ENode) of
|
||||||
false -> {error, ?ERR_ITEM_NOT_FOUND};
|
false -> {error, ?ERR_ITEM_NOT_FOUND};
|
||||||
Node ->
|
Node ->
|
||||||
case rpc:call(Node, gen_mod, loaded_modules, [Host]) of
|
case ejabberd_cluster:call(Node, gen_mod, loaded_modules, [Host]) of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||||
Modules ->
|
Modules ->
|
||||||
@ -1607,7 +1607,7 @@ set_form(_From, Host,
|
|||||||
case Vals of
|
case Vals of
|
||||||
[<<"1">>] ->
|
[<<"1">>] ->
|
||||||
Module = jlib:binary_to_atom(Var),
|
Module = jlib:binary_to_atom(Var),
|
||||||
rpc:call(Node, gen_mod, stop_module,
|
ejabberd_cluster:call(Node, gen_mod, stop_module,
|
||||||
[Host, Module]);
|
[Host, Module]);
|
||||||
_ -> ok
|
_ -> ok
|
||||||
end
|
end
|
||||||
@ -1634,7 +1634,7 @@ set_form(_From, Host,
|
|||||||
case erl_parse:parse_term(Tokens) of
|
case erl_parse:parse_term(Tokens) of
|
||||||
{ok, Modules} ->
|
{ok, Modules} ->
|
||||||
lists:foreach(fun ({Module, Args}) ->
|
lists:foreach(fun ({Module, Args}) ->
|
||||||
rpc:call(Node, gen_mod,
|
ejabberd_cluster:call(Node, gen_mod,
|
||||||
start_module,
|
start_module,
|
||||||
[Host, Module, Args])
|
[Host, Module, Args])
|
||||||
end,
|
end,
|
||||||
@ -1656,7 +1656,7 @@ set_form(_From, _Host,
|
|||||||
case lists:keysearch(<<"path">>, 1, XData) of
|
case lists:keysearch(<<"path">>, 1, XData) of
|
||||||
false -> {error, ?ERR_BAD_REQUEST};
|
false -> {error, ?ERR_BAD_REQUEST};
|
||||||
{value, {_, [String]}} ->
|
{value, {_, [String]}} ->
|
||||||
case rpc:call(Node, mnesia, backup, [String]) of
|
case ejabberd_cluster:call(Node, mnesia, backup, [String]) of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||||
{error, _Reason} -> {error, ?ERR_INTERNAL_SERVER_ERROR};
|
{error, _Reason} -> {error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||||
@ -1675,7 +1675,7 @@ set_form(_From, _Host,
|
|||||||
case lists:keysearch(<<"path">>, 1, XData) of
|
case lists:keysearch(<<"path">>, 1, XData) of
|
||||||
false -> {error, ?ERR_BAD_REQUEST};
|
false -> {error, ?ERR_BAD_REQUEST};
|
||||||
{value, {_, [String]}} ->
|
{value, {_, [String]}} ->
|
||||||
case rpc:call(Node, ejabberd_admin, restore, [String])
|
case ejabberd_cluster:call(Node, ejabberd_admin, restore, [String])
|
||||||
of
|
of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||||
@ -1695,7 +1695,7 @@ set_form(_From, _Host,
|
|||||||
case lists:keysearch(<<"path">>, 1, XData) of
|
case lists:keysearch(<<"path">>, 1, XData) of
|
||||||
false -> {error, ?ERR_BAD_REQUEST};
|
false -> {error, ?ERR_BAD_REQUEST};
|
||||||
{value, {_, [String]}} ->
|
{value, {_, [String]}} ->
|
||||||
case rpc:call(Node, ejabberd_admin, dump_to_textfile,
|
case ejabberd_cluster:call(Node, ejabberd_admin, dump_to_textfile,
|
||||||
[String])
|
[String])
|
||||||
of
|
of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
@ -1715,7 +1715,7 @@ set_form(_From, _Host,
|
|||||||
case lists:keysearch(<<"path">>, 1, XData) of
|
case lists:keysearch(<<"path">>, 1, XData) of
|
||||||
false -> {error, ?ERR_BAD_REQUEST};
|
false -> {error, ?ERR_BAD_REQUEST};
|
||||||
{value, {_, [String]}} ->
|
{value, {_, [String]}} ->
|
||||||
rpc:call(Node, jd2ejd, import_file, [String]),
|
ejabberd_cluster:call(Node, jd2ejd, import_file, [String]),
|
||||||
{result, []};
|
{result, []};
|
||||||
_ -> {error, ?ERR_BAD_REQUEST}
|
_ -> {error, ?ERR_BAD_REQUEST}
|
||||||
end
|
end
|
||||||
@ -1729,7 +1729,7 @@ set_form(_From, _Host,
|
|||||||
case lists:keysearch(<<"path">>, 1, XData) of
|
case lists:keysearch(<<"path">>, 1, XData) of
|
||||||
false -> {error, ?ERR_BAD_REQUEST};
|
false -> {error, ?ERR_BAD_REQUEST};
|
||||||
{value, {_, [String]}} ->
|
{value, {_, [String]}} ->
|
||||||
rpc:call(Node, jd2ejd, import_dir, [String]),
|
ejabberd_cluster:call(Node, jd2ejd, import_dir, [String]),
|
||||||
{result, []};
|
{result, []};
|
||||||
_ -> {error, ?ERR_BAD_REQUEST}
|
_ -> {error, ?ERR_BAD_REQUEST}
|
||||||
end
|
end
|
||||||
@ -1912,7 +1912,6 @@ set_form(From, Host,
|
|||||||
Server)
|
Server)
|
||||||
of
|
of
|
||||||
[] ->
|
[] ->
|
||||||
%% _US = {User, Server},
|
|
||||||
case get_last_info(User, Server) of
|
case get_last_info(User, Server) of
|
||||||
not_found -> ?T(Lang, <<"Never">>);
|
not_found -> ?T(Lang, <<"Never">>);
|
||||||
{ok, Timestamp, _Status} ->
|
{ok, Timestamp, _Status} ->
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
|
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%% @copyright (C) 2014, Evgeny Khramtsov
|
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%%
|
%%%
|
||||||
%%% @end
|
%%% @end
|
||||||
%%% Created : 15 Aug 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
%%% Created : 15 Aug 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%%
|
%%%
|
||||||
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2014-2015 ProcessOne
|
%%% ejabberd, Copyright (C) 2014-2015 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
|
@ -784,8 +784,6 @@ set_form(ServerHost, Host, From, [], _Lang, XData) ->
|
|||||||
set_form(_ServerHost, _Host, _, _, _Lang, _XData) ->
|
set_form(_ServerHost, _Host, _, _, _Lang, _XData) ->
|
||||||
{error, ?ERR_SERVICE_UNAVAILABLE}.
|
{error, ?ERR_SERVICE_UNAVAILABLE}.
|
||||||
|
|
||||||
%% Host = "irc.example.com"
|
|
||||||
%% ServerHost = "example.com"
|
|
||||||
get_connection_params(Host, From, IRCServer) ->
|
get_connection_params(Host, From, IRCServer) ->
|
||||||
[_ | HostTail] = str:tokens(Host, <<".">>),
|
[_ | HostTail] = str:tokens(Host, <<".">>),
|
||||||
ServerHost = str:join(HostTail, <<".">>),
|
ServerHost = str:join(HostTail, <<".">>),
|
||||||
|
@ -221,7 +221,7 @@ process_iq_v0_2(#jid{lserver = LServer} = From,
|
|||||||
#jid{lserver = LServer} = To,
|
#jid{lserver = LServer} = To,
|
||||||
#iq{type = get, sub_el = #xmlel{name = <<"query">>} = SubEl} = IQ) ->
|
#iq{type = get, sub_el = #xmlel{name = <<"query">>} = SubEl} = IQ) ->
|
||||||
Fs = lists:flatmap(
|
Fs = lists:flatmap(
|
||||||
fun(#xmlel{name = <<"start">>} = El) ->
|
fun (#xmlel{name = <<"start">>} = El) ->
|
||||||
[{<<"start">>, [xml:get_tag_cdata(El)]}];
|
[{<<"start">>, [xml:get_tag_cdata(El)]}];
|
||||||
(#xmlel{name = <<"end">>} = El) ->
|
(#xmlel{name = <<"end">>} = El) ->
|
||||||
[{<<"end">>, [xml:get_tag_cdata(El)]}];
|
[{<<"end">>, [xml:get_tag_cdata(El)]}];
|
||||||
|
105
src/mod_muc.erl
105
src/mod_muc.erl
@ -85,10 +85,6 @@
|
|||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
|
|
||||||
%% Description: Starts the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
start_link(Host, Opts) ->
|
start_link(Host, Opts) ->
|
||||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||||
gen_server:start_link({local, Proc}, ?MODULE,
|
gen_server:start_link({local, Proc}, ?MODULE,
|
||||||
@ -295,13 +291,6 @@ can_use_nick(LServer, Host, JID, Nick, odbc) ->
|
|||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: init(Args) -> {ok, State} |
|
|
||||||
%% {ok, State, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, Reason}
|
|
||||||
%% Description: Initiates the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
init([Host, Opts]) ->
|
init([Host, Opts]) ->
|
||||||
MyHost = gen_mod:get_opt_host(Host, Opts,
|
MyHost = gen_mod:get_opt_host(Host, Opts,
|
||||||
<<"conference.@HOST@">>),
|
<<"conference.@HOST@">>),
|
||||||
@ -390,8 +379,7 @@ init([Host, Opts]) ->
|
|||||||
ejabberd_router:register_route(MyHost),
|
ejabberd_router:register_route(MyHost),
|
||||||
load_permanent_rooms(MyHost, Host,
|
load_permanent_rooms(MyHost, Host,
|
||||||
{Access, AccessCreate, AccessAdmin, AccessPersistent},
|
{Access, AccessCreate, AccessAdmin, AccessPersistent},
|
||||||
HistorySize,
|
HistorySize, RoomShaper),
|
||||||
RoomShaper),
|
|
||||||
{ok, #state{host = MyHost,
|
{ok, #state{host = MyHost,
|
||||||
server_host = Host,
|
server_host = Host,
|
||||||
access = {Access, AccessCreate, AccessAdmin, AccessPersistent},
|
access = {Access, AccessCreate, AccessAdmin, AccessPersistent},
|
||||||
@ -399,15 +387,6 @@ init([Host, Opts]) ->
|
|||||||
history_size = HistorySize,
|
history_size = HistorySize,
|
||||||
room_shaper = RoomShaper}}.
|
room_shaper = RoomShaper}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
|
|
||||||
%% {reply, Reply, State, Timeout} |
|
|
||||||
%% {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, Reply, State} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling call messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_call(stop, _From, State) ->
|
handle_call(stop, _From, State) ->
|
||||||
{stop, normal, ok, State};
|
{stop, normal, ok, State};
|
||||||
handle_call({create, Room, From, Nick, Opts}, _From,
|
handle_call({create, Room, From, Nick, Opts}, _From,
|
||||||
@ -428,20 +407,8 @@ handle_call({create, Room, From, Nick, Opts}, _From,
|
|||||||
register_room(Host, Room, Pid),
|
register_room(Host, Room, Pid),
|
||||||
{reply, ok, State}.
|
{reply, ok, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_cast(Msg, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_cast(_Msg, State) -> {noreply, State}.
|
handle_cast(_Msg, State) -> {noreply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_info(Info, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling all non call/cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_info({route, From, To, Packet},
|
handle_info({route, From, To, Packet},
|
||||||
#state{host = Host, server_host = ServerHost,
|
#state{host = Host, server_host = ServerHost,
|
||||||
access = Access, default_room_opts = DefRoomOpts,
|
access = Access, default_room_opts = DefRoomOpts,
|
||||||
@ -468,21 +435,10 @@ handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
|
|||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_info(_Info, State) -> {noreply, State}.
|
handle_info(_Info, State) -> {noreply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: terminate(Reason, State) -> void()
|
|
||||||
%% Description: This function is called by a gen_server when it is about to
|
|
||||||
%% terminate. It should be the opposite of Module:init/1 and do any necessary
|
|
||||||
%% cleaning up. When it returns, the gen_server terminates with Reason.
|
|
||||||
%% The return value is ignored.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
terminate(_Reason, State) ->
|
terminate(_Reason, State) ->
|
||||||
ejabberd_router:unregister_route(State#state.host),
|
ejabberd_router:unregister_route(State#state.host),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
|
|
||||||
%% Description: Convert process state when code is changed
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
@ -645,8 +601,8 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
|||||||
<<"error">> -> ok;
|
<<"error">> -> ok;
|
||||||
<<"result">> -> ok;
|
<<"result">> -> ok;
|
||||||
_ ->
|
_ ->
|
||||||
Err = jlib:make_error_reply(
|
Err = jlib:make_error_reply(Packet,
|
||||||
Packet, ?ERR_ITEM_NOT_FOUND),
|
?ERR_ITEM_NOT_FOUND),
|
||||||
ejabberd_router:route(To, From, Err)
|
ejabberd_router:route(To, From, Err)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
@ -657,14 +613,11 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
|||||||
case {Name, Type} of
|
case {Name, Type} of
|
||||||
{<<"presence">>, <<"">>} ->
|
{<<"presence">>, <<"">>} ->
|
||||||
case check_user_can_create_room(ServerHost,
|
case check_user_can_create_room(ServerHost,
|
||||||
AccessCreate, From,
|
AccessCreate, From, Room) of
|
||||||
Room) of
|
|
||||||
true ->
|
true ->
|
||||||
{ok, Pid} = start_new_room(
|
{ok, Pid} = start_new_room(Host, ServerHost, Access,
|
||||||
Host, ServerHost, Access,
|
|
||||||
Room, HistorySize,
|
Room, HistorySize,
|
||||||
RoomShaper, From,
|
RoomShaper, From, Nick, DefRoomOpts),
|
||||||
Nick, DefRoomOpts),
|
|
||||||
register_room(Host, Room, Pid),
|
register_room(Host, Room, Pid),
|
||||||
mod_muc_room:route(Pid, From, Nick, Packet),
|
mod_muc_room:route(Pid, From, Nick, Packet),
|
||||||
ok;
|
ok;
|
||||||
@ -679,8 +632,7 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
|||||||
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs),
|
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs),
|
||||||
ErrText = <<"Conference room does not exist">>,
|
ErrText = <<"Conference room does not exist">>,
|
||||||
Err = jlib:make_error_reply(Packet,
|
Err = jlib:make_error_reply(Packet,
|
||||||
?ERRT_ITEM_NOT_FOUND(Lang,
|
?ERRT_ITEM_NOT_FOUND(Lang, ErrText)),
|
||||||
ErrText)),
|
|
||||||
ejabberd_router:route(To, From, Err)
|
ejabberd_router:route(To, From, Err)
|
||||||
end;
|
end;
|
||||||
[R] ->
|
[R] ->
|
||||||
@ -743,25 +695,22 @@ get_rooms(LServer, Host, odbc) ->
|
|||||||
Err -> ?ERROR_MSG("failed to get rooms: ~p", [Err]), []
|
Err -> ?ERROR_MSG("failed to get rooms: ~p", [Err]), []
|
||||||
end.
|
end.
|
||||||
|
|
||||||
load_permanent_rooms(Host, ServerHost, Access, HistorySize, RoomShaper) ->
|
load_permanent_rooms(Host, ServerHost, Access,
|
||||||
|
HistorySize, RoomShaper) ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(R) ->
|
fun(R) ->
|
||||||
{Room, Host} = R#muc_room.name_host,
|
{Room, Host} = R#muc_room.name_host,
|
||||||
case mnesia:dirty_read(muc_online_room, {Room, Host}) of
|
case mnesia:dirty_read(muc_online_room, {Room, Host}) of
|
||||||
[] ->
|
[] ->
|
||||||
{ok, Pid} = mod_muc_room:start(
|
{ok, Pid} = mod_muc_room:start(Host,
|
||||||
Host,
|
ServerHost, Access, Room,
|
||||||
ServerHost,
|
HistorySize, RoomShaper,
|
||||||
Access,
|
|
||||||
Room,
|
|
||||||
HistorySize,
|
|
||||||
RoomShaper,
|
|
||||||
R#muc_room.opts),
|
R#muc_room.opts),
|
||||||
register_room(Host, Room, Pid);
|
register_room(Host, Room, Pid);
|
||||||
_ ->
|
_ -> ok
|
||||||
ok
|
|
||||||
end
|
end
|
||||||
end, get_rooms(ServerHost, Host)).
|
end,
|
||||||
|
get_rooms(ServerHost, Host)).
|
||||||
|
|
||||||
start_new_room(Host, ServerHost, Access, Room,
|
start_new_room(Host, ServerHost, Access, Room,
|
||||||
HistorySize, RoomShaper, From,
|
HistorySize, RoomShaper, From,
|
||||||
@ -769,15 +718,13 @@ start_new_room(Host, ServerHost, Access, Room,
|
|||||||
case restore_room(ServerHost, Host, Room) of
|
case restore_room(ServerHost, Host, Room) of
|
||||||
error ->
|
error ->
|
||||||
?DEBUG("MUC: open new room '~s'~n", [Room]),
|
?DEBUG("MUC: open new room '~s'~n", [Room]),
|
||||||
mod_muc_room:start(Host, ServerHost, Access,
|
mod_muc_room:start(Host, ServerHost, Access, Room,
|
||||||
Room, HistorySize,
|
HistorySize, RoomShaper,
|
||||||
RoomShaper, From,
|
From, Nick, DefRoomOpts);
|
||||||
Nick, DefRoomOpts);
|
|
||||||
Opts ->
|
Opts ->
|
||||||
?DEBUG("MUC: restore room '~s'~n", [Room]),
|
?DEBUG("MUC: restore room '~s'~n", [Room]),
|
||||||
mod_muc_room:start(Host, ServerHost, Access,
|
mod_muc_room:start(Host, ServerHost, Access, Room,
|
||||||
Room, HistorySize,
|
HistorySize, RoomShaper, Opts)
|
||||||
RoomShaper, Opts)
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
register_room(Host, Room, Pid) ->
|
register_room(Host, Room, Pid) ->
|
||||||
@ -840,7 +787,6 @@ iq_disco_items(Host, From, Lang, none) ->
|
|||||||
_ -> false
|
_ -> false
|
||||||
end
|
end
|
||||||
end, get_vh_rooms(Host));
|
end, get_vh_rooms(Host));
|
||||||
|
|
||||||
iq_disco_items(Host, From, Lang, Rsm) ->
|
iq_disco_items(Host, From, Lang, Rsm) ->
|
||||||
{Rooms, RsmO} = get_vh_rooms(Host, Rsm),
|
{Rooms, RsmO} = get_vh_rooms(Host, Rsm),
|
||||||
RsmOut = jlib:rsm_encode(RsmO),
|
RsmOut = jlib:rsm_encode(RsmO),
|
||||||
@ -920,13 +866,6 @@ get_room_pos(Desired, [_ | Rooms], HeadPosition) ->
|
|||||||
flush() -> receive _ -> flush() after 0 -> ok end.
|
flush() -> receive _ -> flush() after 0 -> ok end.
|
||||||
|
|
||||||
-define(XFIELD(Type, Label, Var, Val),
|
-define(XFIELD(Type, Label, Var, Val),
|
||||||
%% @doc Get a pseudo unique Room Name. The Room Name is generated as a hash of
|
|
||||||
%% the requester JID, the local time and a random salt.
|
|
||||||
%%
|
|
||||||
%% "pseudo" because we don't verify that there is not a room
|
|
||||||
%% with the returned Name already created, nor mark the generated Name
|
|
||||||
%% as "already used". But in practice, it is unique enough. See
|
|
||||||
%% http://xmpp.org/extensions/xep-0045.html#createroom-unique
|
|
||||||
#xmlel{name = <<"field">>,
|
#xmlel{name = <<"field">>,
|
||||||
attrs =
|
attrs =
|
||||||
[{<<"type">>, Type},
|
[{<<"type">>, Type},
|
||||||
@ -1177,7 +1116,6 @@ iq_get_vcard(Lang) ->
|
|||||||
<<"ejabberd MUC module">>))/binary,
|
<<"ejabberd MUC module">>))/binary,
|
||||||
"\nCopyright (c) 2003-2015 ProcessOne">>}]}].
|
"\nCopyright (c) 2003-2015 ProcessOne">>}]}].
|
||||||
|
|
||||||
|
|
||||||
broadcast_service_message(Host, Msg) ->
|
broadcast_service_message(Host, Msg) ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(#muc_online_room{pid = Pid}) ->
|
fun(#muc_online_room{pid = Pid}) ->
|
||||||
@ -1349,8 +1287,7 @@ import(_LServer) ->
|
|||||||
[{<<"select name, host, opts from muc_room;">>,
|
[{<<"select name, host, opts from muc_room;">>,
|
||||||
fun([Name, RoomHost, SOpts]) ->
|
fun([Name, RoomHost, SOpts]) ->
|
||||||
Opts = opts_to_binary(ejabberd_odbc:decode_term(SOpts)),
|
Opts = opts_to_binary(ejabberd_odbc:decode_term(SOpts)),
|
||||||
#muc_room{name_host = {Name, RoomHost},
|
#muc_room{name_host = {Name, RoomHost}, opts = Opts}
|
||||||
opts = Opts}
|
|
||||||
end},
|
end},
|
||||||
{<<"select jid, host, nick from muc_registered;">>,
|
{<<"select jid, host, nick from muc_registered;">>,
|
||||||
fun([J, RoomHost, Nick]) ->
|
fun([J, RoomHost, Nick]) ->
|
||||||
|
@ -411,7 +411,6 @@ create_room(Name, Host, ServerHost) ->
|
|||||||
AcCreate = gen_mod:get_module_opt(ServerHost, mod_muc, access_create, fun(X) -> X end, all),
|
AcCreate = gen_mod:get_module_opt(ServerHost, mod_muc, access_create, fun(X) -> X end, all),
|
||||||
AcAdmin = gen_mod:get_module_opt(ServerHost, mod_muc, access_admin, fun(X) -> X end, none),
|
AcAdmin = gen_mod:get_module_opt(ServerHost, mod_muc, access_admin, fun(X) -> X end, none),
|
||||||
AcPer = gen_mod:get_module_opt(ServerHost, mod_muc, access_persistent, fun(X) -> X end, all),
|
AcPer = gen_mod:get_module_opt(ServerHost, mod_muc, access_persistent, fun(X) -> X end, all),
|
||||||
_PersistHistory = gen_mod:get_module_opt(ServerHost, mod_muc, persist_history, fun(X) -> X end, false),
|
|
||||||
HistorySize = gen_mod:get_module_opt(ServerHost, mod_muc, history_size, fun(X) -> X end, 20),
|
HistorySize = gen_mod:get_module_opt(ServerHost, mod_muc, history_size, fun(X) -> X end, 20),
|
||||||
RoomShaper = gen_mod:get_module_opt(ServerHost, mod_muc, room_shaper, fun(X) -> X end, none),
|
RoomShaper = gen_mod:get_module_opt(ServerHost, mod_muc, room_shaper, fun(X) -> X end, none),
|
||||||
|
|
||||||
|
@ -76,23 +76,14 @@
|
|||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
|
|
||||||
%% Description: Starts the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
start_link(Host, Opts) ->
|
start_link(Host, Opts) ->
|
||||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||||
gen_server:start_link({local, Proc}, ?MODULE, [Host, Opts], []).
|
gen_server:start_link({local, Proc}, ?MODULE, [Host, Opts], []).
|
||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||||
ChildSpec =
|
ChildSpec = {Proc, {?MODULE, start_link, [Host, Opts]},
|
||||||
{Proc,
|
temporary, 1000, worker, [?MODULE]},
|
||||||
{?MODULE, start_link, [Host, Opts]},
|
|
||||||
temporary,
|
|
||||||
1000,
|
|
||||||
worker,
|
|
||||||
[?MODULE]},
|
|
||||||
supervisor:start_child(ejabberd_sup, ChildSpec).
|
supervisor:start_child(ejabberd_sup, ChildSpec).
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
@ -123,14 +114,6 @@ transform_module_options(Opts) ->
|
|||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: init(Args) -> {ok, State} |
|
|
||||||
%% {ok, State, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, Reason}
|
|
||||||
%% Description: Initiates the server
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
init([Host, Opts]) ->
|
init([Host, Opts]) ->
|
||||||
OutDir = gen_mod:get_opt(outdir, Opts,
|
OutDir = gen_mod:get_opt(outdir, Opts,
|
||||||
fun iolist_to_binary/1,
|
fun iolist_to_binary/1,
|
||||||
@ -181,31 +164,17 @@ init([Host, Opts]) ->
|
|||||||
{ok,
|
{ok,
|
||||||
#logstate{host = Host, out_dir = OutDir,
|
#logstate{host = Host, out_dir = OutDir,
|
||||||
dir_type = DirType, dir_name = DirName,
|
dir_type = DirType, dir_name = DirName,
|
||||||
file_format = FileFormat, file_permissions = FilePermissions, css_file = CSSFile,
|
file_format = FileFormat, css_file = CSSFile,
|
||||||
|
file_permissions = FilePermissions,
|
||||||
access = AccessLog, lang = Lang, timezone = Timezone,
|
access = AccessLog, lang = Lang, timezone = Timezone,
|
||||||
spam_prevention = NoFollow, top_link = Top_link}}.
|
spam_prevention = NoFollow, top_link = Top_link}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
|
|
||||||
%% {reply, Reply, State, Timeout} |
|
|
||||||
%% {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, Reply, State} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling call messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_call({check_access_log, ServerHost, FromJID}, _From, State) ->
|
handle_call({check_access_log, ServerHost, FromJID}, _From, State) ->
|
||||||
Reply = acl:match_rule(ServerHost, State#logstate.access, FromJID),
|
Reply = acl:match_rule(ServerHost, State#logstate.access, FromJID),
|
||||||
{reply, Reply, State};
|
{reply, Reply, State};
|
||||||
handle_call(stop, _From, State) ->
|
handle_call(stop, _From, State) ->
|
||||||
{stop, normal, ok, State}.
|
{stop, normal, ok, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_cast(Msg, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_cast({add_to_log, Type, Data, Room, Opts}, State) ->
|
handle_cast({add_to_log, Type, Data, Room, Opts}, State) ->
|
||||||
case catch add_to_log2(Type, Data, Room, Opts, State) of
|
case catch add_to_log2(Type, Data, Room, Opts, State) of
|
||||||
{'EXIT', Reason} -> ?ERROR_MSG("~p", [Reason]);
|
{'EXIT', Reason} -> ?ERROR_MSG("~p", [Reason]);
|
||||||
@ -214,27 +183,10 @@ handle_cast({add_to_log, Type, Data, Room, Opts}, State) ->
|
|||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_cast(_Msg, State) -> {noreply, State}.
|
handle_cast(_Msg, State) -> {noreply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: handle_info(Info, State) -> {noreply, State} |
|
|
||||||
%% {noreply, State, Timeout} |
|
|
||||||
%% {stop, Reason, State}
|
|
||||||
%% Description: Handling all non call/cast messages
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
handle_info(_Info, State) -> {noreply, State}.
|
handle_info(_Info, State) -> {noreply, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: terminate(Reason, State) -> void()
|
|
||||||
%% Description: This function is called by a gen_server when it is about to
|
|
||||||
%% terminate. It should be the opposite of Module:init/1 and do any necessary
|
|
||||||
%% cleaning up. When it returns, the gen_server terminates with Reason.
|
|
||||||
%% The return value is ignored.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
terminate(_Reason, _State) -> ok.
|
terminate(_Reason, _State) -> ok.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
|
|
||||||
%% Description: Convert process state when code is changed
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
@ -349,7 +301,6 @@ close_previous_log(Fn, Images_dir, FileFormat) ->
|
|||||||
|
|
||||||
write_last_lines(_, _, plaintext) -> ok;
|
write_last_lines(_, _, plaintext) -> ok;
|
||||||
write_last_lines(F, Images_dir, _FileFormat) ->
|
write_last_lines(F, Images_dir, _FileFormat) ->
|
||||||
%% list_to_integer/2 was introduced in OTP R14
|
|
||||||
fw(F, <<"<div class=\"legend\">">>),
|
fw(F, <<"<div class=\"legend\">">>),
|
||||||
fw(F,
|
fw(F,
|
||||||
<<" <a href=\"http://www.ejabberd.im\"><img "
|
<<" <a href=\"http://www.ejabberd.im\"><img "
|
||||||
@ -1163,10 +1114,7 @@ roomoccupants_to_string(Users, _FileFormat) ->
|
|||||||
Users1 /= []],
|
Users1 /= []],
|
||||||
iolist_to_binary([<<"<div class=\"rcot\">">>, Res, <<"</div>">>]).
|
iolist_to_binary([<<"<div class=\"rcot\">">>, Res, <<"</div>">>]).
|
||||||
|
|
||||||
%% Users = [{JID, Nick, Role}]
|
|
||||||
group_by_role(Users) ->
|
group_by_role(Users) ->
|
||||||
%% Role = atom()
|
|
||||||
%% Users = [{JID, Nick}]
|
|
||||||
{Ms, Ps, Vs, Ns} = lists:foldl(fun ({JID, Nick,
|
{Ms, Ps, Vs, Ns} = lists:foldl(fun ({JID, Nick,
|
||||||
moderator},
|
moderator},
|
||||||
{Mod, Par, Vis, Non}) ->
|
{Mod, Par, Vis, Non}) ->
|
||||||
@ -1238,7 +1186,8 @@ get_room_state(RoomPid) ->
|
|||||||
get_state),
|
get_state),
|
||||||
R.
|
R.
|
||||||
|
|
||||||
get_proc_name(Host) -> gen_mod:get_module_proc(Host, ?PROCNAME).
|
get_proc_name(Host) ->
|
||||||
|
gen_mod:get_module_proc(Host, ?PROCNAME).
|
||||||
|
|
||||||
calc_hour_offset(TimeHere) ->
|
calc_hour_offset(TimeHere) ->
|
||||||
TimeZero = calendar:now_to_universal_time(now()),
|
TimeZero = calendar:now_to_universal_time(now()),
|
||||||
|
@ -112,14 +112,8 @@ start_link(Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts) ->
|
|||||||
%%% Callback functions from gen_fsm
|
%%% Callback functions from gen_fsm
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
init([Host, ServerHost, Access, Room, HistorySize,
|
||||||
%% Func: init/1
|
RoomShaper, Creator, _Nick, DefRoomOpts]) ->
|
||||||
%% Returns: {ok, StateName, StateData} |
|
|
||||||
%% {ok, StateName, StateData, Timeout} |
|
|
||||||
%% ignore |
|
|
||||||
%% {stop, StopReason}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Creator, _Nick, DefRoomOpts]) ->
|
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
Shaper = shaper:new(RoomShaper),
|
Shaper = shaper:new(RoomShaper),
|
||||||
State = set_affiliation(Creator, owner,
|
State = set_affiliation(Creator, owner,
|
||||||
@ -155,12 +149,6 @@ init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts]) ->
|
|||||||
add_to_log(room_existence, started, State),
|
add_to_log(room_existence, started, State),
|
||||||
{ok, normal_state, State}.
|
{ok, normal_state, State}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: StateName/2
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
normal_state({route, From, <<"">>,
|
normal_state({route, From, <<"">>,
|
||||||
#xmlel{name = <<"message">>, attrs = Attrs,
|
#xmlel{name = <<"message">>, attrs = Attrs,
|
||||||
children = Els} =
|
children = Els} =
|
||||||
@ -688,12 +676,6 @@ normal_state({route, From, ToNick,
|
|||||||
normal_state(_Event, StateData) ->
|
normal_state(_Event, StateData) ->
|
||||||
{next_state, normal_state, StateData}.
|
{next_state, normal_state, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_event/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_event({service_message, Msg}, _StateName,
|
handle_event({service_message, Msg}, _StateName,
|
||||||
StateData) ->
|
StateData) ->
|
||||||
MessagePkt = #xmlel{name = <<"message">>,
|
MessagePkt = #xmlel{name = <<"message">>,
|
||||||
@ -742,15 +724,6 @@ handle_event({set_affiliations, Affiliations},
|
|||||||
handle_event(_Event, StateName, StateData) ->
|
handle_event(_Event, StateName, StateData) ->
|
||||||
{next_state, StateName, StateData}.
|
{next_state, StateName, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_sync_event/4
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData} |
|
|
||||||
%% {reply, Reply, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData} |
|
|
||||||
%% {stop, Reason, Reply, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_sync_event({get_disco_item, JID, Lang}, _From, StateName, StateData) ->
|
handle_sync_event({get_disco_item, JID, Lang}, _From, StateName, StateData) ->
|
||||||
Reply = get_roomdesc_reply(JID, StateData,
|
Reply = get_roomdesc_reply(JID, StateData,
|
||||||
get_roomdesc_tail(StateData, Lang)),
|
get_roomdesc_tail(StateData, Lang)),
|
||||||
@ -779,12 +752,6 @@ handle_sync_event(_Event, _From, StateName,
|
|||||||
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
code_change(_OldVsn, StateName, StateData, _Extra) ->
|
||||||
{ok, StateName, StateData}.
|
{ok, StateName, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: handle_info/3
|
|
||||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
|
||||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
|
||||||
%% {stop, Reason, NewStateData}
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
handle_info({process_user_presence, From}, normal_state = _StateName, StateData) ->
|
handle_info({process_user_presence, From}, normal_state = _StateName, StateData) ->
|
||||||
RoomQueueEmpty = queue:is_empty(StateData#state.room_queue),
|
RoomQueueEmpty = queue:is_empty(StateData#state.room_queue),
|
||||||
RoomQueue = queue:in({presence, From}, StateData#state.room_queue),
|
RoomQueue = queue:in({presence, From}, StateData#state.room_queue),
|
||||||
@ -864,11 +831,6 @@ handle_info(shutdown, _StateName, StateData) ->
|
|||||||
handle_info(_Info, StateName, StateData) ->
|
handle_info(_Info, StateName, StateData) ->
|
||||||
{next_state, StateName, StateData}.
|
{next_state, StateName, StateData}.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
%% Func: terminate/3
|
|
||||||
%% Purpose: Shutdown the fsm
|
|
||||||
%% Returns: any
|
|
||||||
%%----------------------------------------------------------------------
|
|
||||||
terminate(Reason, _StateName, StateData) ->
|
terminate(Reason, _StateName, StateData) ->
|
||||||
?INFO_MSG("Stopping MUC room ~s@~s",
|
?INFO_MSG("Stopping MUC room ~s@~s",
|
||||||
[StateData#state.room, StateData#state.host]),
|
[StateData#state.room, StateData#state.host]),
|
||||||
@ -979,7 +941,7 @@ process_groupchat_message(From,
|
|||||||
StateData#state.server_host,
|
StateData#state.server_host,
|
||||||
StateData#state.users,
|
StateData#state.users,
|
||||||
NewPacket),
|
NewPacket),
|
||||||
NewStateData2 = case has_body_or_subject(Packet) of
|
NewStateData2 = case has_body_or_subject(NewPacket) of
|
||||||
true ->
|
true ->
|
||||||
add_message_to_history(FromNick, From,
|
add_message_to_history(FromNick, From,
|
||||||
NewPacket,
|
NewPacket,
|
||||||
@ -1808,9 +1770,9 @@ is_nick_change(JID, Nick, StateData) ->
|
|||||||
|
|
||||||
nick_collision(User, Nick, StateData) ->
|
nick_collision(User, Nick, StateData) ->
|
||||||
UserOfNick = find_jid_by_nick(Nick, StateData),
|
UserOfNick = find_jid_by_nick(Nick, StateData),
|
||||||
UserOfNick /= false andalso
|
(UserOfNick /= false andalso
|
||||||
jlib:jid_remove_resource(jlib:jid_tolower(UserOfNick))
|
jlib:jid_remove_resource(jlib:jid_tolower(UserOfNick))
|
||||||
/= jlib:jid_remove_resource(jlib:jid_tolower(User)).
|
/= jlib:jid_remove_resource(jlib:jid_tolower(User))).
|
||||||
|
|
||||||
add_new_user(From, Nick,
|
add_new_user(From, Nick,
|
||||||
#xmlel{attrs = Attrs, children = Els} = Packet,
|
#xmlel{attrs = Attrs, children = Els} = Packet,
|
||||||
@ -4412,7 +4374,6 @@ check_invitation(From, Els, Lang, StateData) ->
|
|||||||
jlib:jid_to_string({StateData#state.room,
|
jlib:jid_to_string({StateData#state.room,
|
||||||
StateData#state.host,
|
StateData#state.host,
|
||||||
<<"">>})]),
|
<<"">>})]),
|
||||||
|
|
||||||
case
|
case
|
||||||
(StateData#state.config)#config.password_protected
|
(StateData#state.config)#config.password_protected
|
||||||
of
|
of
|
||||||
@ -4561,6 +4522,13 @@ tab_count_user(JID) ->
|
|||||||
element_size(El) ->
|
element_size(El) ->
|
||||||
byte_size(xml:element_to_binary(El)).
|
byte_size(xml:element_to_binary(El)).
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%% Multicast
|
||||||
|
|
||||||
|
send_multiple(From, Server, Users, Packet) ->
|
||||||
|
JIDs = [ User#user.jid || {_, User} <- ?DICT:to_list(Users)],
|
||||||
|
ejabberd_router_multicast:route_multicast(From, Server, JIDs, Packet).
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
%% Detect messange stanzas that don't have meaninful content
|
%% Detect messange stanzas that don't have meaninful content
|
||||||
|
|
||||||
@ -4571,9 +4539,3 @@ has_body_or_subject(Packet) ->
|
|||||||
(_) -> true
|
(_) -> true
|
||||||
end, Packet#xmlel.children).
|
end, Packet#xmlel.children).
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
%% Multicast
|
|
||||||
|
|
||||||
send_multiple(From, Server, Users, Packet) ->
|
|
||||||
JIDs = [ User#user.jid || {_, User} <- ?DICT:to_list(Users)],
|
|
||||||
ejabberd_router_multicast:route_multicast(From, Server, JIDs, Packet).
|
|
||||||
|
@ -3,6 +3,24 @@
|
|||||||
%%% Author : Badlop <badlop@process-one.net>
|
%%% Author : Badlop <badlop@process-one.net>
|
||||||
%%% Purpose : Extended Stanza Addressing (XEP-0033) support
|
%%% Purpose : Extended Stanza Addressing (XEP-0033) support
|
||||||
%%% Created : 29 May 2007 by Badlop <badlop@process-one.net>
|
%%% Created : 29 May 2007 by Badlop <badlop@process-one.net>
|
||||||
|
%%%
|
||||||
|
%%%
|
||||||
|
%%% ejabberd, Copyright (C) 2002-2015 ProcessOne
|
||||||
|
%%%
|
||||||
|
%%% This program is free software; you can redistribute it and/or
|
||||||
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
%%% published by the Free Software Foundation; either version 2 of the
|
||||||
|
%%% License, or (at your option) any later version.
|
||||||
|
%%%
|
||||||
|
%%% This program is distributed in the hope that it will be useful,
|
||||||
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
%%% General Public License for more details.
|
||||||
|
%%%
|
||||||
|
%%% You should have received a copy of the GNU General Public License along
|
||||||
|
%%% with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(mod_multicast).
|
-module(mod_multicast).
|
||||||
@ -713,8 +731,7 @@ process_iqreply_error(From, LServiceS, _Packet) ->
|
|||||||
%%% Check protocol support: Receive response: Disco
|
%%% Check protocol support: Receive response: Disco
|
||||||
%%%-------------------------
|
%%%-------------------------
|
||||||
|
|
||||||
process_iqreply_result(From, LServiceS, Packet,
|
process_iqreply_result(From, LServiceS, Packet, State) ->
|
||||||
State) ->
|
|
||||||
#xmlel{name = <<"query">>, attrs = Attrs2,
|
#xmlel{name = <<"query">>, attrs = Attrs2,
|
||||||
children = Els2} =
|
children = Els2} =
|
||||||
xml:get_subtag(Packet, <<"query">>),
|
xml:get_subtag(Packet, <<"query">>),
|
||||||
@ -741,13 +758,12 @@ process_discoinfo_result(From, LServiceS, Els,
|
|||||||
|
|
||||||
process_discoinfo_result2(From, FromS, LServiceS, Els,
|
process_discoinfo_result2(From, FromS, LServiceS, Els,
|
||||||
Waiter) ->
|
Waiter) ->
|
||||||
Multicast_support = lists:any(fun (XML) ->
|
Multicast_support =
|
||||||
|
lists:any(
|
||||||
|
fun(XML) ->
|
||||||
case XML of
|
case XML of
|
||||||
#xmlel{name = <<"feature">>,
|
#xmlel{name = <<"feature">>, attrs = Attrs} ->
|
||||||
attrs = Attrs} ->
|
(?NS_ADDRESS) == xml:get_attr_s(<<"var">>, Attrs);
|
||||||
(?NS_ADDRESS) ==
|
|
||||||
xml:get_attr_s(<<"var">>,
|
|
||||||
Attrs);
|
|
||||||
_ -> false
|
_ -> false
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -758,8 +774,7 @@ process_discoinfo_result2(From, FromS, LServiceS, Els,
|
|||||||
true ->
|
true ->
|
||||||
SenderT = sender_type(From),
|
SenderT = sender_type(From),
|
||||||
RLimits = get_limits_xml(Els, SenderT),
|
RLimits = get_limits_xml(Els, SenderT),
|
||||||
add_response(RServer,
|
add_response(RServer, {multicast_supported, FromS, RLimits}),
|
||||||
{multicast_supported, FromS, RLimits}),
|
|
||||||
FromM = Waiter#waiter.sender,
|
FromM = Waiter#waiter.sender,
|
||||||
DestsM = Group#group.dests,
|
DestsM = Group#group.dests,
|
||||||
PacketM = Waiter#waiter.packet,
|
PacketM = Waiter#waiter.packet,
|
||||||
|
@ -70,17 +70,7 @@
|
|||||||
|
|
||||||
-include("ejabberd_web_admin.hrl").
|
-include("ejabberd_web_admin.hrl").
|
||||||
|
|
||||||
-record(offline_msg,
|
-include("mod_offline.hrl").
|
||||||
{us = {<<"">>, <<"">>} :: {binary(), binary()},
|
|
||||||
timestamp = now() :: erlang:timestamp() | '_',
|
|
||||||
expire = now() :: erlang:timestamp() | never | '_',
|
|
||||||
from = #jid{} :: jid() | '_',
|
|
||||||
to = #jid{} :: jid() | '_',
|
|
||||||
packet = #xmlel{} :: xmlel() | '_'}).
|
|
||||||
|
|
||||||
-record(state,
|
|
||||||
{host = <<"">> :: binary(),
|
|
||||||
access_max_offline_messages}).
|
|
||||||
|
|
||||||
-define(PROCNAME, ejabberd_offline).
|
-define(PROCNAME, ejabberd_offline).
|
||||||
|
|
||||||
@ -139,7 +129,10 @@ init([Host, Opts]) ->
|
|||||||
?MODULE, webadmin_user, 50),
|
?MODULE, webadmin_user, 50),
|
||||||
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),
|
||||||
AccessMaxOfflineMsgs = gen_mod:get_opt(access_max_user_messages, Opts, fun(A) -> A end, max_user_offline_messages),
|
AccessMaxOfflineMsgs =
|
||||||
|
gen_mod:get_opt(access_max_user_messages, Opts,
|
||||||
|
fun(A) when is_atom(A) -> A end,
|
||||||
|
max_user_offline_messages),
|
||||||
{ok,
|
{ok,
|
||||||
#state{host = Host,
|
#state{host = Host,
|
||||||
access_max_offline_messages = AccessMaxOfflineMsgs}}.
|
access_max_offline_messages = AccessMaxOfflineMsgs}}.
|
||||||
@ -253,7 +246,6 @@ store_offline_msg(Host, {User, _}, Msgs, Len, MaxOfflineMsgs,
|
|||||||
end, Msgs)
|
end, Msgs)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% Function copied from ejabberd_sm.erl:
|
|
||||||
get_max_user_messages(AccessRule, {User, Server}, Host) ->
|
get_max_user_messages(AccessRule, {User, Server}, Host) ->
|
||||||
case acl:match_rule(
|
case acl:match_rule(
|
||||||
Host, AccessRule, jlib:make_jid(User, Server, <<"">>)) of
|
Host, AccessRule, jlib:make_jid(User, Server, <<"">>)) of
|
||||||
|
@ -584,8 +584,7 @@ process_list_set(LUser, LServer, {value, Name}, Els) ->
|
|||||||
ejabberd_sm:route(jlib:make_jid(LUser, LServer,
|
ejabberd_sm:route(jlib:make_jid(LUser, LServer,
|
||||||
<<"">>),
|
<<"">>),
|
||||||
jlib:make_jid(LUser, LServer, <<"">>),
|
jlib:make_jid(LUser, LServer, <<"">>),
|
||||||
{broadcast,
|
{broadcast, {privacy_list,
|
||||||
{privacy_list,
|
|
||||||
#userlist{name = Name,
|
#userlist{name = Name,
|
||||||
list = []},
|
list = []},
|
||||||
Name}}),
|
Name}}),
|
||||||
@ -601,8 +600,7 @@ process_list_set(LUser, LServer, {value, Name}, Els) ->
|
|||||||
ejabberd_sm:route(jlib:make_jid(LUser, LServer,
|
ejabberd_sm:route(jlib:make_jid(LUser, LServer,
|
||||||
<<"">>),
|
<<"">>),
|
||||||
jlib:make_jid(LUser, LServer, <<"">>),
|
jlib:make_jid(LUser, LServer, <<"">>),
|
||||||
{broadcast,
|
{broadcast, {privacy_list,
|
||||||
{privacy_list,
|
|
||||||
#userlist{name = Name,
|
#userlist{name = Name,
|
||||||
list = List,
|
list = List,
|
||||||
needdb = NeedDb},
|
needdb = NeedDb},
|
||||||
@ -1166,7 +1164,7 @@ update_table() ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
export(Server) ->
|
export(Server) ->
|
||||||
case ejabberd_odbc:sql_query(jlib:nameprep(Server),
|
case catch ejabberd_odbc:sql_query(jlib:nameprep(Server),
|
||||||
[<<"select id from privacy_list order by "
|
[<<"select id from privacy_list order by "
|
||||||
"id desc limit 1;">>]) of
|
"id desc limit 1;">>]) of
|
||||||
{selected, [<<"id">>], [[I]]} ->
|
{selected, [<<"id">>], [[I]]} ->
|
||||||
|
@ -64,7 +64,8 @@ start_link(Host, Opts) ->
|
|||||||
[]).
|
[]).
|
||||||
|
|
||||||
init([Opts]) ->
|
init([Opts]) ->
|
||||||
mnesia:create_table(bytestream, [{ram_copies, [node()]},
|
mnesia:create_table(bytestream,
|
||||||
|
[{ram_copies, [node()]},
|
||||||
{attributes, record_info(fields, bytestream)}]),
|
{attributes, record_info(fields, bytestream)}]),
|
||||||
mnesia:add_table_copy(bytestream, node(), ram_copies),
|
mnesia:add_table_copy(bytestream, node(), ram_copies),
|
||||||
MaxConnections = gen_mod:get_opt(max_connections, Opts,
|
MaxConnections = gen_mod:get_opt(max_connections, Opts,
|
||||||
|
@ -3481,7 +3481,6 @@ subscribed_nodes_by_jid(NotifyType, SubsByDepth) ->
|
|||||||
lists:foldl(fun({LJID, SubID, SubOptions}, {JIDs, Recipients}) ->
|
lists:foldl(fun({LJID, SubID, SubOptions}, {JIDs, Recipients}) ->
|
||||||
case is_to_deliver(LJID, NotifyType, Depth, NodeOptions, SubOptions) of
|
case is_to_deliver(LJID, NotifyType, Depth, NodeOptions, SubOptions) of
|
||||||
true ->
|
true ->
|
||||||
%% If is to deliver :
|
|
||||||
case state_can_deliver(LJID, SubOptions) of
|
case state_can_deliver(LJID, SubOptions) of
|
||||||
[] -> {JIDs, Recipients};
|
[] -> {JIDs, Recipients};
|
||||||
JIDsToDeliver ->
|
JIDsToDeliver ->
|
||||||
@ -3494,11 +3493,14 @@ subscribed_nodes_by_jid(NotifyType, SubsByDepth) ->
|
|||||||
%% - add the Jid to JIDs list co-accumulator ;
|
%% - add the Jid to JIDs list co-accumulator ;
|
||||||
%% - create a tuple of the Jid, Nidx, and SubID (as list),
|
%% - create a tuple of the Jid, Nidx, and SubID (as list),
|
||||||
%% and add the tuple to the Recipients list co-accumulator
|
%% and add the tuple to the Recipients list co-accumulator
|
||||||
{[JIDToDeliver | JIDsAcc], [{JIDToDeliver, NodeName, [SubID]} | RecipientsAcc]};
|
{[JIDToDeliver | JIDsAcc],
|
||||||
|
[{JIDToDeliver, NodeName, [SubID]}
|
||||||
|
| RecipientsAcc]};
|
||||||
true ->
|
true ->
|
||||||
%% - if the JIDs co-accumulator contains the Jid
|
%% - if the JIDs co-accumulator contains the Jid
|
||||||
%% get the tuple containing the Jid from the Recipient list co-accumulator
|
%% get the tuple containing the Jid from the Recipient list co-accumulator
|
||||||
{_, {JIDToDeliver, NodeName1, SubIDs}} = lists:keysearch(JIDToDeliver, 1, RecipientsAcc),
|
{_, {JIDToDeliver, NodeName1, SubIDs}} =
|
||||||
|
lists:keysearch(JIDToDeliver, 1, RecipientsAcc),
|
||||||
%% delete the tuple from the Recipients list
|
%% delete the tuple from the Recipients list
|
||||||
% v1 : Recipients1 = lists:keydelete(LJID, 1, Recipients),
|
% v1 : Recipients1 = lists:keydelete(LJID, 1, Recipients),
|
||||||
% v2 : Recipients1 = lists:keyreplace(LJID, 1, Recipients, {LJID, Nidx1, [SubID | SubIDs]}),
|
% v2 : Recipients1 = lists:keyreplace(LJID, 1, Recipients, {LJID, Nidx1, [SubID | SubIDs]}),
|
||||||
@ -3507,7 +3509,11 @@ subscribed_nodes_by_jid(NotifyType, SubsByDepth) ->
|
|||||||
% v1.1 : {JIDs, lists:append(Recipients1, [{LJID, Nidx1, lists:append(SubIDs, [SubID])}])}
|
% v1.1 : {JIDs, lists:append(Recipients1, [{LJID, Nidx1, lists:append(SubIDs, [SubID])}])}
|
||||||
% v1.2 : {JIDs, [{LJID, Nidx1, [SubID | SubIDs]} | Recipients1]}
|
% v1.2 : {JIDs, [{LJID, Nidx1, [SubID | SubIDs]} | Recipients1]}
|
||||||
% v2: {JIDs, Recipients1}
|
% v2: {JIDs, Recipients1}
|
||||||
{JIDsAcc, lists:keyreplace(JIDToDeliver, 1, RecipientsAcc, {JIDToDeliver, NodeName1, [SubID | SubIDs]})}
|
{JIDsAcc,
|
||||||
|
lists:keyreplace(JIDToDeliver, 1,
|
||||||
|
RecipientsAcc,
|
||||||
|
{JIDToDeliver, NodeName1,
|
||||||
|
[SubID | SubIDs]})}
|
||||||
end
|
end
|
||||||
end, {JIDs, Recipients}, JIDsToDeliver)
|
end, {JIDs, Recipients}, JIDsToDeliver)
|
||||||
end;
|
end;
|
||||||
|
@ -408,6 +408,8 @@ try_register(User, Server, Password, SourceRaw, Lang) ->
|
|||||||
{error, ?ERR_JID_MALFORMED};
|
{error, ?ERR_JID_MALFORMED};
|
||||||
{error, not_allowed} ->
|
{error, not_allowed} ->
|
||||||
{error, ?ERR_NOT_ALLOWED};
|
{error, ?ERR_NOT_ALLOWED};
|
||||||
|
{error, too_many_users} ->
|
||||||
|
{error, ?ERR_NOT_ALLOWED};
|
||||||
{error, _Reason} ->
|
{error, _Reason} ->
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||||
end
|
end
|
||||||
|
@ -1005,7 +1005,6 @@ send_unsubscription_to_rosteritems(LUser, LServer) ->
|
|||||||
end,
|
end,
|
||||||
RosterItems).
|
RosterItems).
|
||||||
|
|
||||||
%% @spec (From::jid(), Item::roster()) -> ok
|
|
||||||
send_unsubscribing_presence(From, Item) ->
|
send_unsubscribing_presence(From, Item) ->
|
||||||
IsTo = case Item#roster.subscription of
|
IsTo = case Item#roster.subscription of
|
||||||
both -> true;
|
both -> true;
|
||||||
|
@ -98,9 +98,6 @@ start(Host, Opts) ->
|
|||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
||||||
remove_user, 50).
|
remove_user, 50).
|
||||||
|
|
||||||
%%ejabberd_hooks:add(remove_user, Host,
|
|
||||||
%% ?MODULE, remove_user, 50),
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
ejabberd_hooks:delete(webadmin_menu_host, Host, ?MODULE,
|
ejabberd_hooks:delete(webadmin_menu_host, Host, ?MODULE,
|
||||||
webadmin_menu, 70),
|
webadmin_menu, 70),
|
||||||
@ -126,11 +123,10 @@ stop(Host) ->
|
|||||||
register_user, 50),
|
register_user, 50),
|
||||||
ejabberd_hooks:delete(anonymous_purge_hook, Host,
|
ejabberd_hooks:delete(anonymous_purge_hook, Host,
|
||||||
?MODULE, remove_user, 50),
|
?MODULE, remove_user, 50),
|
||||||
%%ejabberd_hooks:delete(remove_user, Host,
|
|
||||||
%% ?MODULE, remove_user, 50),
|
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
||||||
remove_user,
|
remove_user,
|
||||||
50).%%ejabberd_hooks:delete(remove_user, Host,
|
50).
|
||||||
|
%%ejabberd_hooks:delete(remove_user, Host,
|
||||||
%% ?MODULE, remove_user, 50),
|
%% ?MODULE, remove_user, 50),
|
||||||
|
|
||||||
get_user_roster(Items, US) ->
|
get_user_roster(Items, US) ->
|
||||||
@ -622,7 +618,6 @@ get_group_users(Host1, Group1) ->
|
|||||||
|
|
||||||
get_group_users(Host, Group, GroupOpts) ->
|
get_group_users(Host, Group, GroupOpts) ->
|
||||||
case proplists:get_value(all_users, GroupOpts, false) of
|
case proplists:get_value(all_users, GroupOpts, false) of
|
||||||
%% @spec (Host::string(), Group::string()) -> [{User::string(), Server::string()}]
|
|
||||||
true -> ejabberd_auth:get_vh_registered_users(Host);
|
true -> ejabberd_auth:get_vh_registered_users(Host);
|
||||||
false -> []
|
false -> []
|
||||||
end
|
end
|
||||||
@ -675,25 +670,22 @@ get_group_name(Host1, Group1) ->
|
|||||||
|
|
||||||
%% Get list of names of groups that have @all@/@online@/etc in the memberlist
|
%% Get list of names of groups that have @all@/@online@/etc in the memberlist
|
||||||
get_special_users_groups(Host) ->
|
get_special_users_groups(Host) ->
|
||||||
%% Get list of names of groups that have @online@ in the memberlist
|
|
||||||
lists:filter(fun (Group) ->
|
lists:filter(fun (Group) ->
|
||||||
get_group_opt(Host, Group, all_users, false) orelse
|
get_group_opt(Host, Group, all_users, false) orelse
|
||||||
get_group_opt(Host, Group, online_users, false)
|
get_group_opt(Host, Group, online_users, false)
|
||||||
end,
|
end,
|
||||||
list_groups(Host)).
|
list_groups(Host)).
|
||||||
|
|
||||||
|
%% Get list of names of groups that have @online@ in the memberlist
|
||||||
get_special_users_groups_online(Host) ->
|
get_special_users_groups_online(Host) ->
|
||||||
%% Given two lists of groupnames and their options,
|
|
||||||
%% return the list of displayed groups to the second list
|
|
||||||
lists:filter(fun (Group) ->
|
lists:filter(fun (Group) ->
|
||||||
get_group_opt(Host, Group, online_users, false)
|
get_group_opt(Host, Group, online_users, false)
|
||||||
end,
|
end,
|
||||||
list_groups(Host)).
|
list_groups(Host)).
|
||||||
|
|
||||||
|
%% Given two lists of groupnames and their options,
|
||||||
|
%% return the list of displayed groups to the second list
|
||||||
displayed_groups(GroupsOpts, SelectedGroupsOpts) ->
|
displayed_groups(GroupsOpts, SelectedGroupsOpts) ->
|
||||||
%% Given a list of group names with options,
|
|
||||||
%% for those that have @all@ in memberlist,
|
|
||||||
%% get the list of groups displayed
|
|
||||||
DisplayedGroups = lists:usort(lists:flatmap(fun
|
DisplayedGroups = lists:usort(lists:flatmap(fun
|
||||||
({_Group, Opts}) ->
|
({_Group, Opts}) ->
|
||||||
[G
|
[G
|
||||||
@ -712,6 +704,9 @@ displayed_groups(GroupsOpts, SelectedGroupsOpts) ->
|
|||||||
lists:member(disabled,
|
lists:member(disabled,
|
||||||
proplists:get_value(G, GroupsOpts, []))].
|
proplists:get_value(G, GroupsOpts, []))].
|
||||||
|
|
||||||
|
%% Given a list of group names with options,
|
||||||
|
%% for those that have @all@ in memberlist,
|
||||||
|
%% get the list of groups displayed
|
||||||
get_special_displayed_groups(GroupsOpts) ->
|
get_special_displayed_groups(GroupsOpts) ->
|
||||||
Groups = lists:filter(fun ({_Group, Opts}) ->
|
Groups = lists:filter(fun ({_Group, Opts}) ->
|
||||||
proplists:get_value(all_users, Opts, false)
|
proplists:get_value(all_users, Opts, false)
|
||||||
@ -825,7 +820,7 @@ is_user_in_group(US, Group, Host, odbc) ->
|
|||||||
%% @spec (Host::string(), {User::string(), Server::string()}, Group::string()) -> {atomic, ok}
|
%% @spec (Host::string(), {User::string(), Server::string()}, Group::string()) -> {atomic, ok}
|
||||||
add_user_to_group(Host, US, Group) ->
|
add_user_to_group(Host, US, Group) ->
|
||||||
{LUser, LServer} = US,
|
{LUser, LServer} = US,
|
||||||
case ejabberd_regexp:run(LUser, <<"^@.+@$">>) of
|
case ejabberd_regexp:run(LUser, <<"^@.+@\$">>) of
|
||||||
match ->
|
match ->
|
||||||
GroupOpts = (?MODULE):get_group_opts(Host, Group),
|
GroupOpts = (?MODULE):get_group_opts(Host, Group),
|
||||||
MoreGroupOpts = case LUser of
|
MoreGroupOpts = case LUser of
|
||||||
@ -884,7 +879,7 @@ push_displayed_to_user(LUser, LServer, Host, Subscription, DisplayedGroups) ->
|
|||||||
|
|
||||||
remove_user_from_group(Host, US, Group) ->
|
remove_user_from_group(Host, US, Group) ->
|
||||||
{LUser, LServer} = US,
|
{LUser, LServer} = US,
|
||||||
case ejabberd_regexp:run(LUser, <<"^@.+@$">>) of
|
case ejabberd_regexp:run(LUser, <<"^@.+@\$">>) of
|
||||||
match ->
|
match ->
|
||||||
GroupOpts = (?MODULE):get_group_opts(Host, Group),
|
GroupOpts = (?MODULE):get_group_opts(Host, Group),
|
||||||
NewGroupOpts = case LUser of
|
NewGroupOpts = case LUser of
|
||||||
|
@ -275,16 +275,9 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
|||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% For a given user, map all his shared roster contacts to groups they are
|
|
||||||
%% members of. Skip the user himself iff SkipUS is true.
|
|
||||||
get_user_to_groups_map({_, Server} = US, SkipUS) ->
|
get_user_to_groups_map({_, Server} = US, SkipUS) ->
|
||||||
DisplayedGroups = get_user_displayed_groups(US),
|
DisplayedGroups = get_user_displayed_groups(US),
|
||||||
%% Pass given FilterParseArgs to eldap_filter:parse, and if successful, run and
|
|
||||||
%% return the resulting filter, retrieving given AttributesList. Return the
|
|
||||||
%% result entries. On any error silently return an empty list of results.
|
|
||||||
%%
|
|
||||||
%% Eldap server ID and base DN for the query are both retrieved from the State
|
|
||||||
%% record.
|
|
||||||
lists:foldl(fun (Group, Dict1) ->
|
lists:foldl(fun (Group, Dict1) ->
|
||||||
GroupName = get_group_name(Server, Group),
|
GroupName = get_group_name(Server, Group),
|
||||||
lists:foldl(fun (Contact, Dict) ->
|
lists:foldl(fun (Contact, Dict) ->
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
|
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%% @copyright (C) 2014, Evgeny Khramtsov
|
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%%
|
%%%
|
||||||
%%% @end
|
%%% @end
|
||||||
%%% Created : 21 Apr 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
%%% Created : 21 Apr 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%%
|
%%%
|
||||||
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2014-2015 ProcessOne
|
%%% ejabberd, Copyright (C) 2014-2015 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
|
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%% @copyright (C) 2014, Evgeny Khramtsov
|
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%%
|
%%%
|
||||||
%%% @end
|
%%% @end
|
||||||
%%% Created : 21 Apr 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
%%% Created : 21 Apr 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%%
|
%%%
|
||||||
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2014-2015 ProcessOne
|
%%% ejabberd, Copyright (C) 2014-2015 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
|
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%% @copyright (C) 2014, Evgeny Khramtsov
|
|
||||||
%%% @doc
|
%%% @doc
|
||||||
%%%
|
%%%
|
||||||
%%% @end
|
%%% @end
|
||||||
%%% Created : 23 Apr 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
%%% Created : 23 Apr 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%%
|
%%%
|
||||||
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2014-2015 ProcessOne
|
%%% ejabberd, Copyright (C) 2014-2015 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
|
@ -175,7 +175,7 @@ get_local_stat(_Server, _, Name) ->
|
|||||||
|
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
when Name == <<"time/uptime">> ->
|
when Name == <<"time/uptime">> ->
|
||||||
case catch rpc:call(Node, erlang, statistics,
|
case catch ejabberd_cluster:call(Node, erlang, statistics,
|
||||||
[wall_clock])
|
[wall_clock])
|
||||||
of
|
of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
@ -188,7 +188,7 @@ get_node_stat(Node, Name)
|
|||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
when Name == <<"time/cputime">> ->
|
when Name == <<"time/cputime">> ->
|
||||||
case catch rpc:call(Node, erlang, statistics, [runtime])
|
case catch ejabberd_cluster:call(Node, erlang, statistics, [runtime])
|
||||||
of
|
of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
?STATERR(<<"500">>, <<"Internal Server Error">>);
|
?STATERR(<<"500">>, <<"Internal Server Error">>);
|
||||||
@ -200,7 +200,7 @@ get_node_stat(Node, Name)
|
|||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
when Name == <<"users/online">> ->
|
when Name == <<"users/online">> ->
|
||||||
case catch rpc:call(Node, ejabberd_sm,
|
case catch ejabberd_cluster:call(Node, ejabberd_sm,
|
||||||
dirty_get_my_sessions_list, [])
|
dirty_get_my_sessions_list, [])
|
||||||
of
|
of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
@ -211,7 +211,7 @@ get_node_stat(Node, Name)
|
|||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
when Name == <<"transactions/committed">> ->
|
when Name == <<"transactions/committed">> ->
|
||||||
case catch rpc:call(Node, mnesia, system_info,
|
case catch ejabberd_cluster:call(Node, mnesia, system_info,
|
||||||
[transaction_commits])
|
[transaction_commits])
|
||||||
of
|
of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
@ -222,7 +222,7 @@ get_node_stat(Node, Name)
|
|||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
when Name == <<"transactions/aborted">> ->
|
when Name == <<"transactions/aborted">> ->
|
||||||
case catch rpc:call(Node, mnesia, system_info,
|
case catch ejabberd_cluster:call(Node, mnesia, system_info,
|
||||||
[transaction_failures])
|
[transaction_failures])
|
||||||
of
|
of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
@ -233,7 +233,7 @@ get_node_stat(Node, Name)
|
|||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
when Name == <<"transactions/restarted">> ->
|
when Name == <<"transactions/restarted">> ->
|
||||||
case catch rpc:call(Node, mnesia, system_info,
|
case catch ejabberd_cluster:call(Node, mnesia, system_info,
|
||||||
[transaction_restarts])
|
[transaction_restarts])
|
||||||
of
|
of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
@ -244,7 +244,7 @@ get_node_stat(Node, Name)
|
|||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
when Name == <<"transactions/logged">> ->
|
when Name == <<"transactions/logged">> ->
|
||||||
case catch rpc:call(Node, mnesia, system_info,
|
case catch ejabberd_cluster:call(Node, mnesia, system_info,
|
||||||
[transaction_log_writes])
|
[transaction_log_writes])
|
||||||
of
|
of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
|
@ -54,7 +54,8 @@ init(Host, ServerHost, Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
terminate(Host, ServerHost) ->
|
terminate(Host, ServerHost) ->
|
||||||
node_flat:terminate(Host, ServerHost), ok.
|
node_flat:terminate(Host, ServerHost),
|
||||||
|
ok.
|
||||||
|
|
||||||
options() ->
|
options() ->
|
||||||
[{deliver_payloads, true},
|
[{deliver_payloads, true},
|
||||||
|
@ -55,7 +55,8 @@ init(Host, ServerHost, Opts) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
terminate(Host, ServerHost) ->
|
terminate(Host, ServerHost) ->
|
||||||
node_flat_odbc:terminate(Host, ServerHost), ok.
|
node_flat_odbc:terminate(Host, ServerHost),
|
||||||
|
ok.
|
||||||
|
|
||||||
options() ->
|
options() ->
|
||||||
[{odbc, true}, {rsm, true} | node_pep:options()].
|
[{odbc, true}, {rsm, true} | node_pep:options()].
|
||||||
|
Loading…
Reference in New Issue
Block a user