]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_listener.erl: Remove code of the unused listening
authorBadlop <badlop@process-one.net>
Mon, 31 Mar 2008 19:48:35 +0000 (19:48 +0000)
committerBadlop <badlop@process-one.net>
Mon, 31 Mar 2008 19:48:35 +0000 (19:48 +0000)
socket option 'ssl' (EJAB-159)
* src/ejabberd_app.erl: Likewise

SVN Revision: 1263

ChangeLog
src/ejabberd_app.erl
src/ejabberd_listener.erl

index 472653fcd26182356cf2d914208a2bf50129535c..e9f4dc1d516e8fab68409b5f86279e379426c67d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
 
index 4c12069d1cd9b83a054f6f4e99154ba04f199c1d..8f335ad5b97b821cfc88d88bddf3bbd0cdc8c14c 100644 (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(),
index f16cfb0d8c0eadfb0143211bec90bb527a6c84e1..98b90861cfa1188a559f9b8beb73c97b1179cbe0 100644 (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).