mirror of
https://github.com/processone/ejabberd.git
synced 2024-08-14 01:38:09 +02:00
merge resolved against latest 2.1.x
This commit is contained in:
commit
7da8d9e4e3
@ -45,6 +45,7 @@
|
|||||||
wait_for_features/2,
|
wait_for_features/2,
|
||||||
wait_for_auth_result/2,
|
wait_for_auth_result/2,
|
||||||
wait_for_starttls_proceed/2,
|
wait_for_starttls_proceed/2,
|
||||||
|
relay_to_bridge/2,
|
||||||
reopen_socket/2,
|
reopen_socket/2,
|
||||||
wait_before_retry/2,
|
wait_before_retry/2,
|
||||||
stream_established/2,
|
stream_established/2,
|
||||||
@ -73,6 +74,7 @@
|
|||||||
myname, server, queue,
|
myname, server, queue,
|
||||||
delay_to_retry = undefined_delay,
|
delay_to_retry = undefined_delay,
|
||||||
new = false, verify = false,
|
new = false, verify = false,
|
||||||
|
bridge,
|
||||||
timer}).
|
timer}).
|
||||||
|
|
||||||
%%-define(DBGFSM, true).
|
%%-define(DBGFSM, true).
|
||||||
@ -234,8 +236,19 @@ open_socket(init, StateData) ->
|
|||||||
{error, _Reason} ->
|
{error, _Reason} ->
|
||||||
?INFO_MSG("s2s connection: ~s -> ~s (remote server not found)",
|
?INFO_MSG("s2s connection: ~s -> ~s (remote server not found)",
|
||||||
[StateData#state.myname, StateData#state.server]),
|
[StateData#state.myname, StateData#state.server]),
|
||||||
wait_before_reconnect(StateData)
|
case ejabberd_hooks:run_fold(find_s2s_bridge,
|
||||||
%%{stop, normal, StateData}
|
undefined,
|
||||||
|
[StateData#state.myname,
|
||||||
|
StateData#state.server]) of
|
||||||
|
{Mod, Fun, Type} ->
|
||||||
|
?INFO_MSG("found a bridge to ~s for: ~s -> ~s",
|
||||||
|
[Type, StateData#state.myname,
|
||||||
|
StateData#state.server]),
|
||||||
|
NewStateData = StateData#state{bridge={Mod, Fun}},
|
||||||
|
{next_state, relay_to_bridge, NewStateData};
|
||||||
|
_ ->
|
||||||
|
wait_before_reconnect(StateData)
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
open_socket(stop, StateData) ->
|
open_socket(stop, StateData) ->
|
||||||
?INFO_MSG("s2s connection: ~s -> ~s (stopped in open socket)",
|
?INFO_MSG("s2s connection: ~s -> ~s (stopped in open socket)",
|
||||||
@ -683,6 +696,15 @@ reopen_socket(closed, StateData) ->
|
|||||||
wait_before_retry(_Event, StateData) ->
|
wait_before_retry(_Event, StateData) ->
|
||||||
{next_state, wait_before_retry, StateData, ?FSMTIMEOUT}.
|
{next_state, wait_before_retry, StateData, ?FSMTIMEOUT}.
|
||||||
|
|
||||||
|
relay_to_bridge(stop, StateData) ->
|
||||||
|
wait_before_reconnect(StateData);
|
||||||
|
relay_to_bridge(closed, StateData) ->
|
||||||
|
?INFO_MSG("relay to bridge: ~s -> ~s (closed)",
|
||||||
|
[StateData#state.myname, StateData#state.server]),
|
||||||
|
{stop, normal, StateData};
|
||||||
|
relay_to_bridge(_Event, StateData) ->
|
||||||
|
{next_state, relay_to_bridge, StateData}.
|
||||||
|
|
||||||
stream_established({xmlstreamelement, El}, StateData) ->
|
stream_established({xmlstreamelement, El}, StateData) ->
|
||||||
?DEBUG("s2S stream established", []),
|
?DEBUG("s2S stream established", []),
|
||||||
case is_verify_res(El) of
|
case is_verify_res(El) of
|
||||||
@ -836,6 +858,19 @@ handle_info({send_element, El}, StateName, StateData) ->
|
|||||||
wait_before_retry ->
|
wait_before_retry ->
|
||||||
bounce_element(El, ?ERR_REMOTE_SERVER_NOT_FOUND),
|
bounce_element(El, ?ERR_REMOTE_SERVER_NOT_FOUND),
|
||||||
{next_state, StateName, StateData};
|
{next_state, StateName, StateData};
|
||||||
|
relay_to_bridge ->
|
||||||
|
%% In this state we relay all outbound messages
|
||||||
|
%% to a foreign protocol bridge such as SMTP, SIP, etc.
|
||||||
|
{Mod, Fun} = StateData#state.bridge,
|
||||||
|
?DEBUG("relaying stanza via ~p:~p/1", [Mod, Fun]),
|
||||||
|
case catch Mod:Fun(El) of
|
||||||
|
{'EXIT', Reason} ->
|
||||||
|
?ERROR_MSG("Error while relaying to bridge: ~p", [Reason]),
|
||||||
|
bounce_element(El, ?ERR_INTERNAL_SERVER_ERROR),
|
||||||
|
wait_before_reconnect(StateData);
|
||||||
|
_ ->
|
||||||
|
{next_state, StateName, StateData}
|
||||||
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
Q = queue:in(El, StateData#state.queue),
|
Q = queue:in(El, StateData#state.queue),
|
||||||
{next_state, StateName, StateData#state{queue = Q},
|
{next_state, StateName, StateData#state{queue = Q},
|
||||||
|
@ -353,6 +353,9 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
Err = jlib:make_error_reply(Packet, ?ERR_NOT_ALLOWED),
|
Err = jlib:make_error_reply(Packet, ?ERR_NOT_ALLOWED),
|
||||||
ejabberd_router:route_error(To, From, Err, Packet)
|
ejabberd_router:route_error(To, From, Err, Packet)
|
||||||
end,
|
end,
|
||||||
|
{next_state, StateName, StateData};
|
||||||
|
handle_info(Info, StateName, StateData) ->
|
||||||
|
?ERROR_MSG("Unexpected info: ~p", [Info]),
|
||||||
{next_state, StateName, StateData}.
|
{next_state, StateName, StateData}.
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ init([Host, Opts]) ->
|
|||||||
{attributes, record_info(fields, caps_features)}]),
|
{attributes, record_info(fields, caps_features)}]),
|
||||||
mnesia:add_table_copy(caps_features, node(), disc_only_copies),
|
mnesia:add_table_copy(caps_features, node(), disc_only_copies),
|
||||||
MaxSize = gen_mod:get_opt(cache_size, Opts, 1000),
|
MaxSize = gen_mod:get_opt(cache_size, Opts, 1000),
|
||||||
LifeTime = gen_mod:get_opt(cache_life_time, Opts, timer:hours(24)),
|
LifeTime = gen_mod:get_opt(cache_life_time, Opts, timer:hours(24) div 1000),
|
||||||
cache_tab:new(caps_features, [{max_size, MaxSize}, {life_time, LifeTime}]),
|
cache_tab:new(caps_features, [{max_size, MaxSize}, {life_time, LifeTime}]),
|
||||||
ejabberd_hooks:add(user_send_packet, Host,
|
ejabberd_hooks:add(user_send_packet, Host,
|
||||||
?MODULE, user_send_packet, 75),
|
?MODULE, user_send_packet, 75),
|
||||||
|
@ -392,12 +392,13 @@ process_list_set(LUser, LServer, {value, Name}, Els) ->
|
|||||||
{atomic, {error, _} = Error} ->
|
{atomic, {error, _} = Error} ->
|
||||||
Error;
|
Error;
|
||||||
{atomic, {result, _} = Res} ->
|
{atomic, {result, _} = Res} ->
|
||||||
|
NeedDb = is_list_needdb(List),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
jlib:make_jid(LUser, LServer, ""),
|
jlib:make_jid(LUser, LServer, ""),
|
||||||
jlib:make_jid(LUser, LServer, ""),
|
jlib:make_jid(LUser, LServer, ""),
|
||||||
{xmlelement, "broadcast", [],
|
{xmlelement, "broadcast", [],
|
||||||
[{privacy_list,
|
[{privacy_list,
|
||||||
#userlist{name = Name, list = List},
|
#userlist{name = Name, list = List, needdb = NeedDb},
|
||||||
Name}]}),
|
Name}]}),
|
||||||
Res;
|
Res;
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -392,12 +392,13 @@ process_list_set(LUser, LServer, {value, Name}, Els) ->
|
|||||||
{atomic, {error, _} = Error} ->
|
{atomic, {error, _} = Error} ->
|
||||||
Error;
|
Error;
|
||||||
{atomic, {result, _} = Res} ->
|
{atomic, {result, _} = Res} ->
|
||||||
|
NeedDb = is_list_needdb(List),
|
||||||
ejabberd_router:route(
|
ejabberd_router:route(
|
||||||
jlib:make_jid(LUser, LServer, ""),
|
jlib:make_jid(LUser, LServer, ""),
|
||||||
jlib:make_jid(LUser, LServer, ""),
|
jlib:make_jid(LUser, LServer, ""),
|
||||||
{xmlelement, "broadcast", [],
|
{xmlelement, "broadcast", [],
|
||||||
[{privacy_list,
|
[{privacy_list,
|
||||||
#userlist{name = Name, list = List},
|
#userlist{name = Name, list = List, needdb = NeedDb},
|
||||||
Name}]}),
|
Name}]}),
|
||||||
Res;
|
Res;
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -169,7 +169,7 @@ start_link(Host, Opts) ->
|
|||||||
|
|
||||||
init([Host, Opts]) ->
|
init([Host, Opts]) ->
|
||||||
State = parse_options(Host, Opts),
|
State = parse_options(Host, Opts),
|
||||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, parallel),
|
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
||||||
?MODULE, process_local_iq, IQDisc),
|
?MODULE, process_local_iq, IQDisc),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_VCARD,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_VCARD,
|
||||||
|
@ -117,7 +117,7 @@ start(_Host, _Opts) ->
|
|||||||
% mod_http_bind is already started so it will not be started again
|
% mod_http_bind is already started so it will not be started again
|
||||||
ok;
|
ok;
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
{'EXIT', {start_child_error, Error}}
|
exit({start_child_error, Error})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
stop(_Host) ->
|
stop(_Host) ->
|
||||||
@ -125,7 +125,13 @@ stop(_Host) ->
|
|||||||
ok ->
|
ok ->
|
||||||
ok;
|
ok;
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
{'EXIT', {terminate_child_error, Error}}
|
exit({terminate_child_error, Error})
|
||||||
|
end,
|
||||||
|
case supervisor:delete_child(ejabberd_sup, ejabberd_http_bind_sup) of
|
||||||
|
ok ->
|
||||||
|
ok;
|
||||||
|
{error, Error2} ->
|
||||||
|
exit({delete_child_error, Error2})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
setup_database() ->
|
setup_database() ->
|
||||||
|
Loading…
Reference in New Issue
Block a user