25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

* src/ejabberd_s2s_out.erl: Fixed invalid behaviour upon

connecting to host with invalid domain
* src/ejabberd_s2s.erl: Likewise

SVN Revision: 433
This commit is contained in:
Alexey Shchepin 2005-11-12 03:42:12 +00:00
parent 719cd49e59
commit bbfd58a822
3 changed files with 24 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2005-11-12 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_s2s_out.erl: Fixed invalid behaviour upon
connecting to host with invalid domain
* src/ejabberd_s2s.erl: Likewise
2005-11-05 Alexey Shchepin <alexey@sevcom.net> 2005-11-05 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_config.erl: Support for per host certificates * src/ejabberd_config.erl: Support for per host certificates

View File

@ -167,7 +167,9 @@ find_connection(From, To) ->
Pid Pid
end end
end, end,
mnesia:transaction(F); TRes = mnesia:transaction(F),
ejabberd_s2s_out:start_connection(Pid),
TRes;
[El] -> [El] ->
{atomic, El#s2s.pid} {atomic, El#s2s.pid}
end. end.

View File

@ -13,7 +13,9 @@
-behaviour(gen_fsm). -behaviour(gen_fsm).
%% External exports %% External exports
-export([start/3, start_link/3]). -export([start/3,
start_link/3,
start_connection/1]).
%% gen_fsm callbacks %% gen_fsm callbacks
-export([init/1, -export([init/1,
@ -84,6 +86,9 @@ start(From, Host, Type) ->
start_link(From, Host, Type) -> start_link(From, Host, Type) ->
gen_fsm:start_link(ejabberd_s2s_out, [From, Host, Type], ?FSMOPTS). gen_fsm:start_link(ejabberd_s2s_out, [From, Host, Type], ?FSMOPTS).
start_connection(Pid) ->
gen_fsm:send_event(Pid, init).
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% Callback functions from gen_fsm %%% Callback functions from gen_fsm
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
@ -97,7 +102,6 @@ start_link(From, Host, Type) ->
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
init([From, Server, Type]) -> init([From, Server, Type]) ->
?INFO_MSG("started: ~p", [{From, Server, Type}]), ?INFO_MSG("started: ~p", [{From, Server, Type}]),
gen_fsm:send_event(self(), init),
TLS = case ejabberd_config:get_local_option(s2s_use_starttls) of TLS = case ejabberd_config:get_local_option(s2s_use_starttls) of
undefined -> undefined ->
false; false;
@ -115,6 +119,7 @@ init([From, Server, Type]) ->
{new, Key} -> {new, Key} ->
{Key, false}; {Key, false};
{verify, Pid, Key, SID} -> {verify, Pid, Key, SID} ->
start_connection(self()),
{false, {Pid, Key, SID}} {false, {Pid, Key, SID}}
end, end,
Timer = erlang:start_timer(?S2STIMEOUT, self(), []), Timer = erlang:start_timer(?S2STIMEOUT, self(), []),
@ -140,12 +145,17 @@ open_socket(init, StateData) ->
false -> {error, badarg}; false -> {error, badarg};
ASCIIAddr -> ASCIIAddr ->
?DEBUG("s2s_out: connecting to ~s:~p~n", [ASCIIAddr, Port]), ?DEBUG("s2s_out: connecting to ~s:~p~n", [ASCIIAddr, Port]),
case gen_tcp:connect(ASCIIAddr, Port, case catch gen_tcp:connect(ASCIIAddr, Port,
[binary, {packet, 0}, [binary, {packet, 0},
{active, false}]) of {active, false}]) of
{ok, _Socket} = R -> R; {ok, _Socket} = R -> R;
{error, Reason1} -> {error, Reason1} ->
?DEBUG("s2s_out: connect return ~p~n", [Reason1]), ?DEBUG("s2s_out: connect return ~p~n", [Reason1]),
catch gen_tcp:connect(Addr, Port,
[binary, {packet, 0},
{active, false}, inet6]);
{'EXIT', Reason1} ->
?DEBUG("s2s_out: connect crashed ~p~n", [Reason1]),
catch gen_tcp:connect(Addr, Port, catch gen_tcp:connect(Addr, Port,
[binary, {packet, 0}, [binary, {packet, 0},
{active, false}, inet6]) {active, false}, inet6])