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

* src/ejabberd_frontend_socket.erl: Fixed SSL sockets

SVN Revision: 1664
This commit is contained in:
Alexey Shchepin 2008-10-23 14:59:49 +00:00
parent 5264d9299d
commit 7181957506
2 changed files with 24 additions and 4 deletions

View File

@ -1,3 +1,7 @@
2008-10-23 Alexey Shchepin <alexey@process-one.net>
* src/ejabberd_frontend_socket.erl: Fixed SSL sockets
2008-10-17 Badlop <badlop@process-one.net>
* src/Makefile.in: docdir should be prefixed with DESTDIR (thanks

View File

@ -93,7 +93,7 @@ start(Module, SockMod, Socket, Opts) ->
end.
starttls(FsmRef, TLSOpts) ->
gen_server:call(FsmRef, {starttls, TLSOpts}),
%gen_server:call(FsmRef, {starttls, TLSOpts}),
FsmRef.
starttls(FsmRef, TLSOpts, Data) ->
@ -136,7 +136,8 @@ sockname(FsmRef) ->
gen_server:call(FsmRef, sockname).
peername(FsmRef) ->
gen_server:call(FsmRef, peername).
%gen_server:call(FsmRef, peername).
{ok, {{0, 0, 0, 0}, 0}}.
%%====================================================================
@ -153,11 +154,12 @@ peername(FsmRef) ->
init([Module, SockMod, Socket, Opts, Receiver]) ->
%% TODO: monitor the receiver
Node = ejabberd_node_groups:get_closest_node(backend),
{SockMod2, Socket2} = check_starttls(SockMod, Socket, Receiver, Opts),
{ok, Pid} =
rpc:call(Node, Module, start, [{?MODULE, self()}, Opts]),
ejabberd_receiver:become_controller(Receiver, Pid),
{ok, #state{sockmod = SockMod,
socket = Socket,
{ok, #state{sockmod = SockMod2,
socket = Socket2,
receiver = Receiver}}.
%%--------------------------------------------------------------------
@ -298,3 +300,17 @@ code_change(_OldVsn, State, _Extra) ->
%%--------------------------------------------------------------------
%%% Internal functions
%%--------------------------------------------------------------------
check_starttls(SockMod, Socket, Receiver, Opts) ->
TLSEnabled = lists:member(tls, Opts),
TLSOpts = lists:filter(fun({certfile, _}) -> true;
(_) -> false
end, Opts),
if
TLSEnabled ->
{ok, TLSSocket} = tls:tcp_to_tls(Socket, TLSOpts),
ejabberd_receiver:starttls(Receiver, TLSSocket),
{tls, TLSSocket};
true ->
{SockMod, Socket}
end.