* src/ejabberd_listener.erl: Remove code of the unused listening

socket option 'ssl' (EJAB-159)
* src/ejabberd_app.erl: Likewise

SVN Revision: 1263
This commit is contained in:
Badlop 2008-03-31 19:48:35 +00:00
parent 2510d71ae6
commit dcc00bca6d
3 changed files with 22 additions and 68 deletions

View File

@ -1,5 +1,9 @@
2008-03-31 Badlop <badlop@process-one.net>
* src/ejabberd_listener.erl: Remove code of the unused listening
socket option 'ssl' (EJAB-159)
* src/ejabberd_app.erl: Likewise
* doc/webadmmain.png: Updated to ejabberd 2.0.0
* doc/webadmmainru.png: Likewise

View File

@ -44,7 +44,6 @@ start(normal, _Args) ->
randoms:start(),
db_init(),
sha:start(),
catch ssl:start(),
stringprep_sup:start_link(),
translate:start(),
acl:start(),

View File

@ -29,7 +29,6 @@
-export([start_link/0, init/1, start/3,
init/3,
init_ssl/4,
start_listener/3,
stop_listener/1,
add_listener/3,
@ -61,24 +60,27 @@ init(_) ->
start(Port, Module, Opts) ->
SSLError = "There is a problem with your ejabberd configuration file: the option 'ssl' for listening sockets is no longer available. To get SSL encryption use the option 'tls'.",
case includes_deprecated_ssl_option(Opts) of
false ->
{ok, proc_lib:spawn_link(?MODULE, init,
[Port, Module, Opts])};
true ->
SSLErr="There is a problem with your ejabberd configuration file: "
"the option 'ssl' for listening sockets is no longer available."
"To get SSL encryption use the option 'tls'.",
?ERROR_MSG(SSLErr, []),
{error, SSLErr}
end.
%% Parse the options of the socket,
%% and return if the deprecated option 'ssl' is included
%% @spec(Opts::[opt()]) -> true | false
includes_deprecated_ssl_option(Opts) ->
case lists:keysearch(ssl, 1, Opts) of
{value, {ssl, _SSLOpts}} ->
%%{ok, proc_lib:spawn_link(?MODULE, init_ssl,
%% [Port, Module, Opts, SSLOpts])};
?ERROR_MSG(SSLError, []),
{error, SSLError};
true;
_ ->
case lists:member(ssl, Opts) of
true ->
%%{ok, proc_lib:spawn_link(?MODULE, init_ssl,
%% [Port, Module, Opts, []])};
?ERROR_MSG(SSLError, []),
{error, SSLError};
false ->
{ok, proc_lib:spawn_link(?MODULE, init,
[Port, Module, Opts])}
end
lists:member(ssl, Opts)
end.
init(Port, Module, Opts) ->
@ -127,57 +129,6 @@ accept(ListenSocket, Module, Opts) ->
accept(ListenSocket, Module, Opts)
end.
init_ssl(Port, Module, Opts, SSLOpts) ->
SockOpts = lists:filter(fun({ip, _}) -> true;
(inet6) -> true;
(inet) -> true;
({verify, _}) -> true;
({depth, _}) -> true;
({certfile, _}) -> true;
({keyfile, _}) -> true;
({password, _}) -> true;
({cacertfile, _}) -> true;
({ciphers, _}) -> true;
(_) -> false
end, Opts),
Res = ssl:listen(Port, [binary,
{packet, 0},
{active, false},
{nodelay, true} |
SockOpts ++ SSLOpts]),
case Res of
{ok, ListenSocket} ->
accept_ssl(ListenSocket, Module, Opts);
{error, Reason} ->
?ERROR_MSG("Failed to open socket for ~p: ~p",
[{Port, Module, Opts}, Reason]),
error
end.
accept_ssl(ListenSocket, Module, Opts) ->
case ssl:accept(ListenSocket, 200) of
{ok, Socket} ->
case {ssl:sockname(Socket), ssl:peername(Socket)} of
{{ok, Addr}, {ok, PAddr}} ->
?INFO_MSG("(~w) Accepted SSL connection ~w -> ~w",
[Socket, PAddr, Addr]);
_ ->
ok
end,
{ok, Pid} = Module:start({ssl, Socket}, Opts),
catch ssl:controlling_process(Socket, Pid),
Module:become_controller(Pid),
accept_ssl(ListenSocket, Module, Opts);
{error, timeout} ->
accept_ssl(ListenSocket, Module, Opts);
{error, Reason} ->
?INFO_MSG("(~w) Failed SSL handshake: ~w",
[ListenSocket, Reason]),
accept_ssl(ListenSocket, Module, Opts)
end.
start_listener(Port, Module, Opts) ->
start_module_sup(Module),
start_listener_sup(Port, Module, Opts).