mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
* 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:
parent
2510d71ae6
commit
dcc00bca6d
@ -1,5 +1,9 @@
|
|||||||
2008-03-31 Badlop <badlop@process-one.net>
|
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/webadmmain.png: Updated to ejabberd 2.0.0
|
||||||
* doc/webadmmainru.png: Likewise
|
* doc/webadmmainru.png: Likewise
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ start(normal, _Args) ->
|
|||||||
randoms:start(),
|
randoms:start(),
|
||||||
db_init(),
|
db_init(),
|
||||||
sha:start(),
|
sha:start(),
|
||||||
catch ssl:start(),
|
|
||||||
stringprep_sup:start_link(),
|
stringprep_sup:start_link(),
|
||||||
translate:start(),
|
translate:start(),
|
||||||
acl:start(),
|
acl:start(),
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
-export([start_link/0, init/1, start/3,
|
-export([start_link/0, init/1, start/3,
|
||||||
init/3,
|
init/3,
|
||||||
init_ssl/4,
|
|
||||||
start_listener/3,
|
start_listener/3,
|
||||||
stop_listener/1,
|
stop_listener/1,
|
||||||
add_listener/3,
|
add_listener/3,
|
||||||
@ -61,24 +60,27 @@ init(_) ->
|
|||||||
|
|
||||||
|
|
||||||
start(Port, Module, Opts) ->
|
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
|
case lists:keysearch(ssl, 1, Opts) of
|
||||||
{value, {ssl, _SSLOpts}} ->
|
{value, {ssl, _SSLOpts}} ->
|
||||||
%%{ok, proc_lib:spawn_link(?MODULE, init_ssl,
|
true;
|
||||||
%% [Port, Module, Opts, SSLOpts])};
|
|
||||||
?ERROR_MSG(SSLError, []),
|
|
||||||
{error, SSLError};
|
|
||||||
_ ->
|
_ ->
|
||||||
case lists:member(ssl, Opts) of
|
lists:member(ssl, Opts)
|
||||||
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
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
init(Port, Module, Opts) ->
|
init(Port, Module, Opts) ->
|
||||||
@ -127,57 +129,6 @@ accept(ListenSocket, Module, Opts) ->
|
|||||||
accept(ListenSocket, Module, Opts)
|
accept(ListenSocket, Module, Opts)
|
||||||
end.
|
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_listener(Port, Module, Opts) ->
|
||||||
start_module_sup(Module),
|
start_module_sup(Module),
|
||||||
start_listener_sup(Port, Module, Opts).
|
start_listener_sup(Port, Module, Opts).
|
||||||
|
Loading…
Reference in New Issue
Block a user